How to trigger refresh on external annotator
Answered
Hi,
I'm creating a custom language plugin based on external annotator. Overall, it seems to be working fine. However, when there is a change (for example, changes in module or lib dependency) I want to "refresh" or re-trigger external annotator on opened editors. Is this possible?
Thanks!
Please sign in to leave a comment.
Here is the simplified code I use to reparse open files. You should add logic to only re-parse files relevant to your plugin. In my case it is all open Markdown files.
I cannot vouch for this being the correct way to do it but it does work. I am open for a better implementation.
Awesome! Thank you Vladimir!
See com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart()
Alexandr Evstigneev, Will the `com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart()` works for ExternalAnnotator? I tried, but doesn't seem to be working.
Vladimir Schneider Is there a thread restriction when calling FileContentUtil.reparseFiles, I tried running on UI thread as well as bg thread, nothing seem to be working.
ApplicationManager.getApplication().invokeAndWait(()-> {FileContentUtil.reparseFiles(project, vfl, false);
});
Never mind, I figured it out. `com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart()` is throttled restart the Annotator | ExternalAnnotator with respect to `getAutoReparseDelay`.
https://github.com/JetBrains/intellij-community/commit/75fa8aba9629d1cf5166b50e4b3051980204d8ab
After tweaking through Editor settings, it worked for me.