Allow to search marker classes in dumb mode (EA-67309)
This commit is contained in:
+16
-6
@@ -18,8 +18,10 @@ package org.jetbrains.kotlin.idea.versions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -39,13 +41,21 @@ public class KotlinRuntimeLibraryCoreUtil {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
|
||||
@Override
|
||||
public PsiClass compute() {
|
||||
for (String className : CANDIDATE_CLASSES) {
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
|
||||
if (psiClass != null) {
|
||||
return psiClass;
|
||||
final Ref<PsiClass> result = new Ref<PsiClass>();
|
||||
DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String className : CANDIDATE_CLASSES) {
|
||||
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
|
||||
if (psiClass != null) {
|
||||
result.set(psiClass);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
return result.get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+6
-13
@@ -77,7 +77,7 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
||||
|
||||
@Override
|
||||
public void configure(@NotNull Project project) {
|
||||
final String defaultPathToJar = getDefaultPathToJarFile(project);
|
||||
String defaultPathToJar = getDefaultPathToJarFile(project);
|
||||
boolean showPathToJarPanel = needToChooseJarPath(project);
|
||||
|
||||
List<Module> nonConfiguredModules =
|
||||
@@ -103,19 +103,12 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
||||
copyLibraryIntoPath = dialog.getCopyIntoPath();
|
||||
}
|
||||
|
||||
final List<Module> finalModulesToConfigure = modulesToConfigure;
|
||||
final String finalCopyLibraryIntoPath = copyLibraryIntoPath;
|
||||
List<Module> finalModulesToConfigure = modulesToConfigure;
|
||||
String finalCopyLibraryIntoPath = copyLibraryIntoPath;
|
||||
|
||||
// The first root modification enters dumb mode, and we need to be able to perform isKotlinLibrary() checks
|
||||
// after that, and those checks use findClass(). Therefore, we need to enable alternative resolve here.
|
||||
DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Module module : finalModulesToConfigure) {
|
||||
configureModuleWithLibrary(module, defaultPathToJar, finalCopyLibraryIntoPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
for (Module module : finalModulesToConfigure) {
|
||||
configureModuleWithLibrary(module, defaultPathToJar, finalCopyLibraryIntoPath);
|
||||
}
|
||||
}
|
||||
|
||||
protected void configureModuleWithLibrary(
|
||||
|
||||
+2
-1
@@ -50,8 +50,9 @@ public class ConfigureKotlinNotification extends Notification {
|
||||
if (configurator == null) {
|
||||
throw new AssertionError("Missed action: " + event.getDescription());
|
||||
}
|
||||
configurator.configure(project);
|
||||
notification.expire();
|
||||
|
||||
configurator.configure(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user