mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Bug 562181: Fix auto indent after constructor with access specifiers
Some heuristics in skipToStatementStart require knowledge of previous token. It is initialized with value from a fToken, but it current value may be invalid because looksLikeMethodDecl changes fPossition value without adjusting a fToken. Using invalid value may lead to false triggering of heuristics. Restore fToken value when change fPossition in looksLikeMethodDecl to prevent this. Change-Id: If0c2c0577c89a983e1479587409f293c3d0db7be Signed-off-by: Andrey Mozzhuhin <amozzhuhin@yandex.ru>
This commit is contained in:
parent
cab5fc1752
commit
f4f9785b87
2 changed files with 24 additions and 0 deletions
|
@ -1082,4 +1082,23 @@ public class CIndenterTest extends BaseUITestCase {
|
|||
public void testIndentationAfterFunctionCallWithQualifier_Bug562125() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
|
||||
//class Test
|
||||
//{
|
||||
//public:
|
||||
//Test()
|
||||
//{
|
||||
//}
|
||||
//};
|
||||
|
||||
//class Test
|
||||
//{
|
||||
//public:
|
||||
// Test()
|
||||
// {
|
||||
// }
|
||||
//};
|
||||
public void testIndentationAfterContructorWithAccessSpecifier_Bug562181() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2245,10 +2245,12 @@ public final class CIndenter {
|
|||
case Symbols.TokenSEMICOLON:
|
||||
case Symbols.TokenRBRACE:
|
||||
fPosition = pos;
|
||||
fToken = Symbols.TokenIDENT;
|
||||
return true;
|
||||
case Symbols.TokenLBRACE:
|
||||
if (fScanner.looksLikeCompositeTypeDefinitionBackward(fPosition, CHeuristicScanner.UNBOUND)) {
|
||||
fPosition = pos;
|
||||
fToken = Symbols.TokenIDENT;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -2268,11 +2270,13 @@ public final class CIndenter {
|
|||
case Symbols.TokenPROTECTED:
|
||||
case Symbols.TokenPRIVATE:
|
||||
fPosition = pos;
|
||||
fToken = Symbols.TokenIDENT;
|
||||
return true;
|
||||
case Symbols.TokenRPAREN:
|
||||
// constructor initializer
|
||||
if (skipScope()) {
|
||||
pos = fPosition;
|
||||
int token = fToken;
|
||||
nextToken();
|
||||
// optional throw
|
||||
if (fToken == Symbols.TokenTHROW) {
|
||||
|
@ -2282,6 +2286,7 @@ public final class CIndenter {
|
|||
}
|
||||
} else {
|
||||
fPosition = pos;
|
||||
fToken = token;
|
||||
}
|
||||
return looksLikeMethodDecl();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue