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