1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fix for 194710: [Indent] Issue when case statement has a 'char'

This commit is contained in:
Anton Leherbauer 2007-06-29 11:26:44 +00:00
parent a7927f6fa4
commit 05c1dee1bc
2 changed files with 31 additions and 1 deletions

View file

@ -205,4 +205,29 @@ public class CIndenterTest extends BaseUITestCase {
public void testIndentationOfConstructorBodyWithInitializer_Bug194586() throws Exception {
assertIndenterResult();
}
//void f() {
//switch(c) {
//case 'a':
//{
//}
//case 1:
//{
//}
//}
//}
//void f() {
// switch(c) {
// case 'a':
// {
// }
// case 1:
// {
// }
// }
//}
public void testIndentationOfCaseBlockAfterCharLiteral_Bug194710() throws Exception {
assertIndenterResult();
}
}

View file

@ -785,7 +785,9 @@ public final class CIndenter {
case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
unindent= true;
else if ((prevToken == Symbols.TokenCOLON || prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) && !fPrefs.prefIndentBracesForArrays)
else if (prevToken == Symbols.TokenCOLON && !fPrefs.prefIndentBracesForBlocks)
unindent= true;
else if ((prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) && !fPrefs.prefIndentBracesForArrays)
unindent= true;
else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
indent= true;
@ -1004,6 +1006,9 @@ public final class CIndenter {
private boolean looksLikeCaseStatement() {
nextToken();
switch (fToken) {
case Symbols.TokenCASE:
// char literal got skipped
return true;
case Symbols.TokenIDENT:
nextToken();
while (skipQualifiers()) {