Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[356606] - [formatter] fixed (hardcoded) unwanted alignment inside ar…
…ray literal
  • Loading branch information
Vladimir Varankin committed Jan 3, 2013
1 parent caadd58 commit 1d40c05
Showing 1 changed file with 39 additions and 22 deletions.
Expand Up @@ -1369,36 +1369,53 @@ private int handleScopeIntroduction(int bound) {
case Symbols.TokenLBRACE:
pos= fPosition; // store

// (XXX,narqo): Why checks for Array in `LBRACE` token
// // special: array initializer
// if (looksLikeArrayInitializerIntro())
// if (fPrefs.prefArrayDeepIndent)
// return setFirstElementAlignment(pos, bound);
// else
// fIndent= fPrefs.prefArrayIndent;
// else
// fIndent= fPrefs.prefBlockIndent;
//
//
// // normal: skip to the statement start before the scope introducer
// // opening braces are often on differently ending indents than e.g. a method definition
// if (looksLikeArrayInitializerIntro() && !fPrefs.prefIndentBracesForArrays
// || !fPrefs.prefIndentBracesForBlocks) {
// fPosition= pos; // restore
// return skipToStatementStart(true, true); // set to true to match the first if
// } else {
// return pos;
// }

fIndent= fPrefs.prefBlockIndent;
return pos;

case Symbols.TokenLBRACKET:
pos= fPosition; // store

// WTF?
// // special: method declaration deep indentation
// if (fPrefs.prefArrayDimensionsDeepIndent) {
// return setFirstElementAlignment(pos, bound);
// }

// special: array initializer
if (looksLikeArrayInitializerIntro())
if (fPrefs.prefArrayDeepIndent)
return setFirstElementAlignment(pos, bound);
else
fIndent= fPrefs.prefArrayIndent;
else
fIndent= fPrefs.prefBlockIndent;

// normal: skip to the statement start before the scope introducer
// opening braces are often on differently ending indents than e.g. a method definition
if (looksLikeArrayInitializerIntro() && !fPrefs.prefIndentBracesForArrays
|| !fPrefs.prefIndentBracesForBlocks) {
fPosition= pos; // restore
return skipToStatementStart(true, true); // set to true to match the first if
} else {
return pos;
}

case Symbols.TokenLBRACKET:
pos= fPosition; // store

// special: method declaration deep indentation
if (fPrefs.prefArrayDimensionsDeepIndent) {
return setFirstElementAlignment(pos, bound);
}
// normal: return the bracket as reference
fIndent= fPrefs.prefBracketIndent;

fPosition= pos; // restore
return skipToStatementStart(true, true); // set to true to match the first if

// normal: return the bracket as reference
fIndent= fPrefs.prefBracketIndent;
return pos; // restore
// return pos; // restore

default:
Assert.isTrue(false);
Expand Down

0 comments on commit 1d40c05

Please sign in to comment.