Remove problem descriptor from ProblemsHolder

已回答

Is there any way to remove a problem descriptor without recurring to its quick fix? I've created a quick fix that inserts lineInfoExtensions on that element line. However, if I insert them through another method (without recurring to the actual quick fix), the element will remain highlighted and will still allow me to press the quick fix (which won't do anything now). For consistency sake, I would like to remove the problem descriptor.

How can I achieve something like this?

0

What is "lineInfoExtensions"? I'm not sure I understand your problem, could you please share some sample screenshot/code? Thanks

0

LineInfoExtensions are strings that are appended to the IntelliJ file editor, at the end of each file line (just like debug variable values at the end of each line). The file is not changed to incorporate them, they are just a graphical asset. 

But let's clarify my problem. My quick fix does not change the psi element or the psi file where it belongs. I just persist some values (variable name, etc) into a PersistentStateComponent class. When I manually press the quick fix action, the problem descriptor disappears as expected. 

The same thing can be accomplished by filling a dialog modal. However, in this case, if the data that I've just persisted, corresponds to the same data that would have been persisted via the quick fix action, the problem descriptor will remain active. Is there a way to, programmatically, remove it?

0

Not sure I got it, but you can restart highlighting and thus force recalculation of all available quickfixes via

com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart() (all files)

or

com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart(com.intellij.psi.PsiFile) (specific file(s)).

1

Thank you. That did it!

0

请先登录再写评论。