Inspection with runForWholeFile=true: Clear existing problems
Hello,
I write a inspection which depends on multiple PsiElements which can be located somewhere in the PsiFile/PsiClass.
It is something similar like the FieldCanBeLocalInspection.
So my inspection returns true in com.intellij.codeInspection.LocalInspectionTool#runForWholeFile
Register problem is not my problem. The problem is that already registered problems are not cleared when necessary.
I try to explain my inspection and use-case a bit more:
My inspection calls ProblemsHolder.registerProblem for a specific PsiJavaToken element (a simple string literal element)
because the word 'test' does not exist in the whole file (PsiFile/PsiClass).
Now, the user edits somewhere in the same file a javadoc (PsiComment) and writes the word 'test'.
The already registered problems must now be cleared.
How I am doing that?
Both PsiElements can be located in completely different locations.
Thanks
Please sign in to leave a comment.
Please show your inspection's implementation. Did you also specify runForWholeFile=true in plugin.xml registration?
Hello,
No I have not specify runForWholeFile in the plugin.xml (seems also not possible since the property i not in com.intellij.codeInspection.InspectionEP).
Please find below a reproducer. This inspection will mark every java token with a warning.
Now type somehere the code the word 'test'. For exmaple in the file javadoc header.
The warings are not cleared.
Thanks
plugin.xml entry
Code
Thanks for the sample, reproduced. It works as expected after adding runForWholeFile="true" to <localInspection...> registration in plugin.xml. Investigating.