Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionList.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java76
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java87
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java3
6 files changed, 69 insertions, 134 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
index 0e33b92c033..2376a8918fc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
@@ -60,7 +60,7 @@ public class CBasicType implements ICBasicType, ISerializableType {
private static Kind getKind(ICASTSimpleDeclSpecifier sds) {
switch(sds.getType()) {
- case ICASTSimpleDeclSpecifier.t_Bool:
+ case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
case IASTSimpleDeclSpecifier.t_char:
return Kind.eChar;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionList.java
index 577b00ba3ca..e81d93f125b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionList.java
@@ -145,9 +145,9 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
return overloads = NO_FUNCTIONS;
ASTNodeProperty prop = getPropertyInParent();
- if (prop == IASTFunctionCallExpression.PARAMETERS ||
+ if (prop == IASTFunctionCallExpression.ARGUMENT ||
prop == ICPPASTConstructorChainInitializer.INITIALIZER ||
- prop == ICPPASTConstructorInitializer.EXPRESSION ||
+ prop == ICPPASTConstructorInitializer.ARGUMENT ||
prop == ICPPASTNewExpression.NEW_INITIALIZER)
return overloads = NO_FUNCTIONS;
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 c4456482648..1e7d0fc6e7a 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
@@ -80,62 +80,42 @@ public class DeclSpecWriter extends NodeWriter {
}
private String getCPPSimpleDecSpecifier(ICPPASTSimpleDeclSpecifier simpDeclSpec) {
- int type = simpDeclSpec.getType();
- if(type <= IASTSimpleDeclSpecifier.t_last) {
- return getASTSimpleDecSpecifier(type);
- }
- switch (type) {
- case ICPPASTSimpleDeclSpecifier.t_bool:
- return CPP_BOOL;
- case ICPPASTSimpleDeclSpecifier.t_wchar_t:
- return WCHAR_T;
- default:
- System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
- }
+ return getASTSimpleDecSpecifier(simpDeclSpec.getType(), true);
}
private String getCSimpleDecSpecifier(ICASTSimpleDeclSpecifier simpDeclSpec) {
- int type = simpDeclSpec.getType();
- if(type <= IASTSimpleDeclSpecifier.t_last) {
- return getASTSimpleDecSpecifier(type);
- }
- switch (type) {
- case ICASTSimpleDeclSpecifier.t_Bool:
- return _BOOL;
- default:
- System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
- }
+ return getASTSimpleDecSpecifier(simpDeclSpec.getType(), false);
}
- private String getASTSimpleDecSpecifier(int type) {
-
- if(type <= IASTSimpleDeclSpecifier.t_last) {
- switch (type) {
- case IASTSimpleDeclSpecifier.t_unspecified:
- return ""; //$NON-NLS-1$
- case IASTSimpleDeclSpecifier.t_void:
- return VOID;
- case IASTSimpleDeclSpecifier.t_char:
- return CHAR;
- case IASTSimpleDeclSpecifier.t_int:
- return INT;
+ private String getASTSimpleDecSpecifier(int type, boolean isCpp) {
- case IASTSimpleDeclSpecifier.t_float:
- return FLOAT;
-
- case IASTSimpleDeclSpecifier.t_double:
- return DOUBLE;
- default:
- System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
-
- }
+ switch (type) {
+ case IASTSimpleDeclSpecifier.t_unspecified:
+ return ""; //$NON-NLS-1$
+ case IASTSimpleDeclSpecifier.t_void:
+ return VOID;
+ case IASTSimpleDeclSpecifier.t_char:
+ return CHAR;
+ case IASTSimpleDeclSpecifier.t_int:
+ return INT;
+
+ case IASTSimpleDeclSpecifier.t_float:
+ return FLOAT;
+ case IASTSimpleDeclSpecifier.t_double:
+ return DOUBLE;
+
+ case IASTSimpleDeclSpecifier.t_bool:
+ return isCpp ? CPP_BOOL : _BOOL;
+
+ case IASTSimpleDeclSpecifier.t_wchar_t:
+ if (isCpp)
+ return WCHAR_T;
+ break;
}
+
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
+ throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
}
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
@@ -205,7 +185,7 @@ public class DeclSpecWriter extends NodeWriter {
if(cppDelcSpec.isFriend()) {
scribe.print(FRIEND);
}
- if(cppDelcSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
+ if(cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
scribe.print(MUTABLE);
}
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 aaf65e1914c..a04d3310ade 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
@@ -21,6 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
@@ -34,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
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.ICPPASTTypenameExpression;
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;
@@ -149,11 +150,7 @@ public class ExpressionWriter extends NodeWriter{
writeDeleteExpression((ICPPASTDeleteExpression) expression);
}else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) {
writeSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression) expression);
- }else if (expression instanceof ICPPASTTypenameExpression) {
- //No example found for this Node
- throw new UnsupportedOperationException("You found a example for a TypenameExpression: " + expression.getRawSignature()); //$NON-NLS-1$
}
-
}
private String getBinaryExpressionOperator(int operator){
@@ -252,7 +249,6 @@ public class ExpressionWriter extends NodeWriter{
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
case IASTUnaryExpression.op_alignOf:
- case IASTUnaryExpression.op_typeof:
return true;
default:
@@ -268,7 +264,6 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid:
case IASTUnaryExpression.op_alignOf:
- case IASTUnaryExpression.op_typeof:
return true;
default:
@@ -307,8 +302,6 @@ public class ExpressionWriter extends NodeWriter{
return TYPEID_OP;
case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP;
- case IASTUnaryExpression.op_typeof:
- return TYPEOF_OP;
default:
System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
@@ -326,7 +319,6 @@ public class ExpressionWriter extends NodeWriter{
return CLOSING_BRACKET_OP;
case IASTUnaryExpression.op_bracketedPrimary:
case IASTUnaryExpression.op_alignOf:
- case IASTUnaryExpression.op_typeof:
return CLOSING_BRACKET_OP;
default:
System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
@@ -352,25 +344,36 @@ public class ExpressionWriter extends NodeWriter{
scribe.print(COLON_COLON);
}
scribe.print(NEW);
- IASTExpression placement = newExp.getNewPlacement();
- visitNodeIfNotNull(placement);
+ IASTInitializerClause[] placement = newExp.getPlacementArguments();
+ if (placement != null) {
+ writeArgumentList(placement);
+ }
IASTTypeId typeId = newExp.getTypeId();
visitNodeIfNotNull(typeId);
- IASTExpression initExp= getNewInitializer(newExp);
+ IASTInitializer initExp= getNewInitializer(newExp);
if (initExp != null) {
- scribe.print('(');
initExp.accept(visitor);
- scribe.print(')');
}
}
- protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
- return newExp.getNewInitializer();
+ protected IASTInitializer getNewInitializer(ICPPASTNewExpression newExp) {
+ return newExp.getInitializer();
+ }
+
+ private void writeArgumentList(IASTInitializerClause[] args) {
+ scribe.print(OPEN_BRACKET_OP);
+ boolean needComma= false;
+ for (IASTInitializerClause arg : args) {
+ if (needComma) {
+ scribe.print(COMMA_SPACE);
+ }
+ arg.accept(visitor);
+ needComma= true;
+ }
+ scribe.print(CLOSING_BRACKET_OP);
}
-
-
private void writeLiteralExpression(IASTLiteralExpression litExp) {
scribe.print(litExp.toString());
@@ -429,11 +432,7 @@ public class ExpressionWriter extends NodeWriter{
private void writeFunctionCallExpression(IASTFunctionCallExpression funcCallExp) {
funcCallExp.getFunctionNameExpression().accept(visitor);
- scribe.print('(');
- IASTExpression parameterExpression = funcCallExp.getParameterExpression();
- visitNodeIfNotNull(parameterExpression);
- scribe.print(')');
-
+ writeArgumentList(funcCallExp.getArguments());
}
private void writeCastExpression(IASTCastExpression castExp) {
@@ -523,44 +522,8 @@ public class ExpressionWriter extends NodeWriter{
}
private void writeSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression simpTypeCtorExp) {
- scribe.print(getSimpleTypeString(simpTypeCtorExp.getSimpleType()));
- scribe.print('(');
- IASTExpression initalizer = simpTypeCtorExp.getInitialValue();
- visitNodeIfNotNull(initalizer);
- scribe.print(')');
- }
-
- private String getSimpleTypeString(int typeId) {
- switch (typeId) {
-
- case ICPPASTSimpleTypeConstructorExpression.t_void:
- return VOID;
- case ICPPASTSimpleTypeConstructorExpression.t_char:
- return CHAR;
- case ICPPASTSimpleTypeConstructorExpression.t_int:
- return INT;
- case ICPPASTSimpleTypeConstructorExpression.t_float:
- return FLOAT;
- case ICPPASTSimpleTypeConstructorExpression.t_double:
- return DOUBLE;
- case ICPPASTSimpleTypeConstructorExpression.t_bool:
- return CPP_BOOL;
- case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
- return WCHAR_T;
- case ICPPASTSimpleTypeConstructorExpression.t_short:
- return SHORT;
- case ICPPASTSimpleTypeConstructorExpression.t_long:
- return LONG;
- case ICPPASTSimpleTypeConstructorExpression.t_signed:
- return SIGNED;
- case ICPPASTSimpleTypeConstructorExpression.t_unsigned :
- return UNSIGNED;
-
- default:
- System.err.println("Unknown simpleTypeId: " + typeId); //$NON-NLS-1$
- throw new IllegalArgumentException("Unknown simpleTypeId: " + typeId); //$NON-NLS-1$
- }
+ simpTypeCtorExp.getDeclSpecifier().accept(visitor);
+ visitNodeIfNotNull(simpTypeCtorExp.getInitializer());
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java
index 7a5fb5c5459..fef221f6ea6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java
@@ -43,34 +43,29 @@ public class ModifiedASTExpressionWriter extends ExpressionWriter {
}
@Override
- protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
-
-
- IASTExpression initializer = newExp.getNewInitializer();
-
- if(initializer != null){
- for(ASTModification childModification : modificationHelper.modificationsForNode(initializer)){
- switch(childModification.getKind()){
+ protected IASTInitializer getNewInitializer(ICPPASTNewExpression newExp) {
+ IASTInitializer initializer = newExp.getInitializer();
+ if (initializer != null) {
+ for (ASTModification childModification : modificationHelper.modificationsForNode(initializer)) {
+ switch (childModification.getKind()) {
case REPLACE:
- if(childModification.getNewNode() instanceof IASTInitializer){
- return (IASTExpression)childModification.getNewNode();
+ if (childModification.getNewNode() instanceof IASTInitializer) {
+ return (IASTInitializer) childModification.getNewNode();
}
break;
case INSERT_BEFORE:
throw new UnhandledASTModificationException(childModification);
-
+
case APPEND_CHILD:
throw new UnhandledASTModificationException(childModification);
}
}
- }
- else
- {
- for(ASTModification parentModification : modificationHelper.modificationsForNode(newExp)){
- if(parentModification.getKind() == ModificationKind.APPEND_CHILD){
+ } else {
+ for (ASTModification parentModification : modificationHelper.modificationsForNode(newExp)) {
+ if (parentModification.getKind() == ModificationKind.APPEND_CHILD) {
IASTNode newNode = parentModification.getNewNode();
- if(newNode instanceof IASTInitializer){
- return (IASTExpression) newNode;
+ if (newNode instanceof IASTInitializer) {
+ return (IASTInitializer) newNode;
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
index 6128784898a..8a045cdc62c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/commenthandler/NodeCommenter.java
@@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLinkageSpecification;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.core.resources.IFile;
@@ -223,8 +222,6 @@ public class NodeCommenter {
return true;
}else if(node instanceof CPPASTLinkageSpecification) {
return true;
- }else if(node instanceof GPPASTExplicitTemplateInstantiation) {
- return true;
}else if(node instanceof CPPASTExplicitTemplateInstantiation) {
return true;
}

Back to the top