Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-04-07 10:53:36 +0000
committerAnton Leherbauer2008-04-07 10:53:36 +0000
commit3d6501658cf1525291bb35c339abf3f7b9834dad (patch)
treecfe2011b5ca8dbc47b5caa2347e10fbe4c716b2f /core/org.eclipse.cdt.core
parent076444ffe042df890ae32472beafd08556b63449 (diff)
downloadorg.eclipse.cdt-3d6501658cf1525291bb35c339abf3f7b9834dad.tar.gz
org.eclipse.cdt-3d6501658cf1525291bb35c339abf3f7b9834dad.tar.xz
org.eclipse.cdt-3d6501658cf1525291bb35c339abf3f7b9834dad.zip
Fix for 225858: Code formatter differences from CDT 4.0.x
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java14
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java1
2 files changed, 11 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index fb71249cb1..c1841152cc 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -129,6 +129,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.internal.formatter.align.Alignment;
import org.eclipse.cdt.internal.formatter.align.AlignmentException;
import org.eclipse.cdt.internal.formatter.scanner.Scanner;
@@ -2167,19 +2168,20 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.printNextToken(Token.tCOLONCOLON);
}
scribe.printNextToken(Token.t_new);
+ scribe.space();
// placement
final IASTExpression newPlacement= node.getNewPlacement();
if (newPlacement != null) {
formatParenthesizedExpression(newPlacement);
}
+
// type-id
+ scribe.space();
final IASTTypeId typeId= node.getTypeId();
final boolean expectParen= !node.isNewTypeId() && peekNextToken() == Token.tLPAREN;
if (expectParen) {
- scribe.printNextToken(Token.tLPAREN, scribe.printComment());
- } else {
- scribe.space();
+ scribe.printNextToken(Token.tLPAREN, false);
}
typeId.accept(this);
if (expectParen) {
@@ -2486,7 +2488,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.printNextToken(Token.tGT, preferences.insert_space_before_closing_angle_bracket_in_template_arguments);
if (node.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME) {
if (preferences.insert_space_after_closing_angle_bracket_in_template_arguments) {
- scribe.space();
+ // avoid explicit space if followed by pointer operator
+ int nextToken= peekNextToken();
+ if (nextToken != IToken.tSTAR && nextToken != IToken.tAMPER) {
+ scribe.space();
+ }
} else {
scribe.printComment();
scribe.needSpace= false;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java
index 0b5cba9d4e..097b03b7e6 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java
@@ -1737,6 +1737,7 @@ public class DefaultCodeFormatterOptions {
public void setWhitesmitsSettings() {
setDefaultSettings();
this.alignment_for_expressions_in_initializer_list = Alignment.M_ONE_PER_LINE_SPLIT;
+ this.alignment_for_enumerator_list = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_FORCE;
this.brace_position_for_initializer_list = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED;
this.brace_position_for_block = DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED;

Back to the top