From c0c279d60ab30f1cbb96164b359eb4decf8c3b9b Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 18 Dec 2017 12:24:41 +0100 Subject: [PATCH] IDEA-183291 Adding a library to classpath via quick command requires clearing of read-only status of file --- .../daemon/impl/quickfix/AddExtLibraryDependencyFix.java | 4 ---- .../daemon/impl/quickfix/AddLibraryDependencyFix.java | 4 +++- .../daemon/impl/quickfix/AddModuleDependencyFix.java | 4 ---- .../codeInsight/daemon/impl/quickfix/OrderEntryFix.java | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExtLibraryDependencyFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExtLibraryDependencyFix.java index aa01ebab3237..22383af00782 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExtLibraryDependencyFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExtLibraryDependencyFix.java @@ -87,8 +87,4 @@ class AddExtLibraryDependencyFix extends OrderEntryFix { }.execute()); } - @Override - public boolean startInWriteAction() { - return false; - } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddLibraryDependencyFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddLibraryDependencyFix.java index 9f0c90fa1c8b..cf3110bd60ad 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddLibraryDependencyFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddLibraryDependencyFix.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.QuickFixBundle; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -72,7 +73,8 @@ class AddLibraryDependencyFix extends OrderEntryFix { @Override public void invoke(@NotNull Project project, @Nullable Editor editor, PsiFile file) { - JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibrary, myScope, myExported); + WriteAction.run( + () -> JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibrary, myScope, myExported)); if (myQualifiedClassName != null && editor != null) { importClass(myCurrentModule, editor, restoreReference(), myQualifiedClassName); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java index e98e8d9b7ad8..abad48f5b8ec 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddModuleDependencyFix.java @@ -156,8 +156,4 @@ class AddModuleDependencyFix extends OrderEntryFix { return Messages.showOkCancelDialog(project, message, title, Messages.getWarningIcon()) == Messages.OK; } - @Override - public boolean startInWriteAction() { - return false; - } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java index 9a56f3a69c10..9a53b786adf1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java @@ -94,7 +94,7 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix { @Override public boolean startInWriteAction() { - return true; + return false; } @Override