From c4928a6bfc23df6a0921f63e89f0dbb755536cd1 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 22 Mar 2012 15:59:49 +0400 Subject: [PATCH] fixed PY-5527 Move statement: unnecessary pass statement on moving one-line comment out of indented block --- .../editorActions/moveUpDown/StatementMover.java | 2 +- python/testData/mover/commentOut.py | 5 +++++ python/testData/mover/commentOut_afterDown.py | 5 +++++ python/testData/mover/commentOut_afterUp.py | 5 +++++ .../testSrc/com/jetbrains/python/PyStatementMoverTest.java | 6 +++++- 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 python/testData/mover/commentOut.py create mode 100644 python/testData/mover/commentOut_afterDown.py create mode 100644 python/testData/mover/commentOut_afterUp.py diff --git a/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java b/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java index 2d5f5715b2ab..513d5d06b781 100644 --- a/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java +++ b/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java @@ -129,7 +129,7 @@ public class StatementMover extends LineMover { PyElement statementPart = getStatementParts(info, editor, file, down).first; if (statementPart instanceof PyStatementPart) { PyStatementList statementList = ((PyStatementPart)statementPart).getStatementList(); - if (statementList != null && statementList.getStatements().length == 1) { + if (statementList != null && statementList.getStatements().length == 1 && !(myStatementToMove instanceof PsiComment)) { if (theSameLevel) { myStatementListToAddPassAfter = statementList; } diff --git a/python/testData/mover/commentOut.py b/python/testData/mover/commentOut.py new file mode 100644 index 000000000000..5131d71cf8db --- /dev/null +++ b/python/testData/mover/commentOut.py @@ -0,0 +1,5 @@ +if True: + a = 1 +else: + #comment + a = 2 \ No newline at end of file diff --git a/python/testData/mover/commentOut_afterDown.py b/python/testData/mover/commentOut_afterDown.py new file mode 100644 index 000000000000..279856eca063 --- /dev/null +++ b/python/testData/mover/commentOut_afterDown.py @@ -0,0 +1,5 @@ +if True: + a = 1 +else: + a = 2 + #comment diff --git a/python/testData/mover/commentOut_afterUp.py b/python/testData/mover/commentOut_afterUp.py new file mode 100644 index 000000000000..c0dc51720469 --- /dev/null +++ b/python/testData/mover/commentOut_afterUp.py @@ -0,0 +1,5 @@ +if True: + a = 1 + #comment +else: + a = 2 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java b/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java index 39a524e74cad..b345b346ef82 100644 --- a/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java +++ b/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java @@ -41,11 +41,15 @@ public class PyStatementMoverTest extends PyTestCase { doTest(); } + public void testCommentOut() { //PY-5527 + doTest(); + } + public void testMoveDownOut() { doTest(); } - public void testComment() { + public void testComment() { //PY-5270 doTest(); }