java & platform: write action is unnecessary in some quick fixes
authorpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 08:11:47 +0000 (09:11 +0100)
committerpeter <peter@jetbrains.com>
Wed, 16 Nov 2016 08:20:36 +0000 (09:20 +0100)
java/java-analysis-impl/src/com/intellij/codeInspection/unnecessaryModuleDependency/UnnecessaryModuleDependencyInspection.java
java/java-analysis-impl/src/com/intellij/codeInspection/unusedLibraries/UnusedLibrariesInspection.java
java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
java/java-impl/src/com/intellij/codeInspection/dependencyViolation/DependencyInspection.java
platform/lang-impl/src/com/intellij/codeInspection/ProblematicWhitespaceInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/packaging/EmptyDirectoryInspection.java
plugins/java-i18n/src/com/intellij/codeInspection/SuspiciousLocalesLanguagesInspection.java
plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java
spellchecker/src/com/intellij/spellchecker/quickfixes/AcceptWordAsCorrect.java

index f2198709ad8e9a7e952ede6b7f945ade47460c57..e2e7f3f38db8f4f42a4dc83e4d12dab4f365c406 100644 (file)
@@ -162,6 +162,11 @@ public class UnnecessaryModuleDependencyInspection extends GlobalInspectionTool
       return "Remove dependency";
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     public void applyFix(@NotNull Project project, @NotNull CommonProblemDescriptor descriptor) {
       final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
index 6147a0d7ea5b9a22e1cab06335936bfaf07092d3..2bd489c5ef30fec626083a247eb11ffacd3a926e 100644 (file)
@@ -39,7 +39,6 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiUtilCore;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -131,6 +130,11 @@ public class UnusedLibrariesInspection extends GlobalInspectionTool {
       myFiles = files;
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     @NotNull
     public String getFamilyName() {
index ea3c99ac01612580bbd65662df91408e2af8dd12..343732352779b9e5674418d9d9757898300ee8a7 100644 (file)
@@ -90,6 +90,11 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
       return InspectionsBundle.message("default.file.template.edit.template");
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
       final FileTemplateConfigurable configurable = new FileTemplateConfigurable(project);
index d317b5ee7d22fe56ffb69ef5cd87e4f624c66170..93485a5edc209b12bbc012cdaf5c239122077e60 100644 (file)
@@ -79,6 +79,11 @@ public class DependencyInspection extends DependencyInspectionBase {
       return InspectionsBundle.message("edit.dependency.rules.family");
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
       ShowSettingsUtil.getInstance().editConfigurable(project, new DependencyConfigurable(project));
index 487b1cbbfb68b2fb860932c24c68f26a9ecfee2e..4d77cb07b1b28fb4e9804e38deab3a6a7683e10c 100644 (file)
@@ -45,6 +45,11 @@ public class ProblematicWhitespaceInspection extends LocalInspectionTool {
       return InspectionsBundle.message("problematic.whitespace.show.whitespaces.quickfix");
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
       final FileEditorManager editorManager = FileEditorManager.getInstance(project);
index 4cdf27d7894c652de83e3bbf1cdcf9722ef181a7..53e77adec6b2c3146a059e298e4b0960beb6690e 100644 (file)
@@ -126,6 +126,11 @@ public class EmptyDirectoryInspection extends BaseGlobalInspection {
       this.name = name;
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @NotNull
     @Override
     public String getName() {
index 85d8faf5a5bef6dd896f032bcf49f098edf58a59..d570783a1bb8ebd64a9909717b60dc2c7ab001c0 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.lang.properties.psi.PropertiesFile;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.InputValidator;
 import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.util.text.StringUtil;
@@ -33,7 +32,6 @@ import com.intellij.ui.AnActionButton;
 import com.intellij.ui.AnActionButtonRunnable;
 import com.intellij.ui.ToolbarDecorator;
 import com.intellij.ui.components.JBList;
-import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashSet;
 import org.jdom.Element;
@@ -146,6 +144,11 @@ public class SuspiciousLocalesLanguagesInspection extends BaseLocalInspectionToo
       return PropertiesBundle.message("dissociate.resource.bundle.quick.fix.name");
     }
 
+    @Override
+    public boolean startInWriteAction() {
+      return false;
+    }
+
     @Override
     public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
       DissociateResourceBundleAction.dissociate(Collections.singleton(myResourceBundle), project);
index 01e66540a132e6f65109d62cd1a35fb2a88bba7f..a70e455f0da1b3622ac0c8329662a9875bed87bf 100644 (file)
@@ -28,7 +28,6 @@ import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.ide.util.TreeClassChooser;
 import com.intellij.ide.util.TreeClassChooserFactory;
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.extensions.ExtensionPoint;
 import com.intellij.openapi.extensions.Extensions;
@@ -437,16 +436,18 @@ public class I18nInspection extends BaseLocalInspectionTool {
         return IntroduceConstantHandler.REFACTORING_NAME;
       }
 
+      @Override
+      public boolean startInWriteAction() {
+        return false;
+      }
+
       @Override
       public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
-        //do it later because it is invoked from write action
-        ApplicationManager.getApplication().invokeLater(() -> {
-          PsiElement element = descriptor.getPsiElement();
-          if (!(element instanceof PsiExpression)) return;
-
-          PsiExpression[] expressions = {(PsiExpression)element};
-          new IntroduceConstantHandler().invoke(project, expressions);
-        }, project.getDisposed());
+        PsiElement element = descriptor.getPsiElement();
+        if (!(element instanceof PsiExpression)) return;
+
+        PsiExpression[] expressions = {(PsiExpression)element};
+        new IntroduceConstantHandler().invoke(project, expressions);
       }
     };
   }
index 25041dc3b3516bfc4d34291be1a9d0e5c3d6a827..b25e4901bb319d58dd357a73c8adf077a07adb0c 100644 (file)
@@ -52,6 +52,11 @@ public class AcceptWordAsCorrect implements SpellCheckerQuickFix {
     return Anchor.LAST;
   }
 
+  @Override
+  public boolean startInWriteAction() {
+    return false;
+  }
+
   public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
     SpellCheckerManager spellCheckerManager = SpellCheckerManager.getInstance(project);
     if (myWord != null) {