mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Bug 324031 - Indentation problems with typedef and enum
This commit is contained in:
parent
0ea29b6195
commit
6a00f7487a
2 changed files with 53 additions and 9 deletions
|
@ -933,4 +933,39 @@ public class CIndenterTest extends BaseUITestCase {
|
||||||
public void testIndentationOfCaseWithSignedConstant_Bug304150() throws Exception {
|
public void testIndentationOfCaseWithSignedConstant_Bug304150() throws Exception {
|
||||||
assertIndenterResult();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1260,18 +1260,15 @@ public final class CIndenter {
|
||||||
private boolean looksLikeEnumDeclaration() {
|
private boolean looksLikeEnumDeclaration() {
|
||||||
int pos = fPosition;
|
int pos = fPosition;
|
||||||
nextToken();
|
nextToken();
|
||||||
switch (fToken) {
|
if (fToken == Symbols.TokenIDENT) {
|
||||||
case Symbols.TokenIDENT:
|
|
||||||
nextToken();
|
nextToken();
|
||||||
while (skipQualifiers()) {
|
while (skipQualifiers()) {
|
||||||
nextToken();
|
nextToken();
|
||||||
}
|
}
|
||||||
switch (fToken) {
|
}
|
||||||
case Symbols.TokenENUM:
|
if (fToken == Symbols.TokenENUM) {
|
||||||
fPosition = pos;
|
fPosition = pos;
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
fPosition = pos;
|
fPosition = pos;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1617,6 +1614,7 @@ public final class CIndenter {
|
||||||
fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
|
fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
|
||||||
fToken == Symbols.TokenRPAREN;
|
fToken == Symbols.TokenRPAREN;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
int previous = fToken;
|
||||||
nextToken();
|
nextToken();
|
||||||
|
|
||||||
// If any line item comes with its own indentation, adapt to it
|
// If any line item comes with its own indentation, adapt to it
|
||||||
|
@ -1674,11 +1672,22 @@ public final class CIndenter {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Symbols.TokenRETURN:
|
case Symbols.TokenRETURN:
|
||||||
case Symbols.TokenTYPEDEF:
|
|
||||||
case Symbols.TokenUSING:
|
case Symbols.TokenUSING:
|
||||||
fIndent = fPrefs.prefContinuationIndent;
|
fIndent = fPrefs.prefContinuationIndent;
|
||||||
return fPosition;
|
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:
|
case Symbols.TokenEOF:
|
||||||
if (continuationLineCandidate) {
|
if (continuationLineCandidate) {
|
||||||
fIndent = fPrefs.prefContinuationIndent;
|
fIndent = fPrefs.prefContinuationIndent;
|
||||||
|
|
Loading…
Add table
Reference in a new issue