correct place for enabling alternative resolve in library configurator
This commit is contained in:
+15
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.configuration;
|
|||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.module.ModuleManager;
|
import com.intellij.openapi.module.ModuleManager;
|
||||||
|
import com.intellij.openapi.project.DumbService;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.*;
|
import com.intellij.openapi.roots.*;
|
||||||
import com.intellij.openapi.roots.libraries.Library;
|
import com.intellij.openapi.roots.libraries.Library;
|
||||||
@@ -76,7 +77,7 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(@NotNull Project project) {
|
public void configure(@NotNull Project project) {
|
||||||
String defaultPathToJar = getDefaultPathToJarFile(project);
|
final String defaultPathToJar = getDefaultPathToJarFile(project);
|
||||||
boolean showPathToJarPanel = needToChooseJarPath(project);
|
boolean showPathToJarPanel = needToChooseJarPath(project);
|
||||||
|
|
||||||
List<Module> nonConfiguredModules =
|
List<Module> nonConfiguredModules =
|
||||||
@@ -102,9 +103,19 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
|||||||
copyLibraryIntoPath = dialog.getCopyIntoPath();
|
copyLibraryIntoPath = dialog.getCopyIntoPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Module module : modulesToConfigure) {
|
final List<Module> finalModulesToConfigure = modulesToConfigure;
|
||||||
configureModuleWithLibrary(module, defaultPathToJar, copyLibraryIntoPath);
|
final 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void configureModuleWithLibrary(
|
protected void configureModuleWithLibrary(
|
||||||
|
|||||||
+2
-10
@@ -20,7 +20,6 @@ import com.intellij.notification.Notification;
|
|||||||
import com.intellij.notification.NotificationListener;
|
import com.intellij.notification.NotificationListener;
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.project.DumbService;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
@@ -47,18 +46,11 @@ public class ConfigureKotlinNotification extends Notification {
|
|||||||
@Override
|
@Override
|
||||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||||
final KotlinProjectConfigurator configurator = ConfigureKotlinInProjectUtils.getConfiguratorByName(event.getDescription());
|
KotlinProjectConfigurator configurator = ConfigureKotlinInProjectUtils.getConfiguratorByName(event.getDescription());
|
||||||
if (configurator == null) {
|
if (configurator == null) {
|
||||||
throw new AssertionError("Missed action: " + event.getDescription());
|
throw new AssertionError("Missed action: " + event.getDescription());
|
||||||
}
|
}
|
||||||
// The user can often click the notification while building indices, and we want it to work right away, so we
|
configurator.configure(project);
|
||||||
// should enable alternative resolve.
|
|
||||||
DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
configurator.configure(project);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
notification.expire();
|
notification.expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user