Lines 62-67
Link Here
|
62 |
final int prefMethodBodyIndent; |
62 |
final int prefMethodBodyIndent; |
63 |
final int prefTypeIndent; |
63 |
final int prefTypeIndent; |
64 |
final int prefAccessSpecifierIndent; |
64 |
final int prefAccessSpecifierIndent; |
|
|
65 |
final int prefNamespaceBodyIndent; |
65 |
final boolean prefIndentBracesForBlocks; |
66 |
final boolean prefIndentBracesForBlocks; |
66 |
final boolean prefIndentBracesForArrays; |
67 |
final boolean prefIndentBracesForArrays; |
67 |
final boolean prefIndentBracesForMethods; |
68 |
final boolean prefIndentBracesForMethods; |
Lines 111-116
Link Here
|
111 |
prefMethodBodyIndent= prefMethodBodyIndent(); |
112 |
prefMethodBodyIndent= prefMethodBodyIndent(); |
112 |
prefTypeIndent= prefTypeIndent(); |
113 |
prefTypeIndent= prefTypeIndent(); |
113 |
prefAccessSpecifierIndent= prefAccessSpecifierIndent(); |
114 |
prefAccessSpecifierIndent= prefAccessSpecifierIndent(); |
|
|
115 |
prefNamespaceBodyIndent= prefNamespaceBodyIndent(); |
114 |
prefIndentBracesForArrays= prefIndentBracesForArrays(); |
116 |
prefIndentBracesForArrays= prefIndentBracesForArrays(); |
115 |
prefIndentBracesForMethods= prefIndentBracesForMethods(); |
117 |
prefIndentBracesForMethods= prefIndentBracesForMethods(); |
116 |
prefIndentBracesForTypes= prefIndentBracesForTypes(); |
118 |
prefIndentBracesForTypes= prefIndentBracesForTypes(); |
Lines 308-313
Link Here
|
308 |
return 0; |
310 |
return 0; |
309 |
} |
311 |
} |
310 |
|
312 |
|
|
|
313 |
private int prefNamespaceBodyIndent() { |
314 |
if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER))) |
315 |
return prefBlockIndent(); |
316 |
else |
317 |
return 0; |
318 |
} |
319 |
|
311 |
private boolean prefIndentBracesForBlocks() { |
320 |
private boolean prefIndentBracesForBlocks() { |
312 |
return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK)); |
321 |
return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK)); |
313 |
} |
322 |
} |
Lines 1009-1018
Link Here
|
1009 |
case Symbols.TokenTRY: |
1018 |
case Symbols.TokenTRY: |
1010 |
return fPosition; |
1019 |
return fPosition; |
1011 |
|
1020 |
|
1012 |
case Symbols.TokenSTATIC: |
|
|
1013 |
mayBeMethodBody= READ_IDENT; // treat static blocks like methods |
1014 |
break; |
1015 |
|
1016 |
case Symbols.TokenCLASS: |
1021 |
case Symbols.TokenCLASS: |
1017 |
case Symbols.TokenENUM: |
1022 |
case Symbols.TokenENUM: |
1018 |
isTypeBody= true; |
1023 |
isTypeBody= true; |
Lines 1435-1447
Link Here
|
1435 |
pos= fPosition; // store |
1440 |
pos= fPosition; // store |
1436 |
|
1441 |
|
1437 |
// special: array initializer |
1442 |
// special: array initializer |
1438 |
if (looksLikeArrayInitializerIntro()) |
1443 |
if (looksLikeArrayInitializerIntro()) { |
1439 |
if (fPrefs.prefArrayDeepIndent) |
1444 |
if (fPrefs.prefArrayDeepIndent) |
1440 |
return setFirstElementAlignment(pos, bound); |
1445 |
return setFirstElementAlignment(pos, bound); |
1441 |
else |
1446 |
else |
1442 |
fIndent= fPrefs.prefArrayIndent; |
1447 |
fIndent= fPrefs.prefArrayIndent; |
1443 |
else |
1448 |
} else if (isNamespace()) { |
|
|
1449 |
fIndent= fPrefs.prefNamespaceBodyIndent; |
1450 |
} else { |
1444 |
fIndent= fPrefs.prefBlockIndent; |
1451 |
fIndent= fPrefs.prefBlockIndent; |
|
|
1452 |
} |
1445 |
|
1453 |
|
1446 |
// normal: skip to the statement start before the scope introducer |
1454 |
// normal: skip to the statement start before the scope introducer |
1447 |
// opening braces are often on differently ending indents than e.g. a method definition |
1455 |
// opening braces are often on differently ending indents than e.g. a method definition |
Lines 1505-1510
Link Here
|
1505 |
} |
1513 |
} |
1506 |
|
1514 |
|
1507 |
/** |
1515 |
/** |
|
|
1516 |
* Returns <code>true</code> if the the current token is "namespace", or the current token |
1517 |
* is an identifier and the previous token is "namespace". |
1518 |
* |
1519 |
* @return <code>true</code> if the next elements look like the start of a namespace declaration. |
1520 |
*/ |
1521 |
private boolean isNamespace() { |
1522 |
if (fToken == Symbols.TokenNAMESPACE) { |
1523 |
return true; // Anonymous namespace |
1524 |
} else if (fToken == Symbols.TokenIDENT) { |
1525 |
nextToken(); // Get previous token |
1526 |
if (fToken == Symbols.TokenNAMESPACE) { |
1527 |
return true; // Named namespace |
1528 |
} |
1529 |
} |
1530 |
return false; |
1531 |
} |
1532 |
|
1533 |
/** |
1508 |
* Skips over the next <code>if</code> keyword. The current token when calling |
1534 |
* Skips over the next <code>if</code> keyword. The current token when calling |
1509 |
* this method must be an <code>else</code> keyword. Returns <code>true</code> |
1535 |
* this method must be an <code>else</code> keyword. Returns <code>true</code> |
1510 |
* if a matching <code>if</code> could be found, <code>false</code> otherwise. |
1536 |
* if a matching <code>if</code> could be found, <code>false</code> otherwise. |