diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index e6bd5f2a8ba..e392f0a7e3c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -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(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index 89053f73250..dc40302d0eb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -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;