IDEA-58510 code style/spaces within brackets does not apply to new array creation with a length specified

'Space within brackets' is processed for array initialisation brackets now
This commit is contained in:
Denis Zhdanov
2010-10-06 16:27:05 +04:00
parent 23b9b018ac
commit d9cdf5ce98
2 changed files with 14 additions and 0 deletions
@@ -185,6 +185,9 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
else if (myRole2 == ChildRole.ARGUMENT_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
}
else if (myRole1 == ChildRole.LBRACKET || myRole2 == ChildRole.RBRACKET) {
createSpaceInCode(mySettings.SPACE_WITHIN_BRACKETS);
}
}
@Override public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
@@ -163,4 +163,15 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
" }\n" +
"}");
}
public void testSpaceWithArrayBrackets() throws Exception {
// Inspired by IDEA-58510
getSettings().SPACE_WITHIN_BRACKETS = true;
doMethodTest(
"int[] i = new int[1]\n" +
"i[0] = 1;",
"int[] i = new int[ 1 ]\n" +
"i[ 0 ] = 1;"
);
}
}