diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java index 0dfec58240ee..dc67148d6fe0 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertFormatOperatorToMethodIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -51,7 +50,7 @@ import static com.jetbrains.python.psi.PyUtil.sure; *
* Author: Alexey.Ivanov, dcheryasov */ -public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction { +public class ConvertFormatOperatorToMethodIntention extends PyBaseIntentionAction { private static final Pattern FORMAT_PATTERN = Pattern.compile("%(?:\\((\\w+)\\))?([-#0+ ]*)((?:\\*|\\d+)?(?:\\.(?:\\*|\\d+))?)?[hlL]?([diouxXeEfFgGcrs%])"); @@ -255,7 +254,8 @@ public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement elementAt = file.findElementAt(editor.getCaretModel().getOffset()); final PyBinaryExpression element = PsiTreeUtil.getParentOfType(elementAt, PyBinaryExpression.class, false); if (element == null) return; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertVariadicParamIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertVariadicParamIntention.java index abbe391d51a4..bfb78f2f41d4 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ConvertVariadicParamIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ConvertVariadicParamIntention.java @@ -48,7 +48,7 @@ import java.util.function.BiPredicate; * doSomething(foo) * */ -public class ConvertVariadicParamIntention extends BaseIntentionAction { +public class ConvertVariadicParamIntention extends PyBaseIntentionAction { @Override @NotNull @@ -106,7 +106,7 @@ public class ConvertVariadicParamIntention extends BaseIntentionAction { } @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); final PyFunction function = PsiTreeUtil.getParentOfType(element, PyFunction.class); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java index 8ddd5d27cc3c..d0c365143666 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java @@ -16,7 +16,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.google.common.collect.Sets; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -52,9 +51,7 @@ import static com.jetbrains.python.psi.PyUtil.sure; * Date: Sep 26, 2009 9:12:28 AM * */ -public class ImportFromToImportIntention implements IntentionAction { - private String myText; - +public class ImportFromToImportIntention extends PyBaseIntentionAction { /** * This class exists to extract bunches of info we can't store in our stateless instance. * Instead, we store it per thread. @@ -92,11 +89,6 @@ public class ImportFromToImportIntention implements IntentionAction { } } - @NotNull - public String getText() { - return myText; - } - @Nullable private static PsiElement getElementFromEditor(Editor editor, PsiFile file) { PsiElement element = null; @@ -176,7 +168,7 @@ public class ImportFromToImportIntention implements IntentionAction { info.myModuleName = PyPsiUtils.toPath(info.myModuleReference); } if (info.myModuleReference != null && info.myModuleName != null && info.myFromImportStatement != null) { - myText = info.getText(); + setText(info.getText()); return true; } return false; @@ -194,7 +186,8 @@ public class ImportFromToImportIntention implements IntentionAction { target_node.addChild(sure(generator.createFromText(LanguageLevel.getDefault(), PyReferenceExpression.class, qualifier, new int[]{0,0}).getNode()), target_node.getFirstChildNode()); } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { InfoHolder info = InfoHolder.collect(getElementFromEditor(editor, file)); try { String qualifier; // we don't always qualify with module name @@ -299,9 +292,5 @@ public class ImportFromToImportIntention implements IntentionAction { PyUtil.showBalloon(project, PyBundle.message("QFIX.action.failed"), MessageType.WARNING); } } - - public boolean startInWriteAction() { - return true; - } } diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java index cd21ac66a2dd..ee1932955ed9 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ImportToImportFromIntention.java @@ -16,7 +16,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; @@ -49,7 +48,7 @@ import static com.jetbrains.python.psi.PyUtil.sure; * User: dcheryasov * Date: Sep 22, 2009 1:42:52 AM */ -public class ImportToImportFromIntention implements IntentionAction { +public class ImportToImportFromIntention extends PyBaseIntentionAction { private static class IntentionState { private String myModuleName = null; @@ -221,13 +220,6 @@ public class ImportToImportFromIntention implements IntentionAction { } } - private String myText; - - @NotNull - public String getText() { - return myText; - } - @NotNull public String getFamilyName() { return PyBundle.message("INTN.Family.convert.import.unqualify"); @@ -253,18 +245,15 @@ public class ImportToImportFromIntention implements IntentionAction { final IntentionState state = new IntentionState(editor, file); if (state.isAvailable()) { - myText = state.getText(); + setText(state.getText()); return true; } return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final IntentionState state = new IntentionState(editor, file); state.invoke(); } - - public boolean startInWriteAction() { - return true; - } } diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ImportToggleAliasIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ImportToggleAliasIntention.java index 9c48c58376d5..a0408a96c7c1 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ImportToggleAliasIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ImportToggleAliasIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.lang.ASTNode; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.application.Application; @@ -55,7 +54,7 @@ import static com.jetbrains.python.psi.PyUtil.sure; * User: dcheryasov * Date: Oct 9, 2009 6:07:19 PM */ -public class ImportToggleAliasIntention implements IntentionAction { +public class ImportToggleAliasIntention extends PyBaseIntentionAction { private static class IntentionState { private PyImportElement myImportElement; private PyFromImportStatement myFromImportStatement; @@ -109,14 +108,6 @@ public class ImportToggleAliasIntention implements IntentionAction { } } - private String myLastText; - - - @NotNull - public String getText() { - return myLastText; - } - @NotNull public String getFamilyName() { return PyBundle.message("INTN.Family.toggle.import.alias"); @@ -128,11 +119,12 @@ public class ImportToggleAliasIntention implements IntentionAction { } IntentionState state = IntentionState.fromContext(editor, file); - myLastText = state.getText(); + setText(state.getText()); return state.isAvailable(); } - public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException { // sanity check: isAvailable must have set it. final IntentionState state = IntentionState.fromContext(editor, file); // @@ -258,8 +250,4 @@ public class ImportToggleAliasIntention implements IntentionAction { PyUtil.showBalloon(project, PyBundle.message("QFIX.action.failed"), MessageType.WARNING); } } - - public boolean startInWriteAction() { - return true; - } } diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateTypesIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateTypesIntention.java index 85bc67c37e85..8af91521fd05 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateTypesIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateTypesIntention.java @@ -18,7 +18,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.google.common.base.Function; import com.google.common.collect.Lists; import com.intellij.codeInsight.CodeInsightUtilCore; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.template.*; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -45,12 +44,10 @@ import static com.jetbrains.python.codeInsight.intentions.TypeIntention.resolves /** * @author traff */ -public class PyAnnotateTypesIntention implements IntentionAction { - private String myText = PyBundle.message("INTN.annotate.types"); - - @NotNull - public String getText() { - return myText; +public class PyAnnotateTypesIntention extends PyBaseIntentionAction { + + public PyAnnotateTypesIntention() { + setText(PyBundle.message("INTN.annotate.types")); } @NotNull @@ -78,7 +75,8 @@ public class PyAnnotateTypesIntention implements IntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); final PyCallable callable = getCallable(elementAt); @@ -229,13 +227,7 @@ public class PyAnnotateTypesIntention implements IntentionAction { } } - @Override - public boolean startInWriteAction() { - return true; - } - - protected void updateText() { - myText = PyBundle.message("INTN.annotate.types"); + setText(PyBundle.message("INTN.annotate.types")); } } \ No newline at end of file diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseConvertCollectionLiteralIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseConvertCollectionLiteralIntention.java index db243d24b447..89fe34c365de 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseConvertCollectionLiteralIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseConvertCollectionLiteralIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; @@ -36,7 +35,7 @@ import static com.jetbrains.python.psi.PyUtil.as; /** * @author Mikhail Golubev */ -public abstract class PyBaseConvertCollectionLiteralIntention extends BaseIntentionAction { +public abstract class PyBaseConvertCollectionLiteralIntention extends PyBaseIntentionAction { private final Class myTargetCollectionClass; private final String myTargetCollectionName; private final String myRightBrace; @@ -87,7 +86,7 @@ public abstract class PyBaseConvertCollectionLiteralIntention extends BaseIntent } @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PySequenceExpression literal = findCollectionLiteralUnderCaret(editor, file); assert literal != null; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseIntentionAction.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseIntentionAction.java new file mode 100644 index 000000000000..db8a5729f5cc --- /dev/null +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyBaseIntentionAction.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.jetbrains.python.codeInsight.intentions; + + +import com.intellij.codeInsight.FileModificationService; +import com.intellij.codeInsight.intention.impl.BaseIntentionAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +public abstract class PyBaseIntentionAction extends BaseIntentionAction { + + @Override + public final void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; + doInvoke(project, editor, file); + } + + public abstract void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException; +} diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertLambdaToFunctionIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertLambdaToFunctionIntention.java index 5c768169f5a5..d4e56ce16ecd 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertLambdaToFunctionIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertLambdaToFunctionIntention.java @@ -18,7 +18,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.intellij.codeInsight.CodeInsightUtilCore; import com.intellij.codeInsight.controlflow.ControlFlow; import com.intellij.codeInsight.controlflow.Instruction; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.template.*; import com.intellij.openapi.editor.Editor; @@ -42,7 +41,7 @@ import java.util.List; * User: catherine * Intention to convert lambda to function */ -public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction { +public class PyConvertLambdaToFunctionIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { @@ -72,7 +71,7 @@ public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyLambdaExpression.class); if (lambdaExpression != null) { String name = "function"; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java index 08566e3c8eff..ca9d78869fb1 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -34,7 +33,7 @@ import java.util.List; /** * User: ktisha */ -public class PyConvertMethodToPropertyIntention extends BaseIntentionAction { +public class PyConvertMethodToPropertyIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.convert.method.to.property"); @@ -77,7 +76,7 @@ public class PyConvertMethodToPropertyIntention extends BaseIntentionAction { return available[0]; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement element = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyFunction problemFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class); if (problemFunction == null) return; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertStaticMethodToFunctionIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertStaticMethodToFunctionIntention.java index 8d19a7462e5c..fcea35267dad 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertStaticMethodToFunctionIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertStaticMethodToFunctionIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -34,7 +33,7 @@ import java.util.List; /** * User: ktisha */ -public class PyConvertStaticMethodToFunctionIntention extends BaseIntentionAction { +public class PyConvertStaticMethodToFunctionIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.convert.static.method.to.function"); @@ -62,7 +61,7 @@ public class PyConvertStaticMethodToFunctionIntention extends BaseIntentionActio return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement element = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyFunction problemFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class); if (problemFunction == null) return; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java index 98b9c7c8b1cd..307a46b74f3b 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertTripleQuotedStringIntention.java @@ -15,8 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; -import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; @@ -24,7 +22,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.jetbrains.python.PyBundle; @@ -47,7 +44,7 @@ import java.util.List; * "but \"this\" includes far too much" "\n" * "whitespace at the start") */ -public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction { +public class PyConvertTripleQuotedStringIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { @@ -81,7 +78,7 @@ public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) throws IncorrectOperationException { final PyStringLiteralExpression pyString = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyStringLiteralExpression.class); final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyDemorganIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyDemorganIntention.java index 64e9b273b133..c1dfe278f1e0 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyDemorganIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyDemorganIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -31,7 +30,7 @@ import org.jetbrains.annotations.Nullable; /** * @author yole */ -public class PyDemorganIntention extends BaseIntentionAction { +public class PyDemorganIntention extends PyBaseIntentionAction { @NotNull @Override public String getText() { @@ -62,7 +61,7 @@ public class PyDemorganIntention extends BaseIntentionAction { } @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PyBinaryExpression expression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyBinaryExpression.class); assert expression != null; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java index 15a1908134fd..0947dfce9dd6 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; @@ -36,7 +35,7 @@ import org.jetbrains.annotations.NotNull; * dict(foo) -> no transformation * dict(**foo) -> no transformation */ -public class PyDictConstructorToLiteralFormIntention extends BaseIntentionAction { +public class PyDictConstructorToLiteralFormIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.convert.dict.constructor.to.dict.literal"); @@ -69,7 +68,7 @@ public class PyDictConstructorToLiteralFormIntention extends BaseIntentionAction return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyCallExpression expression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyCallExpression.class); PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictLiteralFormToConstructorIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictLiteralFormToConstructorIntention.java index 3dd14160fa8c..bdd9cf41664e 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictLiteralFormToConstructorIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictLiteralFormToConstructorIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; @@ -36,7 +35,7 @@ import org.jetbrains.annotations.NotNull; * {'a': 3, 'b': 5} -> dict(a=3, b=5) * {a: 3, b: 5} -> no transformation */ -public class PyDictLiteralFormToConstructorIntention extends BaseIntentionAction { +public class PyDictLiteralFormToConstructorIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.convert.dict.literal.to.dict.constructor"); @@ -73,7 +72,7 @@ public class PyDictLiteralFormToConstructorIntention extends BaseIntentionAction return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyDictLiteralExpression dictExpression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyDictLiteralExpression.class); PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyFlipComparisonIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyFlipComparisonIntention.java index 027e26bb5742..7bff130afb66 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyFlipComparisonIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyFlipComparisonIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -39,7 +38,7 @@ import java.util.Map; * Date: 26.03.2010 * Time: 22:01:27 */ -public class PyFlipComparisonIntention extends BaseIntentionAction { +public class PyFlipComparisonIntention extends PyBaseIntentionAction { private static final Map FLIPPED_OPERATORS = new HashMap<>(7); static { @@ -82,7 +81,7 @@ public class PyFlipComparisonIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); PyBinaryExpression binaryExpression = PsiTreeUtil.getParentOfType(element, PyBinaryExpression.class, false); while (binaryExpression != null) { diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyGenerateDocstringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyGenerateDocstringIntention.java index 18f2241e648b..b999c1839a9d 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyGenerateDocstringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyGenerateDocstringIntention.java @@ -15,8 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -36,7 +34,7 @@ import org.jetbrains.annotations.Nullable; * Intention to add documentation string for function * (with checked format) */ -public class PyGenerateDocstringIntention extends BaseIntentionAction { +public class PyGenerateDocstringIntention extends PyBaseIntentionAction { private String myText; @NotNull @@ -81,11 +79,7 @@ public class PyGenerateDocstringIntention extends BaseIntentionAction { } } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { - if (!FileModificationService.getInstance().preparePsiElementForWrite(file)) { - return; - } - + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyFunction function = PsiTreeUtil.getParentOfType(elementAt, PyFunction.class); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyJoinIfIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyJoinIfIntention.java index 2fc7cb11f501..2211307259a8 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyJoinIfIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyJoinIfIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiComment; @@ -42,7 +41,7 @@ import java.util.List; * if a and b: * #stuff here */ -public class PyJoinIfIntention extends BaseIntentionAction { +public class PyJoinIfIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.join.if"); @@ -79,7 +78,7 @@ public class PyJoinIfIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyIfStatement expression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyIfStatement.class); PyIfStatement ifStatement = getIfStatement(expression); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyNegateComparisonIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyNegateComparisonIntention.java index 42cef0675741..ad5368feb2ae 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyNegateComparisonIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyNegateComparisonIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -36,7 +35,7 @@ import java.util.Map; * Date: 12.03.2010 * Time: 17:58:56 */ -public class PyNegateComparisonIntention extends BaseIntentionAction { +public class PyNegateComparisonIntention extends PyBaseIntentionAction { private static final Map comparisonStrings = new HashMap<>(7); private static final Map invertedComparasions = new HashMap<>(7); @@ -82,7 +81,7 @@ public class PyNegateComparisonIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); PyBinaryExpression binaryExpression = PsiTreeUtil.getParentOfType(element, PyBinaryExpression.class, false); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java index b1d4c75d3435..ed48206ea7d4 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; @@ -33,7 +32,7 @@ import org.jetbrains.annotations.NotNull; * User: catherine * Intention to convert between single-quoted and double-quoted strings */ -public class PyQuotedStringIntention extends BaseIntentionAction { +public class PyQuotedStringIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { @@ -73,7 +72,7 @@ public class PyQuotedStringIntention extends BaseIntentionAction { return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyStringLiteralExpression string = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyStringLiteralExpression.class); PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); if (string != null) { diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PySplitIfIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PySplitIfIntention.java index 4efc1ab0625b..dd826fd46f59 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PySplitIfIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PySplitIfIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -35,7 +34,7 @@ import org.jetbrains.annotations.NotNull; * Date: 10.03.2010 * Time: 18:52:52 */ -public class PySplitIfIntention extends BaseIntentionAction { +public class PySplitIfIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.split.if"); @@ -82,7 +81,7 @@ public class PySplitIfIntention extends BaseIntentionAction { return true; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement elementAtOffset = file.findElementAt(editor.getCaretModel().getOffset()); // PY-745 final IElementType elementType = elementAtOffset.getNode().getElementType(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java index 128301f3ad40..a9abd773d518 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; @@ -42,7 +41,7 @@ import java.util.List; /** * @author Alexey.Ivanov */ -public class PyStringConcatenationToFormatIntention extends BaseIntentionAction { +public class PyStringConcatenationToFormatIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { @@ -123,7 +122,7 @@ public class PyStringConcatenationToFormatIntention extends BaseIntentionAction return res; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement element = PsiTreeUtil.getTopmostParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyBinaryExpression.class); if (element == null) return; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyTransformConditionalExpressionIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyTransformConditionalExpressionIntention.java index 3180dd1daad5..0149a542ddeb 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyTransformConditionalExpressionIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyTransformConditionalExpressionIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; @@ -39,7 +38,7 @@ import org.jetbrains.annotations.NotNull; * else: * x = b */ -public class PyTransformConditionalExpressionIntention extends BaseIntentionAction { +public class PyTransformConditionalExpressionIntention extends PyBaseIntentionAction { @NotNull public String getFamilyName() { return PyBundle.message("INTN.transform.into.if.else.statement"); @@ -63,7 +62,7 @@ public class PyTransformConditionalExpressionIntention extends BaseIntentionActi return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PyAssignmentStatement assignmentStatement = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyAssignmentStatement.class); assert assignmentStatement != null; diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyYieldFromIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyYieldFromIntention.java index 09e46b657220..e3746cc93b5a 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyYieldFromIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyYieldFromIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.impl.BaseIntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -30,7 +29,7 @@ import org.jetbrains.annotations.Nullable; /** * @author vlan */ -public class PyYieldFromIntention extends BaseIntentionAction { +public class PyYieldFromIntention extends PyBaseIntentionAction { @NotNull @Override public String getFamilyName() { @@ -62,7 +61,7 @@ public class PyYieldFromIntention extends BaseIntentionAction { } @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PyForStatement forLoop = findForStatementAtCaret(editor, file); if (forLoop != null) { final PyExpression source = forLoop.getForPart().getSource(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ReplaceListComprehensionWithForIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ReplaceListComprehensionWithForIntention.java index 60c5c21bdadd..12240e3f2997 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ReplaceListComprehensionWithForIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ReplaceListComprehensionWithForIntention.java @@ -15,7 +15,6 @@ */ package com.jetbrains.python.codeInsight.intentions; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -32,7 +31,7 @@ import java.util.List; /** * User: catherine */ -public class ReplaceListComprehensionWithForIntention implements IntentionAction { +public class ReplaceListComprehensionWithForIntention extends PyBaseIntentionAction { @NotNull public String getText() { return PyBundle.message("INTN.replace.list.comprehensions.with.for"); @@ -61,7 +60,8 @@ public class ReplaceListComprehensionWithForIntention implements IntentionAction return false; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PyListCompExpression expression = PsiTreeUtil.getTopmostParentOfType( file.findElementAt(editor.getCaretModel().getOffset()), PyListCompExpression.class); if (expression == null) { @@ -120,8 +120,4 @@ public class ReplaceListComprehensionWithForIntention implements IntentionAction return elementGenerator.createFromText(LanguageLevel.forElement(expression), PyForStatement.class, stringBuilder.toString()); } - - public boolean startInWriteAction() { - return true; - } } \ No newline at end of file diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java index f270def805c3..1cc96e65a931 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java @@ -53,7 +53,8 @@ public class SpecifyTypeInDocstringIntention extends TypeIntention { return PyBundle.message("INTN.specify.type"); } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); final PyExpression problemElement = getProblemElement(elementAt); final PsiReference reference = problemElement == null ? null : problemElement.getReference(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java index a2b2735c5aa1..df7302343635 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java @@ -64,7 +64,8 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention { return super.isAvailable(project, editor, file); } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); final PyExpression problemElement = getProblemElement(elementAt); final PsiReference reference = problemElement == null ? null : problemElement.getReference(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/TypeAssertionIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/TypeAssertionIntention.java index 9b274563dfd0..d6fea80a8670 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/TypeAssertionIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/TypeAssertionIntention.java @@ -16,7 +16,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.intellij.codeInsight.CodeInsightUtilCore; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.template.*; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -39,10 +38,7 @@ import org.jetbrains.annotations.NotNull; * * Helps to specify type by assertion */ -public class TypeAssertionIntention implements IntentionAction { - - public TypeAssertionIntention() { - } +public class TypeAssertionIntention extends PyBaseIntentionAction { @NotNull public String getText() { @@ -79,7 +75,8 @@ public class TypeAssertionIntention implements IntentionAction { return type == null; } - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + @Override + public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyExpression problemElement = PsiTreeUtil.getParentOfType(elementAt, PyReferenceExpression.class); if (problemElement != null) { @@ -142,8 +139,4 @@ public class TypeAssertionIntention implements IntentionAction { TemplateManager.getInstance(project).startTemplate(editor, template); } } - - public boolean startInWriteAction() { - return true; - } } \ No newline at end of file diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java index 355b2e0f3267..8035cfc02ec0 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java @@ -16,7 +16,6 @@ package com.jetbrains.python.codeInsight.intentions; import com.google.common.base.Function; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -39,7 +38,7 @@ import static com.jetbrains.python.psi.PyUtil.as; * * Common part for type specifying intentions */ -public abstract class TypeIntention implements IntentionAction { +public abstract class TypeIntention extends PyBaseIntentionAction { public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile) || file instanceof PyDocstringFile) return false; @@ -196,8 +195,4 @@ public abstract class TypeIntention implements IntentionAction { protected static PyResolveContext getResolveContext(@NotNull PsiElement origin) { return PyResolveContext.defaultContext().withTypeEvalContext(TypeEvalContext.codeAnalysis(origin.getProject(), origin.getContainingFile())); } - - public boolean startInWriteAction() { - return true; - } } \ No newline at end of file