How to force highlighter to parse all the document?

Hi everyone,

Normally the highlighter will parse the part where the document changed. Sometimes I need the highlighter to parse the whole document.

Is there a way to force the highligter to go through all the document?

Thanks.

5 comments
Comment actions Permalink

DaemonCodeAnalyzer.restart(PsiFile)

0
Comment actions Permalink

That didn't work for me, I tried executing this:

PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
com.intellij.codeInsight.daemon.DaemonCodeAnalyzer.getInstance(project).restart(psiFile);


On the following cases:

  • from ApplicationManager.invokeLater()
  • from ApplicationManager.runReadAction()
  • adding a listener to the document and executing from DocumentListener.documentListener().


Is there anything I'm missing?

0
Comment actions Permalink

Which highlighter do you mean exactly? Lexer highlighting or annotators/inspections?

0
Comment actions Permalink

The lexer one. Is there a way to make it go through the document? or do I have to use an annotator as a workaround?

0
Comment actions Permalink

The lexer highlighter is not intended to be used for any highlighting that depends on anything else other than the text of the document. If you need to update the highlighting based on some other conditions, then using an annotator is the correct solution, not just a workaround.

0

Please sign in to leave a comment.