Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-03-06 15:57:11 -0500
committerSergey Prigogin2011-03-06 15:57:11 -0500
commit0442096272ea3b07a0bff84c35043274c3cc99df (patch)
treeb883099b5859af884d77254ab583d26b82a37f3d /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter
parent0f9084562ec55fa5d27fac360f399048891689ea (diff)
downloadorg.eclipse.cdt-0442096272ea3b07a0bff84c35043274c3cc99df.tar.gz
org.eclipse.cdt-0442096272ea3b07a0bff84c35043274c3cc99df.tar.xz
org.eclipse.cdt-0442096272ea3b07a0bff84c35043274c3cc99df.zip
Removed uses of a deprecated class.
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/ASTWriterVisitor.java57
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java95
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java57
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java21
6 files changed, 95 insertions, 192 deletions
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 cce9745ede..e80ac65408 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
@@ -7,8 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Institute for Software - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
@@ -34,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTLiteralNode;
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>.
*
@@ -42,9 +40,8 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @see MacroExpansionHandler
*
* @author Emanuel Graf IFS
- *
*/
-public class ASTWriterVisitor extends CPPASTVisitor {
+public class ASTWriterVisitor extends ASTVisitor {
protected Scribe scribe = new Scribe();
protected NodeCommentMap commentMap;
@@ -57,42 +54,27 @@ public class ASTWriterVisitor extends CPPASTVisitor {
protected NameWriter nameWriter;
protected TemplateParameterWriter tempParameterWriter;
protected MacroExpansionHandler macroHandler;
+
{
shouldVisitExpressions = true;
-
shouldVisitStatements = true;
-
shouldVisitNames = true;
-
shouldVisitDeclarations = true;
-
shouldVisitDeclSpecifiers = true;
-
shouldVisitDeclarators = true;
-
shouldVisitArrayModifiers= true;
-
shouldVisitInitializers = true;
-
shouldVisitBaseSpecifiers = true;
-
shouldVisitNamespaces = true;
-
shouldVisitTemplateParameters = true;
-
shouldVisitParameterDeclarations = true;
-
shouldVisitTranslationUnit = true;
}
-
-
public ASTWriterVisitor(NodeCommentMap commentMap) {
this("", commentMap); //$NON-NLS-1$
}
-
-
public ASTWriterVisitor(String givenIndentation, NodeCommentMap commentMap) {
super();
scribe.setGivenIndentation(givenIndentation);
@@ -103,14 +85,14 @@ public class ASTWriterVisitor extends CPPASTVisitor {
private void init(NodeCommentMap commentMap) {
macroHandler = new MacroExpansionHandler(scribe);
- statementWriter = new StatementWriter(scribe,this, commentMap);
- declaratorWriter = new DeclaratorWriter(scribe,this, commentMap);
- declarationWriter = new DeclarationWriter(scribe,this, commentMap);
- declSpecWriter = new DeclSpecWriter(scribe,this, commentMap);
- expWriter = new ExpressionWriter(scribe,this, macroHandler, commentMap);
- initializerWriter = new InitializerWriter (scribe,this, commentMap);
+ statementWriter = new StatementWriter(scribe, this, commentMap);
+ declaratorWriter = new DeclaratorWriter(scribe, this, commentMap);
+ declarationWriter = new DeclarationWriter(scribe, this, commentMap);
+ declSpecWriter = new DeclSpecWriter(scribe, this, commentMap);
+ expWriter = new ExpressionWriter(scribe, this, macroHandler, commentMap);
+ initializerWriter = new InitializerWriter (scribe, this, commentMap);
// ppStmtWriter = new PreprocessorStatementWriter(scribe, this, commentMap);
- nameWriter = new NameWriter(scribe,this, commentMap);
+ nameWriter = new NameWriter(scribe, this, commentMap);
tempParameterWriter = new TemplateParameterWriter(scribe, this, commentMap);
}
@@ -148,8 +130,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
@Override
public int visit(IASTDeclSpecifier declSpec) {
writeLeadingComments(declSpec);
@@ -157,8 +137,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
@Override
public int visit(IASTExpression expression) {
writeLeadingComments(expression);
@@ -173,8 +151,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
@Override
public int visit(IASTStatement statement) {
writeLeadingComments(statement);
@@ -187,7 +163,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return statementWriter.writeStatement(statement, true);
}
-
@Override
public int visit(IASTDeclaration declaration) {
writeLeadingComments(declaration);
@@ -197,8 +172,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
@Override
public int visit(IASTDeclarator declarator) {
writeLeadingComments(declarator);
@@ -216,7 +189,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
@Override
public int visit(IASTInitializer initializer) {
writeLeadingComments(initializer);
@@ -226,8 +198,6 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
@Override
public int visit(IASTParameterDeclaration parameterDeclaration) {
writeLeadingComments(parameterDeclaration);
@@ -243,13 +213,10 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
-
protected IASTName getParameterName(IASTDeclarator declarator) {
return declarator.getName();
}
-
protected IASTDeclarator getParameterDeclarator(
IASTParameterDeclaration parameterDeclaration) {
return parameterDeclaration.getDeclarator();
@@ -273,10 +240,8 @@ public class ASTWriterVisitor extends CPPASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
-
public void cleanCache() {
scribe.cleanCache();
macroHandler.reset();
}
-
}
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 1b0666f195..d643b8a317 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
@@ -7,10 +7,11 @@
* 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.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@@ -26,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
@@ -36,16 +36,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
-
/**
- *
* Generates source code of declaration specifier nodes. The actual string operations are delegated
* to the <code>Scribe</code> class.
*
* @see Scribe
* @see IASTDeclSpecifier
* @author Emanuel Graf IFS
- *
*/
public class DeclSpecWriter extends NodeWriter {
private static final String MUTABLE = "mutable "; //$NON-NLS-1$
@@ -65,9 +62,8 @@ 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, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public DeclSpecWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
-
}
protected void writeDelcSpec(IASTDeclSpecifier declSpec) {
@@ -75,7 +71,7 @@ public class DeclSpecWriter extends NodeWriter {
writeDeclSpec(declSpec);
if (declSpec instanceof ICPPASTDeclSpecifier) {
writeCPPDeclSpec((ICPPASTDeclSpecifier) declSpec);
- }else if (declSpec instanceof ICASTDeclSpecifier) {
+ } else if (declSpec instanceof ICASTDeclSpecifier) {
writeCDeclSpec((ICASTDeclSpecifier) declSpec);
}
}
@@ -88,9 +84,7 @@ public class DeclSpecWriter extends NodeWriter {
return getASTSimpleDecSpecifier(simpDeclSpec.getType(), false);
}
-
private String getASTSimpleDecSpecifier(int type, boolean isCpp) {
-
switch (type) {
case IASTSimpleDeclSpecifier.t_unspecified:
return ""; //$NON-NLS-1$
@@ -140,25 +134,25 @@ public class DeclSpecWriter extends NodeWriter {
}
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
- if(cDeclSpec.isRestrict()) {
+ if (cDeclSpec.isRestrict()) {
scribe.print(RESTRICT);
}
if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) {
writeCompositeTypeSpecifier((ICASTCompositeTypeSpecifier) cDeclSpec);
- }else if (cDeclSpec instanceof ICASTEnumerationSpecifier) {
+ } else if (cDeclSpec instanceof ICASTEnumerationSpecifier) {
writeEnumSpec((ICASTEnumerationSpecifier) cDeclSpec);
- }else if (cDeclSpec instanceof ICASTElaboratedTypeSpecifier) {
+ } else if (cDeclSpec instanceof ICASTElaboratedTypeSpecifier) {
writeElaboratedTypeSec((ICASTElaboratedTypeSpecifier) cDeclSpec);
- }else if (cDeclSpec instanceof ICASTSimpleDeclSpecifier) {
+ } else if (cDeclSpec instanceof ICASTSimpleDeclSpecifier) {
writeCSimpleDeclSpec((ICASTSimpleDeclSpecifier) cDeclSpec);
- }else if (cDeclSpec instanceof ICASTTypedefNameSpecifier) {
+ } else if (cDeclSpec instanceof ICASTTypedefNameSpecifier) {
writeNamedTypeSpecifier((ICASTTypedefNameSpecifier) cDeclSpec);
}
}
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
- if( namedSpc.isTypename() ){
+ if ( namedSpc.isTypename() ){
scribe.print(TYPENAME);
}
namedSpc.getName().accept(visitor);
@@ -168,15 +162,11 @@ public class DeclSpecWriter extends NodeWriter {
namedSpc.getName().accept(visitor);
}
-
-
private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) {
scribe.print(getElabTypeString(elabType.getKind()));
elabType.getName().accept(visitor);
}
-
-
private String getElabTypeString(int kind) {
switch(kind) {
case IASTElaboratedTypeSpecifier.k_enum:
@@ -194,46 +184,42 @@ public class DeclSpecWriter extends NodeWriter {
}
}
-
-
private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) {
if (cppDelcSpec.isVirtual()) {
scribe.print(VIRTUAL);
}
- if(cppDelcSpec.isExplicit()) {
+ if (cppDelcSpec.isExplicit()) {
scribe.print(EXPLICIT);
}
- if(cppDelcSpec.isFriend()) {
+ if (cppDelcSpec.isFriend()) {
scribe.print(FRIEND);
}
- if(cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
+ if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
scribe.print(MUTABLE);
}
if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) {
writeCompositeTypeSpecifier((ICPPASTCompositeTypeSpecifier) cppDelcSpec);
- }else if (cppDelcSpec instanceof IASTEnumerationSpecifier) {
+ } else if (cppDelcSpec instanceof IASTEnumerationSpecifier) {
writeEnumSpec((IASTEnumerationSpecifier) cppDelcSpec);
- }else if (cppDelcSpec instanceof ICPPASTElaboratedTypeSpecifier) {
+ } else if (cppDelcSpec instanceof ICPPASTElaboratedTypeSpecifier) {
writeElaboratedTypeSec((ICPPASTElaboratedTypeSpecifier) cppDelcSpec);
- }else if (cppDelcSpec instanceof ICPPASTSimpleDeclSpecifier) {
+ } else if (cppDelcSpec instanceof ICPPASTSimpleDeclSpecifier) {
writeCPPSimpleDeclSpec((ICPPASTSimpleDeclSpecifier) cppDelcSpec);
- }else if (cppDelcSpec instanceof ICPPASTNamedTypeSpecifier) {
+ } else if (cppDelcSpec instanceof ICPPASTNamedTypeSpecifier) {
writeNamedTypeSpecifier((ICPPASTNamedTypeSpecifier) cppDelcSpec);
}
}
-
-
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
scribe.print(ENUM);
enumSpec.getName().accept(visitor);
scribe.print('{');
scribe.printSpace();
IASTEnumerator[] enums = enumSpec.getEnumerators();
- for(int i = 0; i< enums.length;++i) {
+ for (int i = 0; i< enums.length;++i) {
writeEnumerator(enums[i]);
- if(i+1< enums.length) {
+ if (i+1< enums.length) {
scribe.print(NodeWriter.COMMA_SPACE);
}
}
@@ -241,20 +227,16 @@ public class DeclSpecWriter extends NodeWriter {
}
-
-
private void writeEnumerator(IASTEnumerator enumerator) {
enumerator.getName().accept(visitor);
IASTExpression value = enumerator.getValue();
- if(value != null) {
+ if (value != null) {
scribe.print(EQUALS);
value.accept(visitor);
}
}
-
-
private void writeCompositeTypeSpecifier(IASTCompositeTypeSpecifier compDeclSpec) {
boolean hasTrailingComments = hasTrailingComments(compDeclSpec.getName());
scribe.printStringSpace(getCPPCompositeTypeString(compDeclSpec.getKey()));
@@ -264,16 +246,16 @@ public class DeclSpecWriter extends NodeWriter {
ICPPASTBaseSpecifier[] baseSpecifiers = cppComp.getBaseSpecifiers();
if (baseSpecifiers.length > 0) {
scribe.print(SPACE_COLON_SPACE);
- for(int i = 0; i < baseSpecifiers.length;++i) {
+ for (int i = 0; i < baseSpecifiers.length;++i) {
writeBaseSpecifiers(baseSpecifiers[i]);
- if(i+1 < baseSpecifiers.length) {
+ if (i+1 < baseSpecifiers.length) {
scribe.print(COMMA_SPACE);
}
}
hasTrailingComments = hasTrailingComments(baseSpecifiers[baseSpecifiers.length-1].getName());
}
}
- if(!hasTrailingComments){
+ if (!hasTrailingComments){
scribe.newLine();
}
scribe.print('{');
@@ -281,19 +263,19 @@ public class DeclSpecWriter extends NodeWriter {
scribe.incrementIndentationLevel();
IASTDeclaration[] decls = getMembers(compDeclSpec);
- if(decls.length > 0) {
+ if (decls.length > 0) {
for (IASTDeclaration declaration : decls) {
declaration.accept(visitor);
}
}
- if(hasFreestandingComments(compDeclSpec)) {
+ if (hasFreestandingComments(compDeclSpec)) {
writeFreeStandingComments(compDeclSpec);
}
scribe.decrementIndentationLevel();
scribe.print('}');
- if(hasTrailingComments(compDeclSpec)) {
+ if (hasTrailingComments(compDeclSpec)) {
writeTrailingComments(compDeclSpec);
}
}
@@ -317,10 +299,8 @@ public class DeclSpecWriter extends NodeWriter {
specifier.getName().accept(visitor);
}
-
-
private String getCPPCompositeTypeString(int key) {
- if(key <= IASTCompositeTypeSpecifier.k_last) {
+ if (key <= IASTCompositeTypeSpecifier.k_last) {
return getCompositeTypeString(key);
}
switch (key) {
@@ -332,8 +312,6 @@ public class DeclSpecWriter extends NodeWriter {
}
}
-
-
private String getCompositeTypeString(int key) {
switch (key) {
case IASTCompositeTypeSpecifier.k_struct:
@@ -346,10 +324,8 @@ public class DeclSpecWriter extends NodeWriter {
}
}
-
-
private void writeDeclSpec(IASTDeclSpecifier declSpec) {
- if(declSpec.isInline()) {
+ if (declSpec.isInline()) {
scribe.print(INLINE);
}
switch(declSpec.getStorageClass()) {
@@ -375,8 +351,6 @@ public class DeclSpecWriter extends NodeWriter {
if (declSpec.isVolatile()) {
scribe.printStringSpace(VOLATILE);
}
-
-
}
private void writeCPPSimpleDeclSpec(ICPPASTSimpleDeclSpecifier simpDeclSpec) {
@@ -393,17 +367,17 @@ public class DeclSpecWriter extends NodeWriter {
}
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
- if(simpDeclSpec.isSigned()) {
+ if (simpDeclSpec.isSigned()) {
scribe.printStringSpace(SIGNED);
- }else if(simpDeclSpec.isUnsigned()){
+ } else if (simpDeclSpec.isUnsigned()){
scribe.printStringSpace(UNSIGNED);
}
- if(simpDeclSpec.isShort()) {
+ if (simpDeclSpec.isShort()) {
scribe.printStringSpace(SHORT);
- }else if(simpDeclSpec.isLong()) {
+ } else if (simpDeclSpec.isLong()) {
scribe.printStringSpace(LONG);
- }else if(simpDeclSpec.isLongLong()) {
+ } else if (simpDeclSpec.isLongLong()) {
scribe.print(LONG_LONG);
}
if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) {
@@ -414,11 +388,8 @@ public class DeclSpecWriter extends NodeWriter {
}
}
-
-
private void writeCSimpleDeclSpec(ICASTSimpleDeclSpecifier simpDeclSpec) {
printQualifiers(simpDeclSpec);
scribe.print(getCSimpleDecSpecifier(simpDeclSpec));
}
-
}
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 c72974ca3d..8676cae026 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
@@ -7,11 +7,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Institute for Software - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
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;
@@ -28,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
@@ -39,11 +39,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
-import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
-
/**
*
* Generates source code of expression nodes. The actual string operations are delegated
@@ -52,10 +50,8 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @see Scribe
* @see IASTExpression
* @author Emanuel Graf IFS
- *
*/
public class ExpressionWriter extends NodeWriter{
-
private static final String VECTORED_DELETE_OP = "[] "; //$NON-NLS-1$
private static final String DELETE = "delete "; //$NON-NLS-1$
private static final String STATIC_CAST_OP = "static_cast<"; //$NON-NLS-1$
@@ -119,7 +115,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String THIS = "this"; //$NON-NLS-1$
private final MacroExpansionHandler macroHandler;
- public ExpressionWriter(Scribe scribe, CPPASTVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
+ public ExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.macroHandler = macroHandler;
}
@@ -137,23 +133,23 @@ public class ExpressionWriter extends NodeWriter{
writeCastExpression((IASTCastExpression) expression);
} else if (expression instanceof ICPPASTNewExpression) {
writeCPPNewExpression((ICPPASTNewExpression) expression);
- }else if (expression instanceof IASTConditionalExpression) {
+ } else if (expression instanceof IASTConditionalExpression) {
writeConditionalExpression((IASTConditionalExpression) expression);
- }else if (expression instanceof IASTArraySubscriptExpression) {
+ } else if (expression instanceof IASTArraySubscriptExpression) {
writeArraySubscriptExpression((IASTArraySubscriptExpression) expression);
- }else if (expression instanceof IASTFieldReference) {
+ } else if (expression instanceof IASTFieldReference) {
writeFieldReference((IASTFieldReference) expression);
- }else if (expression instanceof IASTFunctionCallExpression) {
+ } else if (expression instanceof IASTFunctionCallExpression) {
writeFunctionCallExpression((IASTFunctionCallExpression) expression);
- }else if (expression instanceof IASTExpressionList) {
+ } else if (expression instanceof IASTExpressionList) {
writeExpressionList((IASTExpressionList) expression);
- }else if (expression instanceof IASTProblemExpression) {
+ } else if (expression instanceof IASTProblemExpression) {
throw new ProblemRuntimeException(((IASTProblemExpression) expression));
- }else if (expression instanceof IASTTypeIdExpression) {
+ } else if (expression instanceof IASTTypeIdExpression) {
writeTypeIdExpression((IASTTypeIdExpression) expression);
- }else if (expression instanceof ICPPASTDeleteExpression) {
+ } else if (expression instanceof ICPPASTDeleteExpression) {
writeDeleteExpression((ICPPASTDeleteExpression) expression);
- }else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) {
+ } else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) {
writeSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression) expression);
} else if (expression instanceof ICPPASTLambdaExpression) {
writeLambdaExpression((ICPPASTLambdaExpression) expression);
@@ -161,7 +157,6 @@ public class ExpressionWriter extends NodeWriter{
}
private String getBinaryExpressionOperator(int operator){
-
switch(operator){
case IASTBinaryExpression.op_multiply:
return MULTIPLY_OP;
@@ -235,7 +230,6 @@ public class ExpressionWriter extends NodeWriter{
System.err.println("Unknown unaryExpressionType: " + operator); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown unaryExpressionType: " + operator); //$NON-NLS-1$
}
-
}
private boolean isPrefixExpression(IASTUnaryExpression unExp) {
@@ -339,7 +333,7 @@ public class ExpressionWriter extends NodeWriter{
operand1.accept(visitor);
}
IASTExpression operand2 = binExp.getOperand2();
- if(macroHandler.checkisMacroExpansionNode(operand2, false)&& macroHandler.macroExpansionAlreadyPrinted(operand2)) {
+ if (macroHandler.checkisMacroExpansionNode(operand2, false)&& macroHandler.macroExpansionAlreadyPrinted(operand2)) {
return;
}
scribe.print(getBinaryExpressionOperator(binExp.getOperator()));
@@ -347,7 +341,7 @@ public class ExpressionWriter extends NodeWriter{
}
private void writeCPPNewExpression(ICPPASTNewExpression newExp) {
- if(newExp.isGlobal()) {
+ if (newExp.isGlobal()) {
scribe.print(COLON_COLON);
}
scribe.print(NEW);
@@ -387,11 +381,11 @@ public class ExpressionWriter extends NodeWriter{
}
private void writeUnaryExpression(IASTUnaryExpression unExp) {
- if(isPrefixExpression(unExp )) {
+ if (isPrefixExpression(unExp )) {
scribe.print(getPrefixOperator(unExp));
}
visitNodeIfNotNull(unExp.getOperand());
- if(isPostfixExpression(unExp)) {
+ if (isPostfixExpression(unExp)) {
scribe.print(getPostfixOperator(unExp));
}
}
@@ -422,19 +416,18 @@ public class ExpressionWriter extends NodeWriter{
private void writeFieldReference(IASTFieldReference fieldRef) {
fieldRef.getFieldOwner().accept(visitor);
- if(fieldRef.isPointerDereference()) {
+ if (fieldRef.isPointerDereference()) {
scribe.print(ARROW);
- }else {
+ } else {
scribe.print('.');
}
if (fieldRef instanceof ICPPASTFieldReference) {
ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef;
- if(cppFieldRef.isTemplate()) {
+ if (cppFieldRef.isTemplate()) {
scribe.print(TEMPLATE);
}
}
fieldRef.getFieldName().accept(visitor);
-
}
private void writeFunctionCallExpression(IASTFunctionCallExpression funcCallExp) {
@@ -487,7 +480,6 @@ public class ExpressionWriter extends NodeWriter{
}
private void writeExpressionList(IASTExpressionList expList) {
-
IASTExpression[] expressions = expList.getExpressions();
writeExpressions(expList, expressions);
}
@@ -509,20 +501,20 @@ public class ExpressionWriter extends NodeWriter{
return SIZEOF_OP + "("; //$NON-NLS-1$
case ICPPASTTypeIdExpression.op_typeid:
return TYPEID_OP;
- case IGNUASTTypeIdExpression.op_alignof:
+ case IASTTypeIdExpression.op_alignof:
return ALIGNOF_OP + "("; //$NON-NLS-1$
- case IGNUASTTypeIdExpression.op_typeof:
+ case IASTTypeIdExpression.op_typeof:
return TYPEOF_OP;
}
throw new IllegalArgumentException("Unknown TypeId Type"); //$NON-NLS-1$
}
private void writeDeleteExpression(ICPPASTDeleteExpression delExp) {
- if(delExp.isGlobal()) {
+ if (delExp.isGlobal()) {
scribe.print(COLON_COLON);
}
scribe.print(DELETE);
- if(delExp.isVectored()) {
+ if (delExp.isVectored()) {
scribe.print(VECTORED_DELETE_OP);
}
delExp.getOperand().accept(visitor);
@@ -571,6 +563,5 @@ public class ExpressionWriter extends NodeWriter{
capture.getIdentifier().accept(visitor);
}
}
-
}
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 6f3c8f2d40..37aaff78c0 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
@@ -7,11 +7,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Institute for Software - initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Institute for Software - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
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;
@@ -20,45 +21,40 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
-
/**
- *
* Generates source code of initializer nodes. The actual string operations are delegated
* to the <code>Scribe</code> class.
*
* @see Scribe
* @see IASTInitializer
* @author Emanuel Graf IFS
- *
*/
public class InitializerWriter extends NodeWriter{
- public InitializerWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public InitializerWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
protected void writeInitializer(IASTInitializer initializer) {
if (initializer instanceof IASTEqualsInitializer) {
writeEqualsInitializer((IASTEqualsInitializer) initializer);
- }else if (initializer instanceof IASTInitializerList) {
+ } else if (initializer instanceof IASTInitializerList) {
writeInitializerList((IASTInitializerList) initializer);
- }else if (initializer instanceof ICPPASTConstructorInitializer) {
+ } else if (initializer instanceof ICPPASTConstructorInitializer) {
writeConstructorInitializer((ICPPASTConstructorInitializer) initializer);
- }else if (initializer instanceof ICASTDesignatedInitializer) {
+ } else if (initializer instanceof ICASTDesignatedInitializer) {
writeDesignatedInitializer((ICASTDesignatedInitializer) initializer);
- }else if (initializer instanceof ICPPASTConstructorChainInitializer) {
+ } else if (initializer instanceof ICPPASTConstructorChainInitializer) {
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
}
if (hasTrailingComments(initializer))
writeTrailingComments(initializer, false);
}
-
private void writeEqualsInitializer(IASTEqualsInitializer initializer) {
scribe.print(EQUALS);
@@ -100,16 +96,15 @@ public class InitializerWriter extends NodeWriter{
ICASTFieldDesignator fieldDes = (ICASTFieldDesignator) designator;
scribe.print('.');
fieldDes.getName().accept(visitor);
- }else if (designator instanceof ICASTArrayDesignator) {
+ } else if (designator instanceof ICASTArrayDesignator) {
ICASTArrayDesignator arrDes = (ICASTArrayDesignator) designator;
scribe.print('[');
arrDes.getSubscriptExpression().accept(visitor);
scribe.print(']');
- }else if (designator instanceof IGCCASTArrayRangeDesignator) {
+ } else if (designator instanceof IGCCASTArrayRangeDesignator) {
//IGCCASTArrayRangeDesignator new_name = (IGCCASTArrayRangeDesignator) designator;
//TODO IGCCASTArrayRangeDesignator Bespiel zu parsen bringen
throw new UnsupportedOperationException("Writing of GCC ArrayRangeDesignator is not yet implemented"); //$NON-NLS-1$
}
-
}
}
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 329843ce81..c5c2a05f1a 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
@@ -11,37 +11,32 @@
*******************************************************************************/
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;
-import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
-
/**
- *
* Generates source code of name nodes. The actual string operations are delegated
* to the <code>Scribe</code> class.
*
* @see Scribe
* @see IASTName
* @author Emanuel Graf IFS
- *
*/
public class NameWriter extends NodeWriter {
-
private static final String OPERATOR = "operator "; //$NON-NLS-1$
-
/**
* @param scribe
* @param visitor
*/
- public NameWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public NameWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@@ -57,13 +52,13 @@ public class NameWriter extends NodeWriter {
scribe.print(name.toString());
}
- if(hasTrailingComments(name)) {
+ if (hasTrailingComments(name)) {
writeTrailingComments(name);
}
}
private void writeTempalteId(ICPPASTTemplateId tempId) {
- if(needsTemplateQualifier(tempId)) {
+ if (needsTemplateQualifier(tempId)) {
scribe.print(TEMPLATE);
}
scribe.print(tempId.getTemplateName().toString());
@@ -71,12 +66,12 @@ public class NameWriter extends NodeWriter {
IASTNode[] nodes = tempId.getTemplateArguments();
for (int i = 0; i < nodes.length; ++i) {
nodes[i].accept(visitor);
- if(i + 1 < nodes.length) {
+ if (i + 1 < nodes.length) {
scribe.print(',');
}
}
scribe.print('>');
- if(isNestedTemplateId(tempId)) {
+ if (isNestedTemplateId(tempId)) {
scribe.printSpace();
}
}
@@ -91,18 +86,16 @@ public class NameWriter extends NodeWriter {
private boolean isDependentName(ICPPASTQualifiedName qname, ICPPASTTemplateId tempId) {
IASTName[] names = qname.getNames();
- int i = 0;
- for(;i < names.length; ++i){
- if(names[i] == tempId){
+ for (int i = 0; i < names.length; ++i){
+ if (names[i] == tempId){
return isDependentName(qname, tempId, i);
}
}
return false;
}
- private boolean isDependentName(ICPPASTQualifiedName qname,
- ICPPASTTemplateId tempId, int i) {
- if(i <= 0){
+ private boolean isDependentName(ICPPASTQualifiedName qname, ICPPASTTemplateId tempId, int i) {
+ if (i <= 0){
return false;
}
if (qname.getNames()[i-1] instanceof ICPPASTTemplateId) {
@@ -116,7 +109,7 @@ public class NameWriter extends NodeWriter {
}
private boolean isNestedTemplateId(IASTNode node) {
- while((node = node.getParent()) != null) {
+ while ((node = node.getParent()) != null) {
if (node instanceof ICPPASTTemplateId) {
return true;
}
@@ -124,12 +117,11 @@ public class NameWriter extends NodeWriter {
return false;
}
-
private void writeQualifiedName(ICPPASTQualifiedName qname) {
IASTName[] nodes = qname.getNames();
for (int i = 0; i < nodes.length; ++i) {
nodes[i].accept(visitor);
- if(i + 1 < nodes.length) {
+ if (i + 1 < nodes.length) {
scribe.print(COLON_COLON);
}
}
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 0ac8322479..f1265c5bbd 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,37 +11,31 @@
*******************************************************************************/
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.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
-
/**
- *
* Generates source code of template parameter nodes. The actual string operations are delegated
* to the <code>Scribe</code> class.
*
* @see Scribe
* @see ICPPASTTemplateParameter
* @author Emanuel Graf IFS
- *
*/
public class TemplateParameterWriter extends NodeWriter {
-
private static final String GREATER_THAN_CLASS = "> class"; //$NON-NLS-1$
private static final String TEMPLATE_LESS_THAN = "template <"; //$NON-NLS-1$
-
-
/**
* @param scribe
* @param visitor
*/
- public TemplateParameterWriter(Scribe scribe, CPPASTVisitor visitor, NodeCommentMap commentMap) {
+ public TemplateParameterWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@@ -55,29 +49,24 @@ public class TemplateParameterWriter extends NodeWriter {
}
}
-
private void writeTemplatedTypeTemplateParameter(ICPPASTTemplatedTypeTemplateParameter templated) {
scribe.print(TEMPLATE_LESS_THAN);
-
-
ICPPASTTemplateParameter[] params = templated.getTemplateParameters();
writeNodeList(params);
scribe.print(GREATER_THAN_CLASS);
- if(templated.getName()!=null){
+ if (templated.getName()!=null){
scribe.printSpace();
templated.getName().accept(visitor);
}
- if(templated.getDefaultValue() != null){
+ if (templated.getDefaultValue() != null){
scribe.print(EQUALS);
templated.getDefaultValue().accept(visitor);
}
}
-
-
private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) {
switch (simple.getParameterType()) {
case ICPPASTSimpleTypeTemplateParameter.st_class:
@@ -90,7 +79,7 @@ public class TemplateParameterWriter extends NodeWriter {
visitNodeIfNotNull(simple.getName());
- if(simple.getDefaultType() != null){
+ if (simple.getDefaultType() != null){
scribe.print(EQUALS);
simple.getDefaultType().accept(visitor);
}

Back to the top