diff options
Diffstat (limited to 'python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java')
-rw-r--r-- | python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java b/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java index a055375bc040..582e034c5603 100644 --- a/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java +++ b/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/PyParenthesizedFixer.java @@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement; import com.intellij.util.IncorrectOperationException; import com.jetbrains.python.codeInsight.editorActions.smartEnter.PySmartEnterProcessor; import com.jetbrains.python.psi.PyParenthesizedExpression; +import org.jetbrains.annotations.NotNull; /** * Created by IntelliJ IDEA. @@ -27,13 +28,17 @@ import com.jetbrains.python.psi.PyParenthesizedExpression; * Date: 15.04.2010 * Time: 17:42:08 */ -public class PyParenthesizedFixer implements PyFixer { - public void apply(final Editor editor, final PySmartEnterProcessor processor, final PsiElement psiElement) throws IncorrectOperationException { - if (psiElement instanceof PyParenthesizedExpression) { - final PsiElement lastChild = psiElement.getLastChild(); - if (lastChild != null && !")".equals(lastChild.getText())) { - editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), ")"); - } +public class PyParenthesizedFixer extends PyFixer<PyParenthesizedExpression> { + public PyParenthesizedFixer() { + super(PyParenthesizedExpression.class); + } + + @Override + public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyParenthesizedExpression expression) + throws IncorrectOperationException { + final PsiElement lastChild = expression.getLastChild(); + if (lastChild != null && !")".equals(lastChild.getText())) { + editor.getDocument().insertString(expression.getTextRange().getEndOffset(), ")"); } } } |