python: write action is unnecessary in some quick fixes

This commit is contained in:
peter
2016-11-16 09:20:36 +01:00
parent 589f3efc5a
commit 53210fe263
6 changed files with 46 additions and 5 deletions
@@ -48,6 +48,11 @@ public class AddIgnoredRoleFix implements LocalQuickFix, LowPriorityAction {
return "Ignore undefined role";
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
if (!myInspection.ignoredRoles.contains(myRole)) {
@@ -19,7 +19,6 @@ import com.intellij.codeInspection.LocalInspectionToolSession;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.options.ShowSettingsUtil;
@@ -87,12 +86,14 @@ public class PyInterpreterInspection extends PyInspection {
return "Configure Python Interpreter";
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
ApplicationManager.getApplication().invokeLater(() -> {
// outside of read action
ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter");
});
ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter");
}
}
}
@@ -272,6 +272,11 @@ public class PyPackageRequirementsInspection extends PyInspection {
return myName;
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
boolean installManagement = false;
@@ -356,6 +361,11 @@ public class PyPackageRequirementsInspection extends PyInspection {
return "Install and import package " + myPackageName;
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
final PyPackageManagerUI ui = new PyPackageManagerUI(project, mySdk, new UIListener(myModule) {
@@ -411,6 +421,11 @@ public class PyPackageRequirementsInspection extends PyInspection {
return String.format("Ignore requirement%s", plural ? "s" : "");
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
@@ -444,6 +459,11 @@ public class PyPackageRequirementsInspection extends PyInspection {
myLanguageLevel = languageLevel;
}
@Override
public boolean startInWriteAction() {
return false;
}
@NotNull
@Override
public String getFamilyName() {
@@ -128,6 +128,11 @@ public class PyShadowingBuiltinsInspection extends PyInspection {
return getFamilyName() + " \"" + myName + "\"";
}
@Override
public boolean startInWriteAction() {
return false;
}
@NotNull
@Override
public String getFamilyName() {
@@ -56,6 +56,11 @@ public class AddIgnoredIdentifierQuickFix implements LocalQuickFix, LowPriorityA
return "Ignore unresolved reference";
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement context = descriptor.getPsiElement();
@@ -110,6 +110,11 @@ public class GenerateBinaryStubsFix implements LocalQuickFix {
return "Generate binary stubs";
}
@Override
public boolean startInWriteAction() {
return false;
}
@Override
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
final PsiFile file = descriptor.getPsiElement().getContainingFile();