mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
smart enter shouldn't insert parentheses into decorator calls (PY-3209)
This commit is contained in:
+3
-5
@@ -8,19 +8,17 @@ import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.codeInsight.editorActions.smartEnter.PySmartEnterProcessor;
|
||||
import com.jetbrains.python.psi.PyArgumentList;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyDecorator;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* Author: Alexey.Ivanov
|
||||
* Date: 16.04.2010
|
||||
* Time: 19:15:36
|
||||
* @author Alexey.Ivanov
|
||||
*/
|
||||
public class PyArgumentListFixer implements PyFixer {
|
||||
public void apply(Editor editor, PySmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
|
||||
if (psiElement instanceof PyArgumentList) {
|
||||
final PsiElement rBrace = PyUtil.getChildByFilter(psiElement, PyTokenTypes.CLOSE_BRACES, 0);
|
||||
if (psiElement.getContext() instanceof PyClass) {
|
||||
if (psiElement.getParent() instanceof PyClass || psiElement.getParent() instanceof PyDecorator) {
|
||||
final PsiElement lBrace = PyUtil.getChildByFilter(psiElement, PyTokenTypes.OPEN_BRACES, 0);
|
||||
if (lBrace != null && rBrace == null) {
|
||||
final Document document = editor.getDocument();
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@classmethod
|
||||
def func(arg<caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
@classmethod
|
||||
def func(arg):
|
||||
<caret>
|
||||
@@ -11,17 +11,14 @@ import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* Author: Alexey.Ivanov
|
||||
* Date: 22.04.2010
|
||||
* Time: 17:00:16
|
||||
* @author Alexey.Ivanov
|
||||
*/
|
||||
public class PySmartEnterTest extends PyLightFixtureTestCase {
|
||||
protected static List<SmartEnterProcessor> getSmartProcessors(Language language) {
|
||||
return SmartEnterProcessors.INSTANCE.forKey(language);
|
||||
}
|
||||
|
||||
public void doTest() throws Exception {
|
||||
public void doTest() {
|
||||
myFixture.configureByFile("codeInsight/smartEnter/" + getTestName(true) + ".py");
|
||||
final List<SmartEnterProcessor> processors = getSmartProcessors(PythonLanguage.getInstance());
|
||||
new WriteCommandAction(myFixture.getProject()) {
|
||||
@@ -36,67 +33,71 @@ public class PySmartEnterTest extends PyLightFixtureTestCase {
|
||||
myFixture.checkResultByFile("codeInsight/smartEnter/" + getTestName(true) + "_after.py", true);
|
||||
}
|
||||
|
||||
public void testIf() throws Exception {
|
||||
public void testIf() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWhile() throws Exception {
|
||||
public void testWhile() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testElif() throws Exception {
|
||||
public void testElif() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testForFirst() throws Exception {
|
||||
public void testForFirst() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testForSecond() throws Exception {
|
||||
public void testForSecond() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTry() throws Exception {
|
||||
public void testTry() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testString() throws Exception {
|
||||
public void testString() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDocstring() throws Exception {
|
||||
public void testDocstring() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDict() throws Exception {
|
||||
public void testDict() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParenthesized() throws Exception {
|
||||
public void testParenthesized() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArgumentsFirst() throws Exception {
|
||||
public void testArgumentsFirst() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArgumentsSecond() throws Exception {
|
||||
public void testArgumentsSecond() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFunc() throws Exception {
|
||||
public void testFunc() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testClass() throws Exception {
|
||||
public void testClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testComment() throws Exception {
|
||||
public void testComment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy891() throws Exception {
|
||||
public void testPy891() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy3209() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user