mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-75547 Groovy move statement moves method if a line comment is selected together with statements
This commit is contained in:
@@ -832,6 +832,13 @@ public class PsiTreeUtil {
|
||||
return prevLeaf;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement nextVisibleLeaf(@NotNull final PsiElement element) {
|
||||
PsiElement nextLeaf = nextLeaf(element, true);
|
||||
while (nextLeaf != null && StringUtil.isEmptyOrSpaces(nextLeaf.getText())) nextLeaf = nextLeaf(nextLeaf, true);
|
||||
return nextLeaf;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement nextLeaf(final PsiElement element, final boolean skipEmptyElements) {
|
||||
PsiElement nextLeaf = nextLeaf(element);
|
||||
|
||||
+3
@@ -113,6 +113,9 @@ public class GroovyStatementMover extends StatementUpDownMover {
|
||||
element = owner;
|
||||
}
|
||||
}
|
||||
if (element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.nextVisibleLeaf(element);
|
||||
}
|
||||
|
||||
return (GroovyPsiElement)PsiTreeUtil.findFirstParent(element, new Condition<PsiElement>() {
|
||||
@Override
|
||||
|
||||
+1
@@ -99,6 +99,7 @@ public class GroovyMoveStatementTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testStatementToEmptySpace3() throws Throwable { bothTest(); }
|
||||
|
||||
public void testStatementsWithSemicolons() throws Throwable { bothTest(); }
|
||||
public void testStatementsWithComments() throws Throwable { bothTest(); }
|
||||
|
||||
private void bothTest() {
|
||||
final List<String> data = TestUtils.readInput(getTestDataPath() + getTestName(true) + ".test");
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
def bar() {
|
||||
|
||||
}
|
||||
|
||||
private boolean function() {
|
||||
println 'hi'
|
||||
<selection> //foo
|
||||
println 'hi3'<caret></selection>
|
||||
println 'hi2'
|
||||
}
|
||||
-----
|
||||
def bar() {
|
||||
|
||||
}
|
||||
|
||||
private boolean function() {
|
||||
<selection> //foo
|
||||
println 'hi3'<caret></selection>
|
||||
println 'hi'
|
||||
println 'hi2'
|
||||
}
|
||||
Reference in New Issue
Block a user