mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bugs 529299 and 491296. Fix indentation after 'noexcept'/'override'.
Change-Id: I3129e5f9fced4a27020f6ca27238bf5faf4df889 Signed-off-by: Davin McCall <davmac@davmac.org>
This commit is contained in:
parent
1213755167
commit
fc053e6124
4 changed files with 52 additions and 2 deletions
|
@ -513,6 +513,43 @@ public class CAutoIndentTest extends AbstractAutoEditTest {
|
||||||
assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
|
assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSmartIndentAfterNoexcept_Bug529299() throws Exception {
|
||||||
|
AutoEditTester tester = createAutoEditTester();
|
||||||
|
|
||||||
|
tester.type("void f() noexcept\n"); //$NON-NLS-1$
|
||||||
|
assertEquals(1, tester.getCaretLine());
|
||||||
|
tester.type('{');
|
||||||
|
// Brace is not indented
|
||||||
|
assertEquals(1, tester.getCaretColumn());
|
||||||
|
tester.type('\n');
|
||||||
|
// The brace was closed automatically.
|
||||||
|
assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
|
||||||
|
|
||||||
|
tester.reset();
|
||||||
|
tester.type("void f() noexcept(true)\n"); //$NON-NLS-1$
|
||||||
|
assertEquals(1, tester.getCaretLine());
|
||||||
|
tester.type('{');
|
||||||
|
// Brace is not indented
|
||||||
|
assertEquals(1, tester.getCaretColumn());
|
||||||
|
tester.type('\n');
|
||||||
|
// The brace was closed automatically.
|
||||||
|
assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSmartIndentAfterOverride_Bug491296() throws Exception {
|
||||||
|
AutoEditTester tester = createAutoEditTester();
|
||||||
|
|
||||||
|
tester.reset();
|
||||||
|
tester.type("void f() override\n"); //$NON-NLS-1$
|
||||||
|
assertEquals(1, tester.getCaretLine());
|
||||||
|
tester.type('{');
|
||||||
|
// Brace is not indented
|
||||||
|
assertEquals(1, tester.getCaretColumn());
|
||||||
|
tester.type('\n');
|
||||||
|
// The brace was closed automatically.
|
||||||
|
assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void testSkipToStatementStartWhitesmiths_Bug311018() throws Exception {
|
public void testSkipToStatementStartWhitesmiths_Bug311018() throws Exception {
|
||||||
DefaultCodeFormatterOptions whitesmiths= DefaultCodeFormatterOptions.getWhitesmithsSettings();
|
DefaultCodeFormatterOptions whitesmiths= DefaultCodeFormatterOptions.getWhitesmithsSettings();
|
||||||
CCorePlugin.setOptions(new HashMap<String, String>(whitesmiths.getMap()));
|
CCorePlugin.setOptions(new HashMap<String, String>(whitesmiths.getMap()));
|
||||||
|
|
|
@ -630,6 +630,10 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
return TokenTEMPLATE;
|
return TokenTEMPLATE;
|
||||||
if ("typename".equals(s)) //$NON-NLS-1$
|
if ("typename".equals(s)) //$NON-NLS-1$
|
||||||
return TokenTYPENAME;
|
return TokenTYPENAME;
|
||||||
|
if ("noexcept".equals(s)) //$NON-NLS-1$
|
||||||
|
return TokenNOEXCEPT;
|
||||||
|
if ("override".equals(s)) //$NON-NLS-1$
|
||||||
|
return TokenOVERRIDE;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
if ("namespace".equals(s)) //$NON-NLS-1$
|
if ("namespace".equals(s)) //$NON-NLS-1$
|
||||||
|
|
|
@ -1123,7 +1123,9 @@ public final class CIndenter {
|
||||||
return fPosition;
|
return fPosition;
|
||||||
}
|
}
|
||||||
fPosition= scope;
|
fPosition= scope;
|
||||||
if (looksLikeMethodDecl()) {
|
// "noexcept" at this point would be a noexcept-with-argument, which should be
|
||||||
|
// attached to a method declaration:
|
||||||
|
if (looksLikeMethodDecl() || fToken == Symbols.TokenNOEXCEPT) {
|
||||||
return skipToStatementStart(danglingElse, false);
|
return skipToStatementStart(danglingElse, false);
|
||||||
}
|
}
|
||||||
if (fToken == Symbols.TokenCATCH) {
|
if (fToken == Symbols.TokenCATCH) {
|
||||||
|
@ -1140,6 +1142,11 @@ public final class CIndenter {
|
||||||
// else: fall through to default
|
// else: fall through to default
|
||||||
return skipToPreviousListItemOrListStart();
|
return skipToPreviousListItemOrListStart();
|
||||||
|
|
||||||
|
case Symbols.TokenNOEXCEPT:
|
||||||
|
case Symbols.TokenOVERRIDE:
|
||||||
|
// Method declaration
|
||||||
|
return skipToStatementStart(danglingElse, false);
|
||||||
|
|
||||||
case Symbols.TokenCOMMA:
|
case Symbols.TokenCOMMA:
|
||||||
// Inside a list of some type.
|
// Inside a list of some type.
|
||||||
// Easy if there is already a list item before with its own indentation - we just align.
|
// Easy if there is already a list item before with its own indentation - we just align.
|
||||||
|
|
|
@ -72,5 +72,7 @@ public interface Symbols {
|
||||||
int TokenUSING= 1039;
|
int TokenUSING= 1039;
|
||||||
int TokenTEMPLATE= 1040;
|
int TokenTEMPLATE= 1040;
|
||||||
int TokenTYPENAME= 1041;
|
int TokenTYPENAME= 1041;
|
||||||
|
int TokenNOEXCEPT= 1042;
|
||||||
|
int TokenOVERRIDE= 1043;
|
||||||
int TokenIDENT= 2000;
|
int TokenIDENT= 2000;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue