Update editors on file based index update

Hello community,

The question is following.
I have custom line marker for java files. The marker is rendered according to data provided by my custom file based index.

The issue happens in following scenario:
User have open java file in editor. Line marker created gutter icon according to data in index.
User triggers index update while file is still opened in editor (he/she deletes file)
The gutter icon renders invalid link to file that is no longer exists. (as the gutter icon is cached)
So, the solution would be to refresh opened editors upon specific file based index update but I didn't manage to find proper API for that.

Would be grateful for any hint,
Thanks

0
3 comments
Avatar
Permanently deleted user

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

0

Hello Alexey,

I see that I can refresh gutters via the method you've provided, but I don't know how I could invoke that method upon specific File Based Index update. What API should I use?

Thanks

 

0
Avatar
Permanently deleted user

if "User triggers index update while file is still opened in editor (he/she deletes file)" then you can use e.g.

ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
if (relevant(events)) daemonAnalyzer.restart();
}
});
0

Please sign in to leave a comment.