mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-16 00:21:26 +00:00
correct place for enabling alternative resolve in library configurator
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.configuration;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -76,7 +77,7 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
||||
|
||||
@Override
|
||||
public void configure(@NotNull Project project) {
|
||||
String defaultPathToJar = getDefaultPathToJarFile(project);
|
||||
final String defaultPathToJar = getDefaultPathToJarFile(project);
|
||||
boolean showPathToJarPanel = needToChooseJarPath(project);
|
||||
|
||||
List<Module> nonConfiguredModules =
|
||||
@@ -102,9 +103,19 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
||||
copyLibraryIntoPath = dialog.getCopyIntoPath();
|
||||
}
|
||||
|
||||
for (Module module : modulesToConfigure) {
|
||||
configureModuleWithLibrary(module, defaultPathToJar, copyLibraryIntoPath);
|
||||
}
|
||||
final List<Module> finalModulesToConfigure = modulesToConfigure;
|
||||
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(
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
@@ -47,18 +46,11 @@ public class ConfigureKotlinNotification extends Notification {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
final KotlinProjectConfigurator configurator = ConfigureKotlinInProjectUtils.getConfiguratorByName(event.getDescription());
|
||||
KotlinProjectConfigurator configurator = ConfigureKotlinInProjectUtils.getConfiguratorByName(event.getDescription());
|
||||
if (configurator == null) {
|
||||
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
|
||||
// should enable alternative resolve.
|
||||
DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
configurator.configure(project);
|
||||
}
|
||||
});
|
||||
configurator.configure(project);
|
||||
notification.expire();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user