mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
normalize declaration: don't include tree next after space
This commit is contained in:
+11
-3
@@ -181,9 +181,17 @@ public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLoca
|
||||
|
||||
ASTNode comma = PsiImplUtil.skipWhitespaceAndCommentsBack(variable.getTreePrev());
|
||||
if (comma != null && comma.getElementType() == JavaTokenType.COMMA) {
|
||||
PsiElement commaPsi = comma.getPsi();
|
||||
PsiElement lastWhitespaceAfterComma = commaPsi != null && commaPsi.getNextSibling() instanceof PsiWhiteSpace ? PsiTreeUtil.skipWhitespacesForward(commaPsi) : null;
|
||||
CodeEditUtil.removeChildren(statement, comma, lastWhitespaceAfterComma != null ? lastWhitespaceAfterComma.getNode() : comma);
|
||||
PsiElement lastWhitespaceAfterComma = comma.getPsi();
|
||||
while (true) {
|
||||
PsiElement nextSibling = lastWhitespaceAfterComma.getNextSibling();
|
||||
if (nextSibling instanceof PsiWhiteSpace) {
|
||||
lastWhitespaceAfterComma = nextSibling;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
CodeEditUtil.removeChildren(statement, comma, lastWhitespaceAfterComma.getNode());
|
||||
}
|
||||
|
||||
CodeEditUtil.removeChild(statement, variable);
|
||||
|
||||
+2
@@ -3,6 +3,8 @@ class Test {
|
||||
{
|
||||
String foo = "foo";//c1
|
||||
//c2
|
||||
//c3
|
||||
String bar = "bar";
|
||||
String baz = "baz";
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
// "Split into separate declarations" "true"
|
||||
class Test {
|
||||
{
|
||||
String foo <caret>= "foo",//c1
|
||||
bar = "bar";//c2
|
||||
String foo <caret>= "foo",
|
||||
//c1
|
||||
bar = "bar",//c2
|
||||
baz = "baz"; //c3
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user