Restarting inlay hints provider

Answered

How can I trigger the inlay hints to be computed again for any open (selected) editors?

DaemonCodeAnalyzer.getInstance(project).restart(); doesnt't work.

I also tried:

DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project);
        final FileEditor selectedEditor = FileEditorManager.getInstance(project).getSelectedEditor();
        if (selectedEditor != null) {
            final VirtualFile file = selectedEditor.getFile();
            if (file != null) {
                final PsiFile psiFile = ReadAction.compute(() -> PsiManager.getInstance(project).findFile(file));
                final Document document = ReadAction.compute(() -> FileDocumentManager.getInstance().getDocument(file));
                final ProgressIndicator daemonIndicator = new DaemonProgressIndicator();
                ProgressManager.getInstance().runProcess(() -> {
                    ReadAction.run(() -> codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator));

                }, daemonIndicator);
                codeAnalyzer.restart();
            }
        }

Writing anything in the open file causes the inlay hints to be recomputed but I want to trigger it programmatically.

Thanks!

2 comments
Comment actions Permalink

ParameterHintsPassFactory#forceHintsUpdateOnNextPass  before DaemonCodeAnalyzer#restart to force redraw

1

Please sign in to leave a comment.