Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Dubrow2010-04-14 08:49:00 -0400
committerDavid Dubrow2010-04-14 08:49:00 -0400
commit58d2a2e8b608801fc2e565ec1099668d4c4b5ca7 (patch)
treef25af380392228604c9a47e7740ad6cf61b89576
parent95cc453417bdf036d4078c723d5133c3288bb89b (diff)
downloadorg.eclipse.cdt-58d2a2e8b608801fc2e565ec1099668d4c4b5ca7.tar.gz
org.eclipse.cdt-58d2a2e8b608801fc2e565ec1099668d4c4b5ca7.tar.xz
org.eclipse.cdt-58d2a2e8b608801fc2e565ec1099668d4c4b5ca7.zip
Fix and test for case where method body brace should be indented once - bug 298282
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java2
2 files changed, 5 insertions, 3 deletions
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 17e3b6e18a..aadbc16af8 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
@@ -814,9 +814,11 @@ public class CIndenterTest extends BaseUITestCase {
//}
//void t() const
- //{
- //}
+ // {
+ // }
public void testIndentationOfConstMethodBody_Bug298282() throws Exception {
+ fOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION,
+ DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
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 8e2ddd5db5..2184172036 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
@@ -833,7 +833,7 @@ public final class CIndenter {
} else if ((prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) &&
!fPrefs.prefIndentBracesForArrays) {
cancelIndent= true;
- } else if (prevToken == Symbols.TokenRPAREN && fPrefs.prefIndentBracesForMethods) {
+ } else if ((prevToken == Symbols.TokenRPAREN || prevToken == Symbols.TokenCONST) && fPrefs.prefIndentBracesForMethods) {
extraIndent= 1;
} else if (prevToken == Symbols.TokenIDENT && fPrefs.prefIndentBracesForTypes) {
extraIndent= 1;

Back to the top