From f64ae0c21bf3f8eaa35467bc337c1b4222fe1f8a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 22 Feb 2013 13:03:40 +0100 Subject: [PATCH] spacing in py3 annotations (PY-8961) --- .../python/formatter/PythonFormattingModelBuilder.java | 1 + python/testData/formatter/spaceInAnnotations.py | 2 ++ python/testData/formatter/spaceInAnnotations_after.py | 2 ++ python/testSrc/com/jetbrains/python/PyFormatterTest.java | 8 ++++++++ 4 files changed, 13 insertions(+) create mode 100644 python/testData/formatter/spaceInAnnotations.py create mode 100644 python/testData/formatter/spaceInAnnotations_after.py diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index fd215072fe78..63f8003108a3 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -84,6 +84,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .afterInside(GT, ANNOTATION).spaces(1) .betweenInside(MINUS, GT, ANNOTATION).none() .beforeInside(ANNOTATION, FUNCTION_DECLARATION).spaces(1) + .beforeInside(ANNOTATION, NAMED_PARAMETER).none() .between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES) diff --git a/python/testData/formatter/spaceInAnnotations.py b/python/testData/formatter/spaceInAnnotations.py new file mode 100644 index 000000000000..9e8ed998c55e --- /dev/null +++ b/python/testData/formatter/spaceInAnnotations.py @@ -0,0 +1,2 @@ +def foo(x : int): + pass diff --git a/python/testData/formatter/spaceInAnnotations_after.py b/python/testData/formatter/spaceInAnnotations_after.py new file mode 100644 index 000000000000..219a2c76558e --- /dev/null +++ b/python/testData/formatter/spaceInAnnotations_after.py @@ -0,0 +1,2 @@ +def foo(x: int): + pass diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 7da411bbb1ea..6eb7165ef742 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -66,6 +66,10 @@ public class PyFormatterTest extends PyTestCase { } public void testStarExpression() { // PY-1523 + doTestPy3(); + } + + private void doTestPy3() { PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30); try { doTest(); @@ -304,6 +308,10 @@ public class PyFormatterTest extends PyTestCase { } } + public void testSpaceInAnnotations() { // PY-8961 + doTestPy3(); + } + private void doTest() { myFixture.configureByFile("formatter/" + getTestName(true) + ".py"); ApplicationManager.getApplication().runWriteAction(new Runnable() {