Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-11-07 14:00:43 -0500
committerSergey Prigogin2011-11-07 14:04:35 -0500
commitafb3fae823eca93ea486d6aebb4525bfbccac796 (patch)
tree1ec57b44ff4870749ca370f871373deff60ed6a4 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter
parent65673a50e15988ab8840f73eca11e2423db301d4 (diff)
downloadorg.eclipse.cdt-afb3fae823eca93ea486d6aebb4525bfbccac796.tar.gz
org.eclipse.cdt-afb3fae823eca93ea486d6aebb4525bfbccac796.tar.xz
org.eclipse.cdt-afb3fae823eca93ea486d6aebb4525bfbccac796.zip
Automatic formatting of code affected by refactoring.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java108
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java77
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java48
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java75
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java36
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java3
12 files changed, 280 insertions, 144 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
index 8752230ea2..5b7229e5de 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java
@@ -8,10 +8,19 @@
*
* Contributors:
* Institute for Software - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.ASTCommenter;
@@ -19,9 +28,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
* ASTWriter main class. Generates source code from <code>IASTNode</code>.
- * Uses a <code>hangeGeneratorWriterVisitor</code> to generate the code for the given nodes.
- *
- * @see ChangeGeneratorWriterVisitor
+ * Uses a {@link ChangeGeneratorWriterVisitor} to generate the code for the given nodes.
*
* @author Emanuel Graf
*/
@@ -54,18 +61,13 @@ public class ASTWriter {
* @throws ProblemRuntimeException if the node or one of it's children is a <code>IASTProblemNode</code>.
*/
public String write(IASTNode rootNode) throws ProblemRuntimeException {
- return write(rootNode, null, new NodeCommentMap());
- }
-
- public String write(IASTNode rootNode, NodeCommentMap commentMap) {
- return write(rootNode, null, commentMap);
+ return write(rootNode, new NodeCommentMap());
}
/**
* Generates the source code representing this node including comments.
*
* @param rootNode Node to write.
- * @param fileScope
* @param commentMap Node Comment Map <code>ASTCommenter</code>
* @return A <code>String</code> representing the source code for the node.
* @throws ProblemRuntimeException if the node or one of it's children is
@@ -73,17 +75,95 @@ public class ASTWriter {
*
* @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
*/
- public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap)
+ public String write(IASTNode rootNode, NodeCommentMap commentMap)
throws ProblemRuntimeException {
- ChangeGeneratorWriterVisitor transformationVisitor = new ChangeGeneratorWriterVisitor(
- modificationStore, givenIndentation, fileScope, commentMap);
+ ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(
+ modificationStore, givenIndentation, null, commentMap);
if (rootNode != null) {
- rootNode.accept(transformationVisitor);
+ rootNode.accept(writer);
}
- return transformationVisitor.toString();
+ return writer.toString();
}
public void setModificationStore(ASTModificationStore modificationStore) {
this.modificationStore = modificationStore;
}
+
+ /**
+ * Returns <code>true</code> if the node should be separated by a blank line from the node
+ * before it.
+ *
+ * @param node The node.
+ * @return <code>true</code> if the node should be separated by a blank line from the node
+ * before it.
+ */
+ public static boolean requiresLeadingBlankLine(IASTNode node) {
+ if (node instanceof ICPPASTTemplateDeclaration) {
+ node = ((ICPPASTTemplateDeclaration) node).getDeclaration();
+ }
+ return node instanceof IASTASMDeclaration ||
+ node instanceof IASTFunctionDefinition ||
+ node instanceof ICPPASTVisibilityLabel;
+ }
+
+ /**
+ * Returns <code>true</code> if the node should be separated by a blank line from the node
+ * after it.
+ *
+ * @param node The node.
+ * @return <code>true</code> if the node should be separated by a blank line from the node
+ * after it.
+ */
+ public static boolean requiresTrailingBlankLine(IASTNode node) {
+ if (node instanceof ICPPASTNamespaceDefinition)
+ return true;
+ if (node instanceof IASTFunctionDefinition)
+ return true;
+ if (node instanceof IASTIfStatement) {
+ IASTIfStatement statement = ((IASTIfStatement) node);
+ IASTStatement lastClause = statement.getElseClause();
+ if (lastClause == null)
+ lastClause = statement.getThenClause();
+
+ if (!(lastClause instanceof IASTCompoundStatement) &&
+ !doNodesHaveSameOffset(lastClause, statement)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if there should be no blank line after this node even if a blank
+ * line is normally required before the subsequent node.
+ *
+ * @param node The node.
+ * @return <code>true</code> if there should be no blank line after this node.
+ */
+ public static boolean suppressesTrailingBlankLine(IASTNode node) {
+ return node instanceof ICPPASTVisibilityLabel;
+ }
+
+ /**
+ * Returns <code>true</code> if the two given nodes should be separated by a blank line.
+ *
+ * @param node1 The first node.
+ * @param node2 The second node.
+ * @return <code>true</code> if the blank line between the nodes is needed.
+ */
+ public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) {
+ if (requiresTrailingBlankLine(node1))
+ return true;
+
+ return !suppressesTrailingBlankLine(node1) && requiresLeadingBlankLine(node2);
+ }
+
+ /**
+ * Returns true if the two given nodes have the same offset. For nodes that are normally
+ * separated by other tokens this is an indication that they were produced by the same macro
+ * expansion.
+ */
+ private static boolean doNodesHaveSameOffset(IASTNode node1, IASTNode node2) {
+ return node1.getFileLocation().getNodeOffset() == node2.getFileLocation().getNodeOffset();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
index 553d8907c6..16f9325785 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java
@@ -9,6 +9,7 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@@ -38,15 +39,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
* Visits all nodes, prints leading comments and handles macro expansions. The
- * source code generation is delegated to severals <code>NodeWriters</code>.
+ * source code generation is delegated to severals {@code NodeWriter}s.
*
- * @see NodeWriter
* @see MacroExpansionHandler
*
* @author Emanuel Graf IFS
*/
public class ASTWriterVisitor extends ASTVisitor {
- protected Scribe scribe = new Scribe();
+ protected final Scribe scribe = new Scribe();
protected NodeCommentMap commentMap;
protected ExpressionWriter expWriter;
protected DeclSpecWriter declSpecWriter;
@@ -57,6 +57,9 @@ public class ASTWriterVisitor extends ASTVisitor {
protected NameWriter nameWriter;
protected TemplateParameterWriter tempParameterWriter;
protected MacroExpansionHandler macroHandler;
+ private boolean insertLeadingBlankLine;
+ private boolean suppressLeadingBlankLine;
+ private boolean spaceNeededBeforeName;
{
shouldVisitExpressions = true;
@@ -83,6 +86,7 @@ public class ASTWriterVisitor extends ASTVisitor {
scribe.setGivenIndentation(givenIndentation);
init(commentMap);
this.commentMap = commentMap;
+ this.suppressLeadingBlankLine = true;
}
private void init(NodeCommentMap commentMap) {
@@ -135,6 +139,10 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(IASTName name) {
+ if (spaceNeededBeforeName && name.getSimpleID().length != 0) {
+ scribe.printSpace();
+ spaceNeededBeforeName = false;
+ }
writeLeadingComments(name);
if (!macroHandler.checkisMacroExpansionNode(name)) {
nameWriter.writeName(name);
@@ -166,24 +174,31 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(IASTStatement statement) {
+ insertBlankLineIfNeeded(statement);
writeLeadingComments(statement);
- if (macroHandler.isStatementWithMixedLocation(statement) &&
- !(statement instanceof IASTCompoundStatement)) {
- return statementWriter.writeMixedStatement(statement);
- }
- if (macroHandler.checkisMacroExpansionNode(statement)) {
- return ASTVisitor.PROCESS_SKIP;
+ try {
+ if (macroHandler.isStatementWithMixedLocation(statement) &&
+ !(statement instanceof IASTCompoundStatement)) {
+ return statementWriter.writeMixedStatement(statement);
+ }
+ if (macroHandler.checkisMacroExpansionNode(statement)) {
+ return ASTVisitor.PROCESS_SKIP;
+ }
+ return statementWriter.writeStatement(statement, true);
+ } finally {
+ setLeadingBlankLineFlags(statement);
}
- return statementWriter.writeStatement(statement, true);
}
@Override
public int visit(IASTDeclaration declaration) {
+ insertBlankLineIfNeeded(declaration);
writeLeadingComments(declaration);
if (!macroHandler.checkisMacroExpansionNode(declaration)) {
declarationWriter.writeDeclaration(declaration);
+ setLeadingBlankLineFlags(declaration);
}
- return ASTVisitor.PROCESS_SKIP;
+ return ASTVisitor.PROCESS_SKIP;
}
@Override
@@ -219,9 +234,7 @@ public class ASTWriterVisitor extends ASTVisitor {
parameterDeclaration.getDeclSpecifier().accept(this);
IASTDeclarator declarator = getParameterDeclarator(parameterDeclaration);
- if (getParameterName(declarator).toString().length() != 0) {
- scribe.printSpaces(1);
- }
+ spaceNeededBeforeName = true;
declarator.accept(this);
}
return ASTVisitor.PROCESS_SKIP;
@@ -237,9 +250,11 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
+ insertBlankLineIfNeeded(namespace);
writeLeadingComments(namespace);
if (!macroHandler.checkisMacroExpansionNode(namespace)) {
declarationWriter.writeDeclaration(namespace);
+ setLeadingBlankLineFlags(namespace);
}
return ASTVisitor.PROCESS_SKIP;
}
@@ -257,4 +272,38 @@ public class ASTWriterVisitor extends ASTVisitor {
scribe.cleanCache();
macroHandler.reset();
}
+
+ private void insertBlankLineIfNeeded(IASTNode node) {
+ if (!suppressLeadingBlankLine &&
+ (insertLeadingBlankLine || ASTWriter.requiresLeadingBlankLine(node))) {
+ scribe.newLine();
+ }
+ insertLeadingBlankLine = false;
+ suppressLeadingBlankLine = false;
+ }
+
+ private void setLeadingBlankLineFlags(IASTNode node) {
+ insertLeadingBlankLine = ASTWriter.requiresTrailingBlankLine(node);
+ suppressLeadingBlankLine = ASTWriter.suppressesTrailingBlankLine(node);
+ }
+
+ public boolean isSuppressLeadingBlankLine() {
+ return suppressLeadingBlankLine;
+ }
+
+ public void setSuppressLeadingBlankLine(boolean value) {
+ this.suppressLeadingBlankLine = value;
+ }
+
+ public boolean isSpaceNeededBeforeName() {
+ return spaceNeededBeforeName;
+ }
+
+ public void setSpaceNeededBeforeName(boolean value) {
+ this.spaceNeededBeforeName = value;
+ }
+
+ public void newLine() {
+ scribe.newLine();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java
index 17c6eab08a..ba7fb2e862 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -62,12 +61,12 @@ public class DeclSpecWriter extends NodeWriter {
private static final String ENUM = "enum "; //$NON-NLS-1$
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
- public DeclSpecWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
protected void writeDelcSpec(IASTDeclSpecifier declSpec) {
-// Write general DelcSpec Keywords
+ // Write general DelcSpec Keywords
writeDeclSpec(declSpec);
if (declSpec instanceof ICPPASTDeclSpecifier) {
writeCPPDeclSpec((ICPPASTDeclSpecifier) declSpec);
@@ -129,7 +128,6 @@ public class DeclSpecWriter extends NodeWriter {
break;
}
- System.err.println("Unknown specifier type: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown specifier type: " + type); //$NON-NLS-1$
}
@@ -152,7 +150,7 @@ public class DeclSpecWriter extends NodeWriter {
}
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
- if ( namedSpc.isTypename() ){
+ if (namedSpc.isTypename()) {
scribe.print(TYPENAME);
}
namedSpc.getName().accept(visitor);
@@ -179,8 +177,7 @@ public class DeclSpecWriter extends NodeWriter {
return CLASS_SPACE;
default:
- System.err.println("Unknown ElaboratedType: " + kind); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknown ElaboratedType: " + kind); //$NON-NLS-1$
+ throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
}
}
@@ -254,12 +251,13 @@ public class DeclSpecWriter extends NodeWriter {
hasTrailingComments = hasTrailingComments(baseSpecifiers[baseSpecifiers.length-1].getName());
}
}
- if (!hasTrailingComments){
+ if (!hasTrailingComments) {
scribe.newLine();
}
scribe.print('{');
scribe.newLine();
scribe.incrementIndentationLevel();
+ visitor.setSuppressLeadingBlankLine(true);
IASTDeclaration[] decls = getMembers(compDeclSpec);
if (decls.length > 0) {
@@ -306,8 +304,7 @@ public class DeclSpecWriter extends NodeWriter {
case ICPPASTCompositeTypeSpecifier.k_class:
return CLASS;
default:
- System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$
+ throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
}
@@ -318,8 +315,7 @@ public class DeclSpecWriter extends NodeWriter {
case IASTCompositeTypeSpecifier.k_union:
return UNION;
default:
- System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$
+ throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
}
@@ -368,7 +364,7 @@ public class DeclSpecWriter extends NodeWriter {
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
if (simpDeclSpec.isSigned()) {
scribe.printStringSpace(SIGNED);
- } else if (simpDeclSpec.isUnsigned()){
+ } else if (simpDeclSpec.isUnsigned()) {
scribe.printStringSpace(UNSIGNED);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
index 6976f5fcf6..41ed66fc64 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java
@@ -9,10 +9,10 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -47,7 +47,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @see IASTDeclaration
* @author Emanuel Graf IFS
*/
-public class DeclarationWriter extends NodeWriter{
+public class DeclarationWriter extends NodeWriter {
private static final String ASM_END = ")"; //$NON-NLS-1$
private static final String ASM_START = "asm("; //$NON-NLS-1$
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
@@ -57,7 +57,7 @@ public class DeclarationWriter extends NodeWriter{
private static final String USING = "using "; //$NON-NLS-1$
private boolean printSemicolon;
- public DeclarationWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@@ -72,6 +72,7 @@ public class DeclarationWriter extends NodeWriter{
writeASMDeclatation((IASTASMDeclaration) declaration);
} else if (declaration instanceof IASTFunctionDefinition) {
writeFunctionDefinition((IASTFunctionDefinition) declaration);
+ addNewLine = false;
} else if (declaration instanceof IASTProblemDeclaration) {
throw new ProblemRuntimeException((IASTProblemDeclaration) declaration);
} else if (declaration instanceof IASTSimpleDeclaration) {
@@ -98,17 +99,17 @@ public class DeclarationWriter extends NodeWriter{
}
if (hasTrailingComments(declaration)) {
- writeTrailingComments(declaration, addNewLine);
- } else if (addNewLine) {
+ writeTrailingComments(declaration, false);
+ }
+ if (addNewLine) {
scribe.newLine();
}
if (hasFreestandingComments(declaration)) {
+ if (declaration instanceof IASTFunctionDefinition) {
+ scribe.newLine();
+ }
writeFreeStandingComments(declaration);
}
-
- if (declaration instanceof ICPPASTUsingDirective) {
- scribe.newLine();
- }
}
private void writeVisibilityLabel(ICPPASTVisibilityLabel visiblityLabel) {
@@ -181,17 +182,18 @@ public class DeclarationWriter extends NodeWriter{
if (!hasTrailingComments(namespaceDefinition.getName())) {
scribe.newLine();
}
- scribe.printLBrace();
- scribe.newLine();
+ scribe.print('{');
+ scribe.newLine(2);
writeDeclarationsInNamespace(namespaceDefinition, namespaceDefinition.getDeclarations());
if (hasFreestandingComments(namespaceDefinition)) {
writeFreeStandingComments(namespaceDefinition);
}
- scribe.printRBrace();
+ scribe.newLine();
+ scribe.print('}');
if (hasTrailingComments(namespaceDefinition)) {
writeTrailingComments(namespaceDefinition);
- }else{
+ } else {
scribe.newLine();
}
}
@@ -211,7 +213,7 @@ public class DeclarationWriter extends NodeWriter{
}
private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) {
- scribe.print( EXTERN);
+ scribe.print(EXTERN);
scribe.print(linkageSpecification.getLiteral());
scribe.printSpaces(1);
@@ -266,10 +268,10 @@ public class DeclarationWriter extends NodeWriter{
if (declSpecifier instanceof IASTSimpleDeclSpecifier) {
IASTSimpleDeclSpecifier simDeclSpec = (IASTSimpleDeclSpecifier) declSpecifier;
if (simDeclSpec.getType() != IASTSimpleDeclSpecifier.t_unspecified) {
- scribe.printSpace();
+ visitor.setSpaceNeededBeforeName(true);
}
- }else {
- scribe.printSpace();
+ } else {
+ visitor.setSpaceNeededBeforeName(true);
}
IASTDeclarator declarator = ASTQueries.findOutermostDeclarator(funcDef.getDeclarator());
declarator.accept(visitor);
@@ -325,10 +327,16 @@ public class DeclarationWriter extends NodeWriter{
}
if (decls.length > 0) {
- if (!noSpace) {
- scribe.printSpace();
+ if (decls.length == 1) {
+ if (!noSpace)
+ visitor.setSpaceNeededBeforeName(true);
+ decls[0].accept(visitor);
+ } else {
+ if (!noSpace) {
+ scribe.printSpace();
+ }
+ writeNodeList(decls);
}
- writeNodeList(decls);
}
printSemicolon();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
index 219af0c80e..4a9a8af385 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
@@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -40,14 +39,12 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf IFS
*/
public class DeclaratorWriter extends NodeWriter {
- private static final String AMPERSAND_SPACE = "& "; //$NON-NLS-1$
- private static final String AMPERSAND_AMPERSAND_SPACE = "&& "; //$NON-NLS-1$
- private static final String STAR_SPACE = "* "; //$NON-NLS-1$
+ private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
private static final String MUTABLE = "mutable"; //$NON-NLS-1$
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
- public DeclaratorWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@@ -63,7 +60,8 @@ public class DeclaratorWriter extends NodeWriter {
} else {
writeDefaultDeclarator(declarator);
}
-
+
+ visitor.setSpaceNeededBeforeName(false);
if (hasTrailingComments(declarator)) {
writeTrailingComments(declarator, false);
}
@@ -119,6 +117,10 @@ public class DeclaratorWriter extends NodeWriter {
private void writeNestedDeclarator(IASTDeclarator funcDec) {
IASTDeclarator nestedDeclarator = funcDec.getNestedDeclarator();
if (nestedDeclarator != null) {
+ if (visitor.isSpaceNeededBeforeName()) {
+ scribe.printSpace();
+ visitor.setSpaceNeededBeforeName(false);
+ }
scribe.print('(');
nestedDeclarator.accept(visitor);
scribe.print(')');
@@ -160,10 +162,10 @@ public class DeclaratorWriter extends NodeWriter {
}
}
- protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paraDecls) {
- writeNodeList(paraDecls);
+ protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paramDecls) {
+ writeNodeList(paramDecls);
if (funcDec.takesVarArgs()) {
- if (paraDecls.length > 0) {
+ if (paramDecls.length > 0) {
scribe.print(COMMA_SPACE);
}
scribe.print(VAR_ARGS);
@@ -175,7 +177,7 @@ public class DeclaratorWriter extends NodeWriter {
ICPPASTPointerToMember pointerToMemberOp = (ICPPASTPointerToMember) operator;
if (pointerToMemberOp.getName() != null) {
pointerToMemberOp.getName().accept(visitor);
- scribe.print(STAR_SPACE);
+ scribe.print('*');
}
} else {
scribe.print('*');
@@ -198,9 +200,9 @@ public class DeclaratorWriter extends NodeWriter {
writePointer(pointOp);
} else if (operator instanceof ICPPASTReferenceOperator) {
if (((ICPPASTReferenceOperator) operator).isRValueReference()) {
- scribe.print(AMPERSAND_AMPERSAND_SPACE);
+ scribe.print(AMPERSAND_AMPERSAND);
} else {
- scribe.print(AMPERSAND_SPACE);
+ scribe.print('&');
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
index 8676cae026..150f6c7454 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
@@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
@@ -115,7 +114,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String THIS = "this"; //$NON-NLS-1$
private final MacroExpansionHandler macroHandler;
- public ExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
+ public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.macroHandler = macroHandler;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
index 37aaff78c0..7adc8fdce8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
@@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
@@ -36,7 +35,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
*/
public class InitializerWriter extends NodeWriter{
- public InitializerWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public InitializerWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java
index c5c2a05f1a..941931511c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java
@@ -7,11 +7,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
+ * Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -36,7 +35,7 @@ public class NameWriter extends NodeWriter {
* @param scribe
* @param visitor
*/
- public NameWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public NameWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@@ -45,7 +44,7 @@ public class NameWriter extends NodeWriter {
writeTempalteId((ICPPASTTemplateId) name);
} else if (name instanceof ICPPASTConversionName) {
scribe.print(OPERATOR);
- ((ICPPASTConversionName)name).getTypeId().accept(visitor);
+ ((ICPPASTConversionName) name).getTypeId().accept(visitor);
} else if (name instanceof ICPPASTQualifiedName){
writeQualifiedName((ICPPASTQualifiedName) name);
} else {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
index 5c2b384974..627e8158a5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import java.util.ArrayList;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCopyLocation;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -28,7 +27,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
*/
public class NodeWriter {
protected Scribe scribe;
- protected ASTVisitor visitor;
+ protected ASTWriterVisitor visitor;
protected NodeCommentMap commentMap;
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
protected static final String EQUALS = " = "; //$NON-NLS-1$
@@ -61,7 +60,7 @@ public class NodeWriter {
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$
- public NodeWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public NodeWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super();
this.scribe = scribe;
this.visitor = visitor;
@@ -89,12 +88,17 @@ public class NodeWriter {
}
protected void writeTrailingComments(IASTNode node, boolean newLine) {
+ boolean first = true;
for (IASTComment comment : getTrailingComments(node)) {
- scribe.printSpace();
- scribe.print(comment.getComment());
- if (newLine) {
+ if (!first) {
scribe.newLine();
}
+ scribe.printSpace();
+ scribe.print(comment.getComment());
+ first = false;
+ }
+ if (newLine) {
+ scribe.newLine();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
index 9751cefd6a..8bc32d8396 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
+ * Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@@ -20,92 +20,93 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
*/
public class Scribe {
private int indentationLevel = 0;
- private int indentationSize = 4; //HSR tcorbat: could be a tab character too - this is not a very elegant solution
+ // Any positive indentation size is good enough since the code is going to be formatted anyway.
+ private int indentationSize = 4;
private StringBuilder buffer = new StringBuilder();
private boolean isAtLineBeginning = true;
private String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
- private String givenIndentation = null;
+ private String givenIndentation;
+
+ private boolean skipLineBreaks;
+ private boolean skipSemicolons;
- private boolean noNewLine = false;
- private boolean noSemicolon = false;
-
public void newLine() {
- if (!noNewLine) {
+ if (!skipLineBreaks) {
isAtLineBeginning = true;
buffer.append(getNewline());
}
}
-
+
private void indent() {
if (givenIndentation != null) {
buffer.append(givenIndentation);
}
printSpaces(indentationLevel * indentationSize);
}
-
+
private void indentIfNewLine() {
if (isAtLineBeginning) {
isAtLineBeginning = false;
indent();
}
}
-
+
private String getNewline() {
return newLine;
}
-
+
public void print(String code) {
indentIfNewLine();
buffer.append(code);
}
-
+
public void println(String code) {
print(code);
newLine();
}
-
+
public void print(String code, String code2) {
print(code);
buffer.append(code2);
}
-
+
public void println(String code, String code2) {
print(code, code2);
newLine();
}
-
+
public void println(String code, char[] code2) {
print(code);
buffer.append(code2);
newLine();
}
-
+
public void printSpaces(int number) {
indentIfNewLine();
for (int i = 0; i < number; ++i) {
printSpace();
}
}
-
+
public void noSemicolon() {
- noSemicolon = true;
+ skipSemicolons = true;
}
-
+
public void printSemicolon() {
- if (!noSemicolon) {
+ if (!skipSemicolons) {
indentIfNewLine();
buffer.append(';');
} else {
- noSemicolon = false;
+ skipSemicolons = false;
}
}
-
+
@Override
public String toString() {
return buffer.toString();
}
-
- public void print (char code) {
+
+ public void print(char code) {
indentIfNewLine();
buffer.append(code);
}
@@ -114,19 +115,19 @@ public class Scribe {
indentIfNewLine();
buffer.append(code);
}
-
+
public void println(char[] code) {
print(code);
newLine();
}
-
+
public void printStringSpace(String code) {
print(code);
printSpace();
}
/**
- * Prints a { to the Buffer an increases the indentation level.
+ * Prints a { to the buffer an increases the indentation level.
*/
public void printLBrace() {
print('{');
@@ -134,31 +135,31 @@ public class Scribe {
}
/**
- * Prints a } to the Buffer an decrease the indentation level.
+ * Prints a } to the buffer an decrease the indentation level.
*/
public void printRBrace() {
--indentationLevel;
print('}');
}
-
+
public void incrementIndentationLevel() {
++indentationLevel;
}
-
+
public void decrementIndentationLevel() {
if (indentationLevel > 0) {
--indentationLevel;
}
}
-
+
protected void noNewLines() {
- noNewLine = true;
+ skipLineBreaks = true;
}
-
+
protected void newLines() {
- noNewLine = false;
+ skipLineBreaks = false;
}
-
+
public void newLine(int i) {
while (i > 0) {
newLine();
@@ -167,7 +168,7 @@ public class Scribe {
}
public void printSpace() {
- buffer.append(' ');
+ buffer.append(' ');
}
public String getGivenIndentation() {
@@ -179,6 +180,6 @@ public class Scribe {
}
public void cleanCache() {
- buffer = new StringBuilder();
+ buffer = new StringBuilder();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
index fbafe9bf15..ac8c6f21f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java
@@ -56,17 +56,17 @@ import org.eclipse.core.resources.IFile;
public class StatementWriter extends NodeWriter {
private static final String DEFAULT = "default:"; //$NON-NLS-1$
private static final String CASE = "case "; //$NON-NLS-1$
- private static final String WHILE = "while("; //$NON-NLS-1$
+ private static final String WHILE = "while ("; //$NON-NLS-1$
private static final String TRY = "try "; //$NON-NLS-1$
- private static final String CATCH = "catch("; //$NON-NLS-1$
+ private static final String CATCH = "catch ("; //$NON-NLS-1$
private static final String RETURN = "return"; //$NON-NLS-1$
private static final String GOTO = "goto "; //$NON-NLS-1$
private static final String CONTINUE = "continue"; //$NON-NLS-1$
private static final String BREAK = "break"; //$NON-NLS-1$
private static final String ELSE = "else"; //$NON-NLS-1$
- private static final String IF = "if("; //$NON-NLS-1$
- private static final String FOR = "for("; //$NON-NLS-1$
- private static final String DO_WHILE = " while("; //$NON-NLS-1$
+ private static final String IF = "if ("; //$NON-NLS-1$
+ private static final String FOR = "for ("; //$NON-NLS-1$
+ private static final String DO_WHILE = " while ("; //$NON-NLS-1$
private static final String DO = "do"; //$NON-NLS-1$
private static final String SWITCH_BRACKET = "switch ("; //$NON-NLS-1$
private boolean compoundNoNewLine = false;
@@ -74,14 +74,15 @@ public class StatementWriter extends NodeWriter {
private boolean decrementIndentationLevelOneMore = false;
private final DeclarationWriter declWriter;
- public StatementWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public StatementWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
declWriter = new DeclarationWriter(scribe, visitor, commentMap);
}
/**
+ * Prints a statement.
*
- * @param statement
+ * @param statement the statement
* @param newLine if true print a newline if statement usually have one.
* @return {@link ASTVisitor#PROCESS_SKIP}
*/
@@ -132,7 +133,7 @@ public class StatementWriter extends NodeWriter {
writeIfStatement((IASTIfStatement) statement);
newLine = false;
} else if (statement instanceof IASTWhileStatement) {
- writeWhileStatement( (IASTWhileStatement) statement );
+ writeWhileStatement((IASTWhileStatement) statement);
newLine = false;
} else if (statement instanceof IASTForStatement) {
writeForStatement((IASTForStatement) statement);
@@ -173,12 +174,12 @@ public class StatementWriter extends NodeWriter {
scribe.printSemicolon();
}
- private void writeForStatement(IASTForStatement forStatment) {
+ private void writeForStatement(IASTForStatement forStatement) {
scribe.noNewLines();
scribe.print(FOR);
- writeStatement(forStatment.getInitializerStatement(),false);
- if (forStatment instanceof ICPPASTForStatement) {
- ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatment;
+ writeStatement(forStatement.getInitializerStatement(),false);
+ if (forStatement instanceof ICPPASTForStatement) {
+ ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatement;
IASTDeclaration cppConditionDeclaration = cppForStatment.getConditionDeclaration();
if (cppConditionDeclaration == null) {
visitNodeIfNotNull(cppForStatment.getConditionExpression());
@@ -187,17 +188,17 @@ public class StatementWriter extends NodeWriter {
cppConditionDeclaration.accept(visitor);
}
} else {
- if (forStatment.getConditionExpression() != null) {
- forStatment.getConditionExpression().accept(visitor);
+ if (forStatement.getConditionExpression() != null) {
+ forStatement.getConditionExpression().accept(visitor);
scribe.printSemicolon();
}
}
- visitNodeIfNotNull(forStatment.getIterationExpression());
+ visitNodeIfNotNull(forStatement.getIterationExpression());
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
- writeBodyStatement(forStatment.getBody(), false);
+ writeBodyStatement(forStatement.getBody(), false);
}
private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
@@ -418,10 +419,9 @@ public class StatementWriter extends NodeWriter {
scribe.newLine();
statement.accept(visitor);
scribe.decrementIndentationLevel();
- scribe.newLine();
}
}
-
+
/**
* Write no new Line after the next Compound-Statement
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java
index f1265c5bbd..64d1167957 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
@@ -35,7 +34,7 @@ public class TemplateParameterWriter extends NodeWriter {
* @param scribe
* @param visitor
*/
- public TemplateParameterWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
+ public TemplateParameterWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}

Back to the top