mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] move up/down: fix moving fields with groovy docs (IDEA-159925)
This commit is contained in:
+15
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -36,7 +35,9 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseLabel;
|
||||
@@ -245,6 +246,18 @@ public class GroovyStatementMover extends StatementUpDownMover {
|
||||
return new LineRange(comment, pivot);
|
||||
}
|
||||
}
|
||||
else if (pivot instanceof GrVariableDeclaration && pivot.getParent() instanceof GrTypeDefinitionBody) {
|
||||
GrVariable[] variables = ((GrVariableDeclaration)pivot).getVariables();
|
||||
if (variables.length > 0) {
|
||||
GrVariable variable = variables[0];
|
||||
if (variable instanceof GrField) {
|
||||
GrDocComment comment = ((GrField)variable).getDocComment();
|
||||
if (comment != null) {
|
||||
return new LineRange(comment, pivot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new LineRange(pivot);
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2000-2008 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -65,6 +66,7 @@ public class GroovyMoveStatementTest extends GroovyEditorActionTestBase {
|
||||
public void testMoveGroovydocWithMethod() throws Throwable { bothTest(); }
|
||||
public void testLeaveGroovydocWithMethod() throws Throwable { bothTest(); }
|
||||
public void testMoveMethodWithGroovydoc() throws Throwable { bothTest(); }
|
||||
public void testMoveGroovyDocWithField() throws Throwable { bothTest(); }
|
||||
|
||||
public void testMoveSecondFieldUp() throws Throwable { bothTest(); }
|
||||
public void testMoveFirstFieldDown() throws Throwable { bothTest(); }
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
class Person {
|
||||
/**
|
||||
* Full name of this person
|
||||
*/
|
||||
String name
|
||||
|
||||
/**
|
||||
* Age of this person in years
|
||||
*/
|
||||
int ag<caret>e
|
||||
}
|
||||
-----
|
||||
class Person {
|
||||
/**
|
||||
* Age of this person in years
|
||||
*/
|
||||
int ag<caret>e
|
||||
|
||||
/**
|
||||
* Full name of this person
|
||||
*/
|
||||
String name
|
||||
}
|
||||
-----
|
||||
class Person {
|
||||
/**
|
||||
* Full name of this person
|
||||
*/
|
||||
String name
|
||||
|
||||
/**
|
||||
* Age of this person in years
|
||||
*/
|
||||
int ag<caret>e
|
||||
}
|
||||
Reference in New Issue
Block a user