mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix for 194710: [Indent] Issue when case statement has a 'char'
This commit is contained in:
parent
a7927f6fa4
commit
05c1dee1bc
2 changed files with 31 additions and 1 deletions
|
@ -205,4 +205,29 @@ public class CIndenterTest extends BaseUITestCase {
|
||||||
public void testIndentationOfConstructorBodyWithInitializer_Bug194586() throws Exception {
|
public void testIndentationOfConstructorBodyWithInitializer_Bug194586() throws Exception {
|
||||||
assertIndenterResult();
|
assertIndenterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void f() {
|
||||||
|
//switch(c) {
|
||||||
|
//case 'a':
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
//case 1:
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void f() {
|
||||||
|
// switch(c) {
|
||||||
|
// case 'a':
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// case 1:
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public void testIndentationOfCaseBlockAfterCharLiteral_Bug194710() throws Exception {
|
||||||
|
assertIndenterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -785,7 +785,9 @@ public final class CIndenter {
|
||||||
case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
|
case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
|
||||||
if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
|
if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
|
||||||
unindent= true;
|
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;
|
unindent= true;
|
||||||
else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
|
else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
|
||||||
indent= true;
|
indent= true;
|
||||||
|
@ -1004,6 +1006,9 @@ public final class CIndenter {
|
||||||
private boolean looksLikeCaseStatement() {
|
private boolean looksLikeCaseStatement() {
|
||||||
nextToken();
|
nextToken();
|
||||||
switch (fToken) {
|
switch (fToken) {
|
||||||
|
case Symbols.TokenCASE:
|
||||||
|
// char literal got skipped
|
||||||
|
return true;
|
||||||
case Symbols.TokenIDENT:
|
case Symbols.TokenIDENT:
|
||||||
nextToken();
|
nextToken();
|
||||||
while (skipQualifiers()) {
|
while (skipQualifiers()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue