IconProvider Problem in IntelliJ 2023
I am using an IconProvider (com.intellij.ide.IconProvider) to add an overlay to the icons of some java classes and it had been working for years. Since version 2023.X it throws an exception:
Must be executed under progress indicator: com.intellij.openapi.progress.EmptyProgressIndicator@44a65a1b. Please see e.g. ProgressManager.runProcess()
The code that causes the problem is called in the “getIcon” method:
Query<PsiReference> search = ReferencesSearch.search(psiClass, GlobalSearchScope.moduleWithDependentsScope(module));
Collection<PsiReference> us = search.findAll();
So I tried to wrap my code, as suggested by the exception:
return ProgressManager.getInstance().runProcess(() -> {
// my code
}, ProgressManager.getInstance().getProgressIndicator()
Then I get the following exception:
This thread is already running under this indicator, starting/stopping it here might be a data race
Next try:
return ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
// my code
}, "Searching", false, psiElement.getProject()
But also no success:
Calling invokeAndWait from read-action leads to possible deadlock.
I need the ReferencesSearch because I have to add the icon to classes that are
- directly referenced in an XML file (no problem because it works without ReferencesSearch)
- classes that are instantiated in another class, that is referenced in an XML file (throws the exception because of ReferencesSearch)
Any idea what to change to make it work again?
Please sign in to leave a comment.
Hi Tom,
Could you please provide full stacktrace?
I tried to reproduce the problem by implementing a dummy icon provider with a similar logic, but could not. I run it under 2023.1.5.
Could you please share your code or create a reproducible example with a test project and steps to reproduce?
If you can share the code, but don't want to make it public, you can share it with https://uploads.jetbrains.com/browse and provide me with the upload ID (only JetBrains employees can access uploaded files).
I uploaded a minimal example that reproduces the problem with the latest stable version 2023.2.2
Upload id: 2023_09_19_23SBu73GV3gcrCBCeWwbBC (file: icontest.zip)
I think the problem is that the “find usages” should be run under a progress indicator.
could you please try
Thank you, that solved my problem.
I had already tried it with ProgressManager but it seems my problem was, that I used
instead of