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) {
|
if (JavaPsiFacade.getInstance(myProject).findClass("jet.JetObject", scope) == null) {
|
||||||
return createNotificationPanel(module);
|
return createNotificationPanel(module);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (ProcessCanceledException e) {
|
catch (ProcessCanceledException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
} catch (IndexNotReadyException e) {
|
}
|
||||||
|
catch (IndexNotReadyException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +117,8 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
|
|
||||||
File runtimePath = PathUtil.getDefaultRuntimePath();
|
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||||
if (runtimePath == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +133,8 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
if (jarVfs != null) {
|
if (jarVfs != null) {
|
||||||
jarVfs.refresh(false, false);
|
jarVfs.refresh(false, false);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
Messages.showErrorDialog(myProject, "Error copying jar: " + e.getLocalizedMessage(), "Error Copying File");
|
Messages.showErrorDialog(myProject, "Error copying jar: " + e.getLocalizedMessage(), "Error Copying File");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -175,8 +178,12 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setUpJSModule(@NotNull Module module) {
|
private void setUpJSModule(@NotNull Module module) {
|
||||||
JsModuleSetUp.doSetUpModule(module.getProject());
|
JsModuleSetUp.doSetUpModule(module.getProject(), new Runnable() {
|
||||||
updateNotifications();
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateNotifications();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpKotlinRuntime(@NotNull final Module module) {
|
private void setUpKotlinRuntime(@NotNull final Module module) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class JsModuleSetUp {
|
|||||||
private JsModuleSetUp() {
|
private JsModuleSetUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doSetUpModule(@Nullable Project project) {
|
public static void doSetUpModule(@Nullable Project project, @NotNull Runnable continuation) {
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
notifyFailure("Internal error: Project not found.");
|
notifyFailure("Internal error: Project not found.");
|
||||||
return;
|
return;
|
||||||
@@ -67,7 +67,7 @@ public final class JsModuleSetUp {
|
|||||||
|
|
||||||
createIndicationFile(file);
|
createIndicationFile(file);
|
||||||
|
|
||||||
refreshRootDir(project);
|
refreshRootDir(project, continuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean copyJsLibFiles(@NotNull File rootDir) {
|
private static boolean copyJsLibFiles(@NotNull File rootDir) {
|
||||||
@@ -81,8 +81,8 @@ public final class JsModuleSetUp {
|
|||||||
return doCopyJsLibFiles(Arrays.asList(jsLibJarPath, jsLibJsPath), rootDir);
|
return doCopyJsLibFiles(Arrays.asList(jsLibJarPath, jsLibJsPath), rootDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void refreshRootDir(@NotNull Project project) {
|
private static void refreshRootDir(@NotNull Project project, @NotNull Runnable continuation) {
|
||||||
getContentRoot(project).refresh(false, true);
|
getContentRoot(project).refresh(true, true, continuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createIndicationFile(@NotNull File file) {
|
private static void createIndicationFile(@NotNull File file) {
|
||||||
|
|||||||
Reference in New Issue
Block a user