IC2 (latest)/Idea 2021.2.3 problem with correctly parsing/inspecting code
I haven’t figured out a pattern for the problem starting but once it does, I have to restart IDEA to get the code inspection working again.
Basically after making changes IC2 starts having problems with the code inspection.
I think it starts with problems finding local classes inside another class really.
But basically it suddenly starts marking various tokens in red when they are in fact correct and were “findable” before the error started happening.
For example the class I keep seeing this in a class like this, where the inspection starts saying it can’t find “Bar”
cannot resolve symbol 'Bar'
is there error I suddenly start getting for all references to internal classes
public class Foo {
public class Bar {
public String someString {get; set;}
}
public static Bar someMethod() {
Bar someBarInstance = new Bar();
//code
System.debug(someBarInstance.someString);
return someBarInstance;
}
}
So in this code it wouldn’t report a problem with the class Bar,
But would report the return type of “someMethod” cannot be resolved
Also it would report “someString” cannot be resolved
etc.
Look at the attached log at the end of the log for these errors:
2021-11-02 12:25:11,792 [76831146] ERROR - aemon.impl.PassExecutorService - Element class com.intellij.psi.impl.source.tree.CompositeElement of type FORMAL_PARAMETER (class com.illuminatedcloud.intellij.psi.stub.ApexFormalParameterElementType)
com.intellij.psi.PsiInvalidElementAccessException: Element class com.intellij.psi.impl.source.tree.CompositeElement of type FORMAL_PARAMETER (class com.illuminatedcloud.intellij.psi.stub.ApexFormalParameterElementType)
Comments (5)
-
repo owner -
reporter so far so good. I did some heavy edits on the class in question where I kept seeing this and haven’t had problems so with any luck this took care of it.
-
repo owner Just to clarify, did you just do a cache/index rebuild or a full reinstall?
-
repo owner - changed status to resolved
Seems to be resolved. Certainly reopen if the issue comes back.
-
reporter I did the cache invalidate since it was already a clean installation
- Log in to comment
Patrick, I've not seen this one myself, nor have I heard about it from others, so let's start with some relatively simple things to try first.
For starters, please do a full cache/index rebuild using File>Invalidate Caches and allow the IDE to restart. If the problem is still present after post-restart indexing completes--or if it comes back after editing code for a bit, please completely uninstall and reinstall IntelliJ IDEA. I know that seems extreme, but particularly with 2021.2, I've seen significant issues with installs based on in-place upgrades to that version--even the more recent patch-levels--that are resolved by an uninstall/reinstall.
Please let me know your findings either way if you don't mind.