How to trigger annotator without changing file?

I need to trigger the annotation engine to be carried out again on my entire editor document, without having the file changed.

Needed scenario:
My document annotator is directly depending on data provided through a jdbc layer from the database.
I may change the current database connection from a toolbar dropdown.
When I switch to another connection, I want the annotator to rerun on the active document.

I currently use a dirty workaround for this, which I do not really want to mention here... ;)

5 comments
Comment actions Permalink

DaemonCodeAnalyser.getInstance(project).restart() should work, even though it's quite a brute force approach ;)

Sascha

0
Comment actions Permalink

Thanks Sascha!
What's the scope of the analyzer? Is it the current document or all currently opened documents?
And what non-openAPI jar is containing it?

btw...
found http://intellij.net/forums/thread.jspa;?messageID=5112057? and http://www.jetbrains.net/jira/browse/IDEA-7297
;)
Looks like there is no other reasonable way to do this...

0
Comment actions Permalink

I believe the restart causes all files that belong to the project to be re-analysed. You need to add idea.jar to your IDEA-JDK to make use of it.

Sascha

0
Comment actions Permalink

idea.jar was already in my library list.
spelling of ..Analyzer was wrong (..Analiser) :)

Thanks a lot! This works. It looks like it annotates only the current file, and this is exactly what I needed. Hope I am not wrong about that...

0
Comment actions Permalink

... was wrong... :( this is resetting the annotators. The current editor is re-annotated and all other editors will be annotated when made current.

Found a more "lighter" method that serves my purpose:
DaemonCodeAnalyzer.getInstance(project).updateVisibleHighlighters(editor)

this is triggering (among others) reloading gutter action "Presentable" and re-resolving the PsiReferences.... which is all I need :)

0

Please sign in to leave a comment.