Try to avoid race condition in "configure Js module" action
This commit is contained in:
+14
-7
@@ -92,10 +92,11 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
||||
if (JavaPsiFacade.getInstance(myProject).findClass("jet.JetObject", scope) == null) {
|
||||
return createNotificationPanel(module);
|
||||
}
|
||||
|
||||
} catch (ProcessCanceledException e) {
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
// Ignore
|
||||
} catch (IndexNotReadyException e) {
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@@ -116,7 +117,8 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
||||
|
||||
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||
if (runtimePath == null) {
|
||||
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.", "No Runtime Found");
|
||||
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.",
|
||||
"No Runtime Found");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -131,7 +133,8 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
||||
if (jarVfs != null) {
|
||||
jarVfs.refresh(false, false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
Messages.showErrorDialog(myProject, "Error copying jar: " + e.getLocalizedMessage(), "Error Copying File");
|
||||
return null;
|
||||
}
|
||||
@@ -175,8 +178,12 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
||||
}
|
||||
|
||||
private void setUpJSModule(@NotNull Module module) {
|
||||
JsModuleSetUp.doSetUpModule(module.getProject());
|
||||
updateNotifications();
|
||||
JsModuleSetUp.doSetUpModule(module.getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateNotifications();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setUpKotlinRuntime(@NotNull final Module module) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class JsModuleSetUp {
|
||||
private JsModuleSetUp() {
|
||||
}
|
||||
|
||||
public static void doSetUpModule(@Nullable Project project) {
|
||||
public static void doSetUpModule(@Nullable Project project, @NotNull Runnable continuation) {
|
||||
if (project == null) {
|
||||
notifyFailure("Internal error: Project not found.");
|
||||
return;
|
||||
@@ -67,7 +67,7 @@ public final class JsModuleSetUp {
|
||||
|
||||
createIndicationFile(file);
|
||||
|
||||
refreshRootDir(project);
|
||||
refreshRootDir(project, continuation);
|
||||
}
|
||||
|
||||
private static boolean copyJsLibFiles(@NotNull File rootDir) {
|
||||
@@ -81,8 +81,8 @@ public final class JsModuleSetUp {
|
||||
return doCopyJsLibFiles(Arrays.asList(jsLibJarPath, jsLibJsPath), rootDir);
|
||||
}
|
||||
|
||||
private static void refreshRootDir(@NotNull Project project) {
|
||||
getContentRoot(project).refresh(false, true);
|
||||
private static void refreshRootDir(@NotNull Project project, @NotNull Runnable continuation) {
|
||||
getContentRoot(project).refresh(true, true, continuation);
|
||||
}
|
||||
|
||||
private static void createIndicationFile(@NotNull File file) {
|
||||
|
||||
Reference in New Issue
Block a user