1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 09:55:29 +02:00

Bug 324031 - Indentation problems with typedef and enum

This commit is contained in:
Anton Leherbauer 2010-09-01 06:05:49 +00:00
parent 0ea29b6195
commit 6a00f7487a
2 changed files with 53 additions and 9 deletions

View file

@ -933,4 +933,39 @@ public class CIndenterTest extends BaseUITestCase {
public void testIndentationOfCaseWithSignedConstant_Bug304150() throws Exception {
assertIndenterResult();
}
//typedef struct
//{
//int i;
//};
//typedef enum
//{
//e;
//};
//typedef struct
//{
// int i;
//};
//typedef enum
//{
// e;
//};
public void testIndentationOfTypedefedCompositeType_Bug324031() throws Exception {
fOptions.putAll(DefaultCodeFormatterOptions.getAllmanSettings().getMap());
assertIndenterResult();
}
//enum {
//a=1,
//b
//}
//enum {
// a=1,
// b
//}
public void testIndentationAfterEnumValueAssignment_Bug324031() throws Exception {
assertIndenterResult();
}
}

View file

@ -1260,18 +1260,15 @@ public final class CIndenter {
private boolean looksLikeEnumDeclaration() {
int pos = fPosition;
nextToken();
switch (fToken) {
case Symbols.TokenIDENT:
if (fToken == Symbols.TokenIDENT) {
nextToken();
while (skipQualifiers()) {
nextToken();
}
switch (fToken) {
case Symbols.TokenENUM:
fPosition = pos;
return true;
}
break;
}
if (fToken == Symbols.TokenENUM) {
fPosition = pos;
return true;
}
fPosition = pos;
return false;
@ -1617,6 +1614,7 @@ public final class CIndenter {
fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
fToken == Symbols.TokenRPAREN;
while (true) {
int previous = fToken;
nextToken();
// If any line item comes with its own indentation, adapt to it
@ -1674,11 +1672,22 @@ public final class CIndenter {
break;
case Symbols.TokenRETURN:
case Symbols.TokenTYPEDEF:
case Symbols.TokenUSING:
fIndent = fPrefs.prefContinuationIndent;
return fPosition;
case Symbols.TokenTYPEDEF:
switch (previous) {
case Symbols.TokenSTRUCT:
case Symbols.TokenUNION:
case Symbols.TokenCLASS:
case Symbols.TokenENUM:
break;
default:
fIndent = fPrefs.prefContinuationIndent;
}
return fPosition;
case Symbols.TokenEOF:
if (continuationLineCandidate) {
fIndent = fPrefs.prefContinuationIndent;