mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change signature: process first param spacing (IDEA-59817)
This commit is contained in:
+20
-1
@@ -77,7 +77,8 @@ public class ParameterListElement extends CompositeElement implements Constants
|
||||
}
|
||||
|
||||
public void deleteChildInternal(@NotNull ASTNode child) {
|
||||
TreeElement oldLastNodeInsideParens = getLastNodeInsideParens();
|
||||
final TreeElement oldLastNodeInsideParens = getLastNodeInsideParens();
|
||||
final TreeElement oldFirstNodeInsideParens = getFirstNodeInsideParens();
|
||||
if (child.getElementType() == PARAMETER) {
|
||||
ASTNode next = TreeUtil.skipElements(child.getTreeNext(), StdTokenSets.WHITE_SPACE_OR_COMMENT_BIT_SET);
|
||||
if (next != null && next.getElementType() == COMMA) {
|
||||
@@ -105,6 +106,15 @@ public class ParameterListElement extends CompositeElement implements Constants
|
||||
}
|
||||
}
|
||||
|
||||
final TreeElement newFirstNodeInsideParens = getFirstNodeInsideParens();
|
||||
if (newFirstNodeInsideParens != null && newFirstNodeInsideParens.getElementType() == WHITE_SPACE) {
|
||||
if (oldFirstNodeInsideParens == null || oldFirstNodeInsideParens.getElementType() != WHITE_SPACE) {
|
||||
deleteChildInternal(newFirstNodeInsideParens);
|
||||
} else {
|
||||
replaceChild(newFirstNodeInsideParens, (ASTNode)oldFirstNodeInsideParens.clone());
|
||||
}
|
||||
}
|
||||
|
||||
//todo[max] hack?
|
||||
try {
|
||||
CodeStyleManager.getInstance(getManager().getProject()).reformat(getPsi());
|
||||
@@ -166,4 +176,13 @@ public class ParameterListElement extends CompositeElement implements Constants
|
||||
TreeElement lastNode = getLastChildNode();
|
||||
return lastNode.getElementType() == RPARENTH ? lastNode.getTreePrev() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return first node after opening left paren if possible; <code>null</code> otherwise
|
||||
*/
|
||||
@Nullable
|
||||
private TreeElement getFirstNodeInsideParens() {
|
||||
TreeElement firstNode = getFirstChildNode();
|
||||
return firstNode.getElementType() == LPARENTH ? firstNode.getTreeNext() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void <caret>foo(boolean b,
|
||||
int i) { // Don't expect line break to be inserted before closing method args bracket
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Test {
|
||||
void <caret>foo(int i) { // Don't expect line break to be inserted before closing method args bracket
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,10 @@ public class ChangeSignatureTest extends LightCodeInsightTestCase {
|
||||
doTest(null, new ParameterInfoImpl[] {new ParameterInfoImpl(1), new ParameterInfoImpl(0)}, false);
|
||||
}
|
||||
|
||||
public void testRemoveFirstParameter() throws Exception {
|
||||
doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(1)}, false);
|
||||
}
|
||||
|
||||
public void testReplaceVarargWithArray() throws Exception {
|
||||
doTest(null, null, null, new GenParams() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user