wait for DaemonCodeAnalyzer to complete pass on file

Answered

Morning...

I'm using DaemonCodeAnalyzerEx to retrieve the linting information from the editor, such as deprecations, unused imports and so on. 

I am setting text in the current document in the editor, and what I don't know is how to wait for the linting pass to complete before attempting to retrieve the linting info. I have tried various refresh methods, DaemonCodeAnalyzer.restart(), etc etc, but nothing is working for me.

I also tried subscribing to DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC but it appears to never fire com.intellij.codeInsight.daemon.DaemonCodeAnalyzer.DaemonListenerAdapter#daemonFinished.

I'm quite new to this whole thing so quite likely a noob fail, so any help appreciated.

cheers, jamie

 

4 comments
Comment actions Permalink
project.getMessageBus().connect(/** some disposable, e.g. */ project).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() {
@Override
public void daemonFinished() {
// do something. However, take care because a daemon could have restarted and some highlighters invalidated.
}
});
0
Comment actions Permalink

Thanks for that Alexey. I had connected to the app message bus with the same topic... it works for projects. I don't suppose there is a way to get the file that it's just finished on?

0
Comment actions Permalink

no, unfortunately. However, the current opened (if any) editor can be obtained via com.intellij.openapi.fileEditor.FileEditorManager#getSelectedTextEditor

0
Comment actions Permalink

Sure... ok, thanks for your help.

0

Please sign in to leave a comment.