How to check if PsiElement contains compile error?

I'd like to suppress some inspections of mine when the inspected part of the code
contains compile errors.
How can I check that?
Somewhere I saw code that uses a visitor and sets a flag in visitErrorElement.
The problem is that not every compile error seems to result in PsiErrorElements in the code,
e.g. "String s = 22;"

Comment actions Permalink

Inspections should not be called on elements with errors automatically. Do you face a situation when they do?

Comment actions Permalink

My inspection deals with annotations on classes.
Since there is no checkClassAnnotation() I have overriden checkClass().
checkClass() gets called even though there are compile errors in the annotations of the class.
That's probably ok, as inspections that work on the class itself can work fine.

It's not that important to me, but it makes my inspections a little bloated because they now must be able to deal with incorrect PSI structures.


Please sign in to leave a comment.