diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java new file mode 100644 index 00000000000..d085efdb147 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ASTComparer.java @@ -0,0 +1,118 @@ +package org.eclipse.cdt.core.parser.tests; + +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import junit.framework.Assert; +import junit.framework.AssertionFailedError; + +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; + +public class ASTComparer extends Assert { + + private static Set methodsToIgnore = new HashSet(Arrays.asList( + // prevent infinite recursion + "getParent", + "getTranslationUnit", + "getLastName", + // original is usually frozen but copy must not be + "isFrozen", + // these methods are problematic + "getChildren", + "getProblem", + "getContainingFilename", + // ignore preprocessor nodes + "getMacroDefinitions", + "getBuiltinMacroDefinitions", + "getIncludeDirectives", + "getAllPreprocessorStatements", + "getMacroExpansions", + "getPreprocessorProblems", + "getComments" + )); + + + public static void assertCopy(IASTNode node1, IASTNode node2) { + try { + assertCopy(node1, node2, 0); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + + private static void assertCopy(IASTNode node1, IASTNode node2, int n) throws Exception { + if(node1 == null && node2 == null) + return; + assertNotNull(node1); + assertNotNull(node2); + assertFalse(node1 == node2); // must be distinct copy + + Class klass1 = node1.getClass(); + Class klass2 = node2.getClass(); + assertTrue(klass1.equals(klass2)); // nodes must be the same concrete type + //System.out.println(spaces(n) + klass1.getSimpleName()); + + BeanInfo beanInfo = Introspector.getBeanInfo(klass1); + + for(PropertyDescriptor property : beanInfo.getPropertyDescriptors()) { + Method getter = property.getReadMethod(); + if(getter == null) + continue; + if(methodsToIgnore.contains(getter.getName())) + continue; + + try { + Class returnType = getter.getReturnType(); + + if(IASTNode.class.isAssignableFrom(returnType)) { + //System.out.println(spaces(n) + "Testing1: " + getter.getName()); + IASTNode result1 = (IASTNode) getter.invoke(node1); + IASTNode result2 = (IASTNode) getter.invoke(node2); + assertCopy(result1, result2, n+1); // members must be same + } + else if(returnType.isArray() && IASTNode.class.isAssignableFrom(returnType.getComponentType())) { + //System.out.println(spaces(n) + "Testing2: " + getter.getName()); + IASTNode[] result1 = (IASTNode[]) getter.invoke(node1); + IASTNode[] result2 = (IASTNode[]) getter.invoke(node2); + if(result1 == null && result2 == null) + continue; + assertNotNull(result1); + assertNotNull(result2); + assertEquals(result1.length, result2.length); + for(int i = 0; i < result1.length; i++) + assertCopy(result1[i], result2[i], n+1); + } + else if((returnType.isPrimitive() || returnType.equals(String.class)) && !returnType.equals(Void.class)) { + //System.out.println(spaces(n) + "Testing3: " + getter.getName()); + Object result1 = getter.invoke(node1); + Object result2 = getter.invoke(node2); + assertEquals(result1, result2); + } + + } catch(AssertionFailedError e) { + System.out.printf("Failure when calling %s.%s() @(%d,%d)\n", + node1.getClass().getSimpleName(), + getter.getName(), + ((ASTNode)node1).getOffset(), + ((ASTNode)node1).getLength()); + throw e; + } + } + + } + + +// private static String spaces(int n) { +// char[] spaces = new char[n*2]; +// Arrays.fill(spaces, ' '); +// return new String(spaces); +// } + +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index 1ef95826943..8aaf71d01ab 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -70,6 +71,7 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; +import org.eclipse.cdt.core.parser.tests.ASTComparer; import org.eclipse.cdt.core.parser.tests.scanner.FileCodeReaderFactory; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; @@ -141,6 +143,8 @@ public class AST2BaseTest extends BaseTestCase { parser.setSkipTrivialExpressionsInAggregateInitializers(true); IASTTranslationUnit tu = parser.parse(); + assertTrue(tu.isFrozen()); + validateCopy(tu); if (parser.encounteredError() && expectNoProblems) throw new ParserException("FAILURE"); //$NON-NLS-1$ @@ -260,6 +264,14 @@ public class AST2BaseTest extends BaseTestCase { return s.getExpression(); } + protected T validateCopy(T tu) { + IASTNode copy = tu.copy(); + assertFalse(copy.isFrozen()); + ASTComparer.assertCopy(tu, copy); + return (T) copy; + } + + static protected class CNameCollector extends CASTVisitor { { shouldVisitNames = true; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 06eaaf0990f..b2ffeef46a5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -115,6 +115,8 @@ import org.eclipse.cdt.internal.core.parser.ParserException; */ public class AST2Tests extends AST2BaseTest { + private static final int NUM_TESTS = 3; + public static TestSuite suite() { return suite(AST2Tests.class); } @@ -127,6 +129,8 @@ public class AST2Tests extends AST2BaseTest { super(name); } + + protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception { return parseAndCheckBindings(code, ParserLanguage.C); } @@ -181,136 +185,141 @@ public class AST2Tests extends AST2BaseTest { // } public void testBasicFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IScope globalScope = tu.getScope(); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IScope globalScope = tu.getScope(); + + IASTDeclaration[] declarations = tu.getDeclarations(); + + // int x + IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) declarations[0]; + IASTSimpleDeclSpecifier declspec_x = (IASTSimpleDeclSpecifier) decl_x + .getDeclSpecifier(); + assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_x.getType()); + IASTDeclarator declor_x = decl_x.getDeclarators()[0]; + IASTName name_x = declor_x.getName(); + assertEquals("x", name_x.toString()); //$NON-NLS-1$ + + // function - void f() + IASTFunctionDefinition funcdef_f = (IASTFunctionDefinition) declarations[1]; + IASTSimpleDeclSpecifier declspec_f = (IASTSimpleDeclSpecifier) funcdef_f + .getDeclSpecifier(); + assertEquals(IASTSimpleDeclSpecifier.t_void, declspec_f.getType()); + IASTFunctionDeclarator declor_f = funcdef_f.getDeclarator(); + IASTName name_f = declor_f.getName(); + assertEquals("f", name_f.toString()); //$NON-NLS-1$ + + // parameter - int y + assertTrue(declor_f instanceof IASTStandardFunctionDeclarator); + IASTParameterDeclaration decl_y = ((IASTStandardFunctionDeclarator) declor_f) + .getParameters()[0]; + IASTSimpleDeclSpecifier declspec_y = (IASTSimpleDeclSpecifier) decl_y + .getDeclSpecifier(); + assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_y.getType()); + IASTDeclarator declor_y = decl_y.getDeclarator(); + IASTName name_y = declor_y.getName(); + assertEquals("y", name_y.toString()); //$NON-NLS-1$ + + // int z + IASTCompoundStatement body_f = (IASTCompoundStatement) funcdef_f + .getBody(); + IASTDeclarationStatement declstmt_z = (IASTDeclarationStatement) body_f + .getStatements()[0]; + IASTSimpleDeclaration decl_z = (IASTSimpleDeclaration) declstmt_z + .getDeclaration(); + IASTSimpleDeclSpecifier declspec_z = (IASTSimpleDeclSpecifier) decl_z + .getDeclSpecifier(); + assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_z.getType()); + IASTDeclarator declor_z = decl_z.getDeclarators()[0]; + IASTName name_z = declor_z.getName(); + assertEquals("z", name_z.toString()); //$NON-NLS-1$ + + // = x + y + IASTInitializerExpression initializer = (IASTInitializerExpression) declor_z + .getInitializer(); + IASTBinaryExpression init_z = (IASTBinaryExpression) initializer + .getExpression(); + assertEquals(IASTBinaryExpression.op_plus, init_z.getOperator()); + IASTIdExpression ref_x = (IASTIdExpression) init_z.getOperand1(); + IASTName name_ref_x = ref_x.getName(); + assertEquals("x", name_ref_x.toString()); //$NON-NLS-1$ + + IASTIdExpression ref_y = (IASTIdExpression) init_z.getOperand2(); + IASTName name_ref_y = ref_y.getName(); + assertEquals("y", name_ref_y.toString()); //$NON-NLS-1$ + + // BINDINGS + // resolve the binding to get the variable object + IVariable var_x = (IVariable) name_x.resolveBinding(); + assertEquals(globalScope, var_x.getScope()); + IFunction func_f = (IFunction) name_f.resolveBinding(); + assertEquals(globalScope, func_f.getScope()); + IParameter var_y = (IParameter) name_y.resolveBinding(); + assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(), + var_y.getScope()); + + IVariable var_z = (IVariable) name_z.resolveBinding(); + assertEquals(((ICFunctionScope) func_f.getFunctionScope()) + .getBodyScope(), var_z.getScope()); + + // make sure the variable referenced is the same one we declared above + assertEquals(var_x, name_ref_x.resolveBinding()); + assertEquals(var_y, name_ref_y.resolveBinding()); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_x.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + decls = tu.getDeclarationsInAST(name_f.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_f); + + decls = tu.getDeclarationsInAST(name_y.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_y); + + decls = tu.getDeclarationsInAST(name_z.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_z); + + decls = tu.getDeclarationsInAST(name_ref_x.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + decls = tu.getDeclarationsInAST(name_ref_y.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_y); - IASTDeclaration[] declarations = tu.getDeclarations(); - - // int x - IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) declarations[0]; - IASTSimpleDeclSpecifier declspec_x = (IASTSimpleDeclSpecifier) decl_x - .getDeclSpecifier(); - assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_x.getType()); - IASTDeclarator declor_x = decl_x.getDeclarators()[0]; - IASTName name_x = declor_x.getName(); - assertEquals("x", name_x.toString()); //$NON-NLS-1$ - - // function - void f() - IASTFunctionDefinition funcdef_f = (IASTFunctionDefinition) declarations[1]; - IASTSimpleDeclSpecifier declspec_f = (IASTSimpleDeclSpecifier) funcdef_f - .getDeclSpecifier(); - assertEquals(IASTSimpleDeclSpecifier.t_void, declspec_f.getType()); - IASTFunctionDeclarator declor_f = funcdef_f.getDeclarator(); - IASTName name_f = declor_f.getName(); - assertEquals("f", name_f.toString()); //$NON-NLS-1$ - - // parameter - int y - assertTrue(declor_f instanceof IASTStandardFunctionDeclarator); - IASTParameterDeclaration decl_y = ((IASTStandardFunctionDeclarator) declor_f) - .getParameters()[0]; - IASTSimpleDeclSpecifier declspec_y = (IASTSimpleDeclSpecifier) decl_y - .getDeclSpecifier(); - assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_y.getType()); - IASTDeclarator declor_y = decl_y.getDeclarator(); - IASTName name_y = declor_y.getName(); - assertEquals("y", name_y.toString()); //$NON-NLS-1$ - - // int z - IASTCompoundStatement body_f = (IASTCompoundStatement) funcdef_f - .getBody(); - IASTDeclarationStatement declstmt_z = (IASTDeclarationStatement) body_f - .getStatements()[0]; - IASTSimpleDeclaration decl_z = (IASTSimpleDeclaration) declstmt_z - .getDeclaration(); - IASTSimpleDeclSpecifier declspec_z = (IASTSimpleDeclSpecifier) decl_z - .getDeclSpecifier(); - assertEquals(IASTSimpleDeclSpecifier.t_int, declspec_z.getType()); - IASTDeclarator declor_z = decl_z.getDeclarators()[0]; - IASTName name_z = declor_z.getName(); - assertEquals("z", name_z.toString()); //$NON-NLS-1$ - - // = x + y - IASTInitializerExpression initializer = (IASTInitializerExpression) declor_z - .getInitializer(); - IASTBinaryExpression init_z = (IASTBinaryExpression) initializer - .getExpression(); - assertEquals(IASTBinaryExpression.op_plus, init_z.getOperator()); - IASTIdExpression ref_x = (IASTIdExpression) init_z.getOperand1(); - IASTName name_ref_x = ref_x.getName(); - assertEquals("x", name_ref_x.toString()); //$NON-NLS-1$ - - IASTIdExpression ref_y = (IASTIdExpression) init_z.getOperand2(); - IASTName name_ref_y = ref_y.getName(); - assertEquals("y", name_ref_y.toString()); //$NON-NLS-1$ - - // BINDINGS - // resolve the binding to get the variable object - IVariable var_x = (IVariable) name_x.resolveBinding(); - assertEquals(globalScope, var_x.getScope()); - IFunction func_f = (IFunction) name_f.resolveBinding(); - assertEquals(globalScope, func_f.getScope()); - IParameter var_y = (IParameter) name_y.resolveBinding(); - assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(), - var_y.getScope()); - - IVariable var_z = (IVariable) name_z.resolveBinding(); - assertEquals(((ICFunctionScope) func_f.getFunctionScope()) - .getBodyScope(), var_z.getScope()); - - // make sure the variable referenced is the same one we declared above - assertEquals(var_x, name_ref_x.resolveBinding()); - assertEquals(var_y, name_ref_y.resolveBinding()); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_x.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); - - decls = tu.getDeclarationsInAST(name_f.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_f); - - decls = tu.getDeclarationsInAST(name_y.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_y); - - decls = tu.getDeclarationsInAST(name_z.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_z); - - decls = tu.getDeclarationsInAST(name_ref_x.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); - - decls = tu.getDeclarationsInAST(name_ref_y.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_y); - - // // test clearBindings - // assertNotNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) body_f.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) body_f.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); - // //$NON-NLS-1$ - // CVisitor.clearBindings(tu); - // assertNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) body_f.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) body_f.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); - // //$NON-NLS-1$ + // // test clearBindings + // assertNotNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) body_f.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) body_f.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); + // //$NON-NLS-1$ + // CVisitor.clearBindings(tu); + // assertNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) body_f.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) body_f.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); + // //$NON-NLS-1$ + + tu = validateCopy(tu); + } } // typedef struct { @@ -323,117 +332,122 @@ public class AST2Tests extends AST2BaseTest { // } public void testSimpleStruct() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTCompositeTypeSpecifier type = (IASTCompositeTypeSpecifier) decl - .getDeclSpecifier(); - - // it's a typedef - assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass()); - // this an anonymous struct - IASTName name_struct = type.getName(); - assertTrue(name_struct.isDeclaration()); - assertFalse(name_struct.isReference()); - assertEquals("", name_struct.toString()); //$NON-NLS-1$ - // member - x - IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type - .getMembers()[0]; - IASTSimpleDeclSpecifier spec_x = (IASTSimpleDeclSpecifier) decl_x - .getDeclSpecifier(); - // it's an int - assertEquals(IASTSimpleDeclSpecifier.t_int, spec_x.getType()); - IASTDeclarator tor_x = decl_x.getDeclarators()[0]; - IASTName name_x = tor_x.getName(); - assertEquals("x", name_x.toString()); //$NON-NLS-1$ - - // declarator S - IASTDeclarator tor_S = decl.getDeclarators()[0]; - IASTName name_S = tor_S.getName(); - assertEquals("S", name_S.toString()); //$NON-NLS-1$ - - // function f - IASTFunctionDefinition def_f = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - // f's body - IASTCompoundStatement body_f = (IASTCompoundStatement) def_f.getBody(); - // the declaration statement for myS - IASTDeclarationStatement declstmt_myS = (IASTDeclarationStatement) body_f - .getStatements()[0]; - // the declaration for myS - IASTSimpleDeclaration decl_myS = (IASTSimpleDeclaration) declstmt_myS - .getDeclaration(); - // the type specifier for myS - IASTNamedTypeSpecifier type_spec_myS = (IASTNamedTypeSpecifier) decl_myS - .getDeclSpecifier(); - // the type name for myS - IASTName name_type_myS = type_spec_myS.getName(); - // the declarator for myS - IASTDeclarator tor_myS = decl_myS.getDeclarators()[0]; - // the name for myS - IASTName name_myS = tor_myS.getName(); - // the assignment expression statement - IASTExpressionStatement exprstmt = (IASTExpressionStatement) body_f - .getStatements()[1]; - // the assignment expression - IASTBinaryExpression assexpr = (IASTBinaryExpression) exprstmt - .getExpression(); - // the field reference to myS.x - IASTFieldReference fieldref = (IASTFieldReference) assexpr - .getOperand1(); - // the reference to myS - IASTIdExpression ref_myS = (IASTIdExpression) fieldref.getFieldOwner(); - IASTLiteralExpression lit_5 = (IASTLiteralExpression) assexpr - .getOperand2(); - assertEquals("5", lit_5.toString()); //$NON-NLS-1$ - - // Logical Bindings In Test - ICompositeType type_struct = (ICompositeType) name_struct - .resolveBinding(); - ITypedef typedef_S = (ITypedef) name_S.resolveBinding(); - // make sure the typedef is hooked up correctly - assertEquals(type_struct, typedef_S.getType()); - // the typedef S for myS - ITypedef typedef_myS = (ITypedef) name_type_myS.resolveBinding(); - assertEquals(typedef_S, typedef_myS); - // get the real type for S which is our anonymous struct - ICompositeType type_myS = (ICompositeType) typedef_myS.getType(); - assertEquals(type_myS, type_struct); - // the variable myS - IVariable var_myS = (IVariable) name_myS.resolveBinding(); - assertEquals(typedef_S, var_myS.getType()); - assertEquals(var_myS, ref_myS.getName().resolveBinding()); - IField field_x = (IField) name_x.resolveBinding(); - assertEquals(field_x, fieldref.getFieldName().resolveBinding()); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_struct.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_struct); - - decls = tu.getDeclarationsInAST(name_x.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); - - decls = tu.getDeclarationsInAST(def_f.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], def_f.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(name_S.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_S); - - decls = tu.getDeclarationsInAST(name_myS.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_myS); - - decls = tu.getDeclarationsInAST(ref_myS.getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_myS); - - decls = tu.getDeclarationsInAST(fieldref.getFieldName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTCompositeTypeSpecifier type = (IASTCompositeTypeSpecifier) decl + .getDeclSpecifier(); + + // it's a typedef + assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass()); + // this an anonymous struct + IASTName name_struct = type.getName(); + assertTrue(name_struct.isDeclaration()); + assertFalse(name_struct.isReference()); + assertEquals("", name_struct.toString()); //$NON-NLS-1$ + // member - x + IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type + .getMembers()[0]; + IASTSimpleDeclSpecifier spec_x = (IASTSimpleDeclSpecifier) decl_x + .getDeclSpecifier(); + // it's an int + assertEquals(IASTSimpleDeclSpecifier.t_int, spec_x.getType()); + IASTDeclarator tor_x = decl_x.getDeclarators()[0]; + IASTName name_x = tor_x.getName(); + assertEquals("x", name_x.toString()); //$NON-NLS-1$ + + // declarator S + IASTDeclarator tor_S = decl.getDeclarators()[0]; + IASTName name_S = tor_S.getName(); + assertEquals("S", name_S.toString()); //$NON-NLS-1$ + + // function f + IASTFunctionDefinition def_f = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + // f's body + IASTCompoundStatement body_f = (IASTCompoundStatement) def_f.getBody(); + // the declaration statement for myS + IASTDeclarationStatement declstmt_myS = (IASTDeclarationStatement) body_f + .getStatements()[0]; + // the declaration for myS + IASTSimpleDeclaration decl_myS = (IASTSimpleDeclaration) declstmt_myS + .getDeclaration(); + // the type specifier for myS + IASTNamedTypeSpecifier type_spec_myS = (IASTNamedTypeSpecifier) decl_myS + .getDeclSpecifier(); + // the type name for myS + IASTName name_type_myS = type_spec_myS.getName(); + // the declarator for myS + IASTDeclarator tor_myS = decl_myS.getDeclarators()[0]; + // the name for myS + IASTName name_myS = tor_myS.getName(); + // the assignment expression statement + IASTExpressionStatement exprstmt = (IASTExpressionStatement) body_f + .getStatements()[1]; + // the assignment expression + IASTBinaryExpression assexpr = (IASTBinaryExpression) exprstmt + .getExpression(); + // the field reference to myS.x + IASTFieldReference fieldref = (IASTFieldReference) assexpr + .getOperand1(); + // the reference to myS + IASTIdExpression ref_myS = (IASTIdExpression) fieldref.getFieldOwner(); + IASTLiteralExpression lit_5 = (IASTLiteralExpression) assexpr + .getOperand2(); + assertEquals("5", lit_5.toString()); //$NON-NLS-1$ + + // Logical Bindings In Test + ICompositeType type_struct = (ICompositeType) name_struct + .resolveBinding(); + ITypedef typedef_S = (ITypedef) name_S.resolveBinding(); + // make sure the typedef is hooked up correctly + assertEquals(type_struct, typedef_S.getType()); + // the typedef S for myS + ITypedef typedef_myS = (ITypedef) name_type_myS.resolveBinding(); + assertEquals(typedef_S, typedef_myS); + // get the real type for S which is our anonymous struct + ICompositeType type_myS = (ICompositeType) typedef_myS.getType(); + assertEquals(type_myS, type_struct); + // the variable myS + IVariable var_myS = (IVariable) name_myS.resolveBinding(); + assertEquals(typedef_S, var_myS.getType()); + assertEquals(var_myS, ref_myS.getName().resolveBinding()); + IField field_x = (IField) name_x.resolveBinding(); + assertEquals(field_x, fieldref.getFieldName().resolveBinding()); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_struct.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_struct); + + decls = tu.getDeclarationsInAST(name_x.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + decls = tu.getDeclarationsInAST(def_f.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], def_f.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(name_S.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_S); + + decls = tu.getDeclarationsInAST(name_myS.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_myS); + + decls = tu.getDeclarationsInAST(ref_myS.getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_myS); + + decls = tu.getDeclarationsInAST(fieldref.getFieldName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + tu = validateCopy(tu); + } } public void testCExpressions() throws ParserException { @@ -507,28 +521,33 @@ public class AST2Tests extends AST2BaseTest { public void testMultipleDeclarators() throws Exception { IASTTranslationUnit tu = parse("int r, s;", ParserLanguage.C); //$NON-NLS-1$ - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTDeclarator[] declarators = decl.getDeclarators(); - assertEquals(2, declarators.length); - - IASTDeclarator dtor1 = declarators[0]; - IASTDeclarator dtor2 = declarators[1]; - - IASTName name1 = dtor1.getName(); - IASTName name2 = dtor2.getName(); - - assertEquals(name1.resolveBinding().getName(), "r"); //$NON-NLS-1$ - assertEquals(name2.resolveBinding().getName(), "s"); //$NON-NLS-1$ - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name1); - - decls = tu.getDeclarationsInAST(name2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name2); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTDeclarator[] declarators = decl.getDeclarators(); + assertEquals(2, declarators.length); + + IASTDeclarator dtor1 = declarators[0]; + IASTDeclarator dtor2 = declarators[1]; + + IASTName name1 = dtor1.getName(); + IASTName name2 = dtor2.getName(); + + assertEquals(name1.resolveBinding().getName(), "r"); //$NON-NLS-1$ + assertEquals(name2.resolveBinding().getName(), "s"); //$NON-NLS-1$ + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name1); + + decls = tu.getDeclarationsInAST(name2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name2); + + tu = validateCopy(tu); + } } @@ -542,78 +561,83 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); - // struct A; - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1 - .getDeclSpecifier(); - assertEquals(0, decl1.getDeclarators().length); - IASTName nameA1 = compTypeSpec.getName(); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // struct A; + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1 + .getDeclSpecifier(); + assertEquals(0, decl1.getDeclarators().length); + IASTName nameA1 = compTypeSpec.getName(); + + // void f() { + IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef + .getBody(); + assertEquals(2, compoundStatement.getStatements().length); + + // struct A; + IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement + .getStatements()[0]; + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement + .getDeclaration(); + compTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); + assertEquals(0, decl2.getDeclarators().length); + IASTName nameA2 = compTypeSpec.getName(); + + // struct A * a; + declStatement = (IASTDeclarationStatement) compoundStatement + .getStatements()[1]; + IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) declStatement + .getDeclaration(); + compTypeSpec = (IASTElaboratedTypeSpecifier) decl3.getDeclSpecifier(); + IASTName nameA3 = compTypeSpec.getName(); + IASTDeclarator dtor = decl3.getDeclarators()[0]; + IASTName namea = dtor.getName(); + assertEquals(1, dtor.getPointerOperators().length); + assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); + + // bindings + ICompositeType str1 = (ICompositeType) nameA1.resolveBinding(); + ICompositeType str2 = (ICompositeType) nameA2.resolveBinding(); + IVariable var = (IVariable) namea.resolveBinding(); + IType str3pointer = var.getType(); + assertTrue(str3pointer instanceof IPointerType); + ICompositeType str3 = (ICompositeType) ((IPointerType) str3pointer) + .getType(); + ICompositeType str4 = (ICompositeType) nameA3.resolveBinding(); + assertNotNull(str1); + assertNotNull(str2); + assertNotSame(str1, str2); + assertSame(str2, str3); + assertSame(str3, str4); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], nameA1); + + decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fndef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(nameA2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], nameA2); + + decls = tu.getDeclarationsInAST(nameA3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], nameA2); + + decls = tu.getDeclarationsInAST(namea.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], namea); - // void f() { - IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef - .getBody(); - assertEquals(2, compoundStatement.getStatements().length); - - // struct A; - IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement - .getStatements()[0]; - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement - .getDeclaration(); - compTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); - assertEquals(0, decl2.getDeclarators().length); - IASTName nameA2 = compTypeSpec.getName(); - - // struct A * a; - declStatement = (IASTDeclarationStatement) compoundStatement - .getStatements()[1]; - IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) declStatement - .getDeclaration(); - compTypeSpec = (IASTElaboratedTypeSpecifier) decl3.getDeclSpecifier(); - IASTName nameA3 = compTypeSpec.getName(); - IASTDeclarator dtor = decl3.getDeclarators()[0]; - IASTName namea = dtor.getName(); - assertEquals(1, dtor.getPointerOperators().length); - assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); - - // bindings - ICompositeType str1 = (ICompositeType) nameA1.resolveBinding(); - ICompositeType str2 = (ICompositeType) nameA2.resolveBinding(); - IVariable var = (IVariable) namea.resolveBinding(); - IType str3pointer = var.getType(); - assertTrue(str3pointer instanceof IPointerType); - ICompositeType str3 = (ICompositeType) ((IPointerType) str3pointer) - .getType(); - ICompositeType str4 = (ICompositeType) nameA3.resolveBinding(); - assertNotNull(str1); - assertNotNull(str2); - assertNotSame(str1, str2); - assertSame(str2, str3); - assertSame(str3, str4); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], nameA1); - - decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fndef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(nameA2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], nameA2); - - decls = tu.getDeclarationsInAST(nameA3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], nameA2); - - decls = tu.getDeclarationsInAST(namea.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], namea); + tu = validateCopy(tu); + } } public void testStructureTagScoping_2() throws Exception { @@ -625,60 +649,65 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); - // struct A; - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1 - .getDeclSpecifier(); - assertEquals(0, decl1.getDeclarators().length); - IASTName nameA1 = compTypeSpec.getName(); - - // void f() { - IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef - .getBody(); - assertEquals(1, compoundStatement.getStatements().length); - - // struct A * a; - IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement - .getStatements()[0]; - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement - .getDeclaration(); - compTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); - IASTName nameA2 = compTypeSpec.getName(); - IASTDeclarator dtor = decl2.getDeclarators()[0]; - IASTName namea = dtor.getName(); - assertEquals(1, dtor.getPointerOperators().length); - assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); - - // bindings - ICompositeType str1 = (ICompositeType) nameA1.resolveBinding(); - ICompositeType str2 = (ICompositeType) nameA2.resolveBinding(); - IVariable var = (IVariable) namea.resolveBinding(); - IPointerType str3pointer = (IPointerType) var.getType(); - ICompositeType str3 = (ICompositeType) str3pointer.getType(); - assertNotNull(str1); - assertSame(str1, str2); - assertSame(str2, str3); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], nameA1); - - decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fndef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(nameA2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], nameA1); - - decls = tu.getDeclarationsInAST(namea.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], namea); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // struct A; + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1 + .getDeclSpecifier(); + assertEquals(0, decl1.getDeclarators().length); + IASTName nameA1 = compTypeSpec.getName(); + + // void f() { + IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef + .getBody(); + assertEquals(1, compoundStatement.getStatements().length); + + // struct A * a; + IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement + .getStatements()[0]; + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement + .getDeclaration(); + compTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); + IASTName nameA2 = compTypeSpec.getName(); + IASTDeclarator dtor = decl2.getDeclarators()[0]; + IASTName namea = dtor.getName(); + assertEquals(1, dtor.getPointerOperators().length); + assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); + + // bindings + ICompositeType str1 = (ICompositeType) nameA1.resolveBinding(); + ICompositeType str2 = (ICompositeType) nameA2.resolveBinding(); + IVariable var = (IVariable) namea.resolveBinding(); + IPointerType str3pointer = (IPointerType) var.getType(); + ICompositeType str3 = (ICompositeType) str3pointer.getType(); + assertNotNull(str1); + assertSame(str1, str2); + assertSame(str2, str3); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], nameA1); + + decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fndef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(nameA2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], nameA1); + + decls = tu.getDeclarationsInAST(namea.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], namea); + + tu = validateCopy(tu); + } } public void testStructureDef() throws Exception { @@ -692,107 +721,112 @@ public class AST2Tests extends AST2BaseTest { IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); - // struct A; - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) decl1 - .getDeclSpecifier(); - assertEquals(0, decl1.getDeclarators().length); - IASTName name_A1 = elabTypeSpec.getName(); - - // struct A * a; - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu - .getDeclarations()[1]; - elabTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); - IASTName name_A2 = elabTypeSpec.getName(); - IASTDeclarator dtor = decl2.getDeclarators()[0]; - IASTName name_a = dtor.getName(); - assertEquals(1, dtor.getPointerOperators().length); - assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); - - // struct A { - IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu - .getDeclarations()[2]; - ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) decl3 - .getDeclSpecifier(); - IASTName name_Adef = compTypeSpec.getName(); - - // int i; - IASTSimpleDeclaration decl4 = (IASTSimpleDeclaration) compTypeSpec - .getMembers()[0]; - dtor = decl4.getDeclarators()[0]; - IASTName name_i = dtor.getName(); - - // void f() { - IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu - .getDeclarations()[3]; - IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef - .getBody(); - assertEquals(1, compoundStatement.getStatements().length); - - // a->i; - IASTExpressionStatement exprstmt = (IASTExpressionStatement) compoundStatement - .getStatements()[0]; - IASTFieldReference fieldref = (IASTFieldReference) exprstmt - .getExpression(); - IASTIdExpression id_a = (IASTIdExpression) fieldref.getFieldOwner(); - IASTName name_aref = id_a.getName(); - IASTName name_iref = fieldref.getFieldName(); - - // bindings - IVariable var_a1 = (IVariable) name_aref.resolveBinding(); - IVariable var_i1 = (IVariable) name_iref.resolveBinding(); - IPointerType structA_1pointer = (IPointerType) var_a1.getType(); - ICompositeType structA_1 = (ICompositeType) structA_1pointer.getType(); - ICompositeType structA_2 = (ICompositeType) name_A1.resolveBinding(); - ICompositeType structA_3 = (ICompositeType) name_A2.resolveBinding(); - ICompositeType structA_4 = (ICompositeType) name_Adef.resolveBinding(); - - IVariable var_a2 = (IVariable) name_a.resolveBinding(); - IVariable var_i2 = (IVariable) name_i.resolveBinding(); - - assertSame(var_a1, var_a2); - assertSame(var_i1, var_i2); - assertSame(structA_1, structA_2); - assertSame(structA_2, structA_3); - assertSame(structA_3, structA_4); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_A1); - assertEquals(decls[1], name_Adef); - - decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_A1); - assertEquals(decls[1], name_Adef); - - decls = tu.getDeclarationsInAST(name_a.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a); - - decls = tu.getDeclarationsInAST(name_Adef.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_A1); - assertEquals(decls[1], name_Adef); - - decls = tu.getDeclarationsInAST(name_i.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); - - decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fndef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(name_aref.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a); - - decls = tu.getDeclarationsInAST(name_iref.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // struct A; + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) decl1 + .getDeclSpecifier(); + assertEquals(0, decl1.getDeclarators().length); + IASTName name_A1 = elabTypeSpec.getName(); + + // struct A * a; + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu + .getDeclarations()[1]; + elabTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier(); + IASTName name_A2 = elabTypeSpec.getName(); + IASTDeclarator dtor = decl2.getDeclarators()[0]; + IASTName name_a = dtor.getName(); + assertEquals(1, dtor.getPointerOperators().length); + assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer); + + // struct A { + IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu + .getDeclarations()[2]; + ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) decl3 + .getDeclSpecifier(); + IASTName name_Adef = compTypeSpec.getName(); + + // int i; + IASTSimpleDeclaration decl4 = (IASTSimpleDeclaration) compTypeSpec + .getMembers()[0]; + dtor = decl4.getDeclarators()[0]; + IASTName name_i = dtor.getName(); + + // void f() { + IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu + .getDeclarations()[3]; + IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef + .getBody(); + assertEquals(1, compoundStatement.getStatements().length); + + // a->i; + IASTExpressionStatement exprstmt = (IASTExpressionStatement) compoundStatement + .getStatements()[0]; + IASTFieldReference fieldref = (IASTFieldReference) exprstmt + .getExpression(); + IASTIdExpression id_a = (IASTIdExpression) fieldref.getFieldOwner(); + IASTName name_aref = id_a.getName(); + IASTName name_iref = fieldref.getFieldName(); + + // bindings + IVariable var_a1 = (IVariable) name_aref.resolveBinding(); + IVariable var_i1 = (IVariable) name_iref.resolveBinding(); + IPointerType structA_1pointer = (IPointerType) var_a1.getType(); + ICompositeType structA_1 = (ICompositeType) structA_1pointer.getType(); + ICompositeType structA_2 = (ICompositeType) name_A1.resolveBinding(); + ICompositeType structA_3 = (ICompositeType) name_A2.resolveBinding(); + ICompositeType structA_4 = (ICompositeType) name_Adef.resolveBinding(); + + IVariable var_a2 = (IVariable) name_a.resolveBinding(); + IVariable var_i2 = (IVariable) name_i.resolveBinding(); + + assertSame(var_a1, var_a2); + assertSame(var_i1, var_i2); + assertSame(structA_1, structA_2); + assertSame(structA_2, structA_3); + assertSame(structA_3, structA_4); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_A1); + assertEquals(decls[1], name_Adef); + + decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_A1); + assertEquals(decls[1], name_Adef); + + decls = tu.getDeclarationsInAST(name_a.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a); + + decls = tu.getDeclarationsInAST(name_Adef.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_A1); + assertEquals(decls[1], name_Adef); + + decls = tu.getDeclarationsInAST(name_i.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fndef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(name_aref.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a); + + decls = tu.getDeclarationsInAST(name_iref.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + tu = validateCopy(tu); + } } // struct x {}; @@ -802,88 +836,93 @@ public class AST2Tests extends AST2BaseTest { public void testStructureNamespace() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTSimpleDeclaration declaration1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTCompositeTypeSpecifier typeSpec = (IASTCompositeTypeSpecifier) declaration1 - .getDeclSpecifier(); - IASTName x_1 = typeSpec.getName(); - - IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator); - IASTParameterDeclaration param = ((IASTStandardFunctionDeclarator) fdef - .getDeclarator()).getParameters()[0]; - IASTName x_2 = param.getDeclarator().getName(); - - IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody(); - IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compound - .getStatements()[0]; - IASTSimpleDeclaration declaration2 = (IASTSimpleDeclaration) declStatement - .getDeclaration(); - IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) declaration2 - .getDeclSpecifier(); - IASTName x_3 = elab.getName(); - - ICompositeType x1 = (ICompositeType) x_1.resolveBinding(); - IVariable x2 = (IVariable) x_2.resolveBinding(); - ICompositeType x3 = (ICompositeType) x_3.resolveBinding(); - - assertNotNull(x1); - assertNotNull(x2); - assertSame(x1, x3); - assertNotSame(x2, x3); - - IASTDeclarator decl_i = declaration2.getDeclarators()[0]; - decl_i.getName().resolveBinding(); // add i's binding to the scope - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(x_1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], x_1); - - decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fdef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(x_2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], x_2); - - decls = tu.getDeclarationsInAST(x_3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], x_1); - - decls = tu.getDeclarationsInAST(declaration2.getDeclarators()[0].getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], declaration2.getDeclarators()[0].getName()); - - // assertNotNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) compound.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNotNull(((ICScope) compound.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); - // //$NON-NLS-1$ - // CVisitor.clearBindings(tu); - // assertNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) tu.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) compound.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); - // //$NON-NLS-1$ - // assertNull(((ICScope) compound.getScope()).getBinding( - // ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); - // //$NON-NLS-1$ + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration declaration1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTCompositeTypeSpecifier typeSpec = (IASTCompositeTypeSpecifier) declaration1 + .getDeclSpecifier(); + IASTName x_1 = typeSpec.getName(); + + IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator); + IASTParameterDeclaration param = ((IASTStandardFunctionDeclarator) fdef + .getDeclarator()).getParameters()[0]; + IASTName x_2 = param.getDeclarator().getName(); + + IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody(); + IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compound + .getStatements()[0]; + IASTSimpleDeclaration declaration2 = (IASTSimpleDeclaration) declStatement + .getDeclaration(); + IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) declaration2 + .getDeclSpecifier(); + IASTName x_3 = elab.getName(); + + ICompositeType x1 = (ICompositeType) x_1.resolveBinding(); + IVariable x2 = (IVariable) x_2.resolveBinding(); + ICompositeType x3 = (ICompositeType) x_3.resolveBinding(); + + assertNotNull(x1); + assertNotNull(x2); + assertSame(x1, x3); + assertNotSame(x2, x3); + + IASTDeclarator decl_i = declaration2.getDeclarators()[0]; + decl_i.getName().resolveBinding(); // add i's binding to the scope + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(x_1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], x_1); + + decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fdef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(x_2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], x_2); + + decls = tu.getDeclarationsInAST(x_3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], x_1); + + decls = tu.getDeclarationsInAST(declaration2.getDeclarators()[0].getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], declaration2.getDeclarators()[0].getName()); + + // assertNotNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) compound.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNotNull(((ICScope) compound.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); + // //$NON-NLS-1$ + // CVisitor.clearBindings(tu); + // assertNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) tu.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) compound.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); + // //$NON-NLS-1$ + // assertNull(((ICScope) compound.getScope()).getBinding( + // ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); + // //$NON-NLS-1$ + + tu = validateCopy(tu); + } } // void f( int a ); @@ -893,126 +932,135 @@ public class AST2Tests extends AST2BaseTest { public void testFunctionParameters() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - // void f( - IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTStandardFunctionDeclarator dtor = (IASTStandardFunctionDeclarator) f_decl - .getDeclarators()[0]; - IASTName f_name1 = dtor.getName(); - // int a ); - IASTParameterDeclaration param1 = dtor.getParameters()[0]; - IASTDeclarator paramDtor = param1.getDeclarator(); - IASTName name_param1 = paramDtor.getName(); - - // void f( - IASTFunctionDefinition f_defn = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - assertTrue(f_defn.getDeclarator() instanceof IASTStandardFunctionDeclarator); - dtor = (IASTStandardFunctionDeclarator) f_defn.getDeclarator(); - IASTName f_name2 = dtor.getName(); - // int b ); - IASTParameterDeclaration param2 = dtor.getParameters()[0]; - paramDtor = param2.getDeclarator(); - IASTName name_param2 = paramDtor.getName(); - - // b; - IASTCompoundStatement compound = (IASTCompoundStatement) f_defn - .getBody(); - IASTExpressionStatement expStatement = (IASTExpressionStatement) compound - .getStatements()[0]; - IASTIdExpression idexp = (IASTIdExpression) expStatement - .getExpression(); - IASTName name_param3 = idexp.getName(); - - // bindings - IParameter param_1 = (IParameter) name_param3.resolveBinding(); - IParameter param_2 = (IParameter) name_param2.resolveBinding(); - IParameter param_3 = (IParameter) name_param1.resolveBinding(); - IFunction f_1 = (IFunction) f_name1.resolveBinding(); - IFunction f_2 = (IFunction) f_name2.resolveBinding(); - - assertNotNull(param_1); - assertNotNull(f_1); - assertSame(param_1, param_2); - assertSame(param_2, param_3); - assertSame(f_1, f_2); - - CVisitor.clearBindings(tu); - param_1 = (IParameter) name_param1.resolveBinding(); - param_2 = (IParameter) name_param3.resolveBinding(); - param_3 = (IParameter) name_param2.resolveBinding(); - f_1 = (IFunction) f_name2.resolveBinding(); - f_2 = (IFunction) f_name1.resolveBinding(); - assertNotNull(param_1); - assertNotNull(f_1); - assertSame(param_1, param_2); - assertSame(param_2, param_3); - assertSame(f_1, f_2); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(f_name1.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], f_name1); - assertEquals(decls[1], f_name2); - - decls = tu.getDeclarationsInAST(name_param1.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_param1); - assertEquals(decls[1], name_param2); - - decls = tu.getDeclarationsInAST(f_name2.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], f_name1); - assertEquals(decls[1], f_name2); - - decls = tu.getDeclarationsInAST(name_param2.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_param1); - assertEquals(decls[1], name_param2); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // void f( + IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTStandardFunctionDeclarator dtor = (IASTStandardFunctionDeclarator) f_decl + .getDeclarators()[0]; + IASTName f_name1 = dtor.getName(); + // int a ); + IASTParameterDeclaration param1 = dtor.getParameters()[0]; + IASTDeclarator paramDtor = param1.getDeclarator(); + IASTName name_param1 = paramDtor.getName(); + + // void f( + IASTFunctionDefinition f_defn = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + assertTrue(f_defn.getDeclarator() instanceof IASTStandardFunctionDeclarator); + dtor = (IASTStandardFunctionDeclarator) f_defn.getDeclarator(); + IASTName f_name2 = dtor.getName(); + // int b ); + IASTParameterDeclaration param2 = dtor.getParameters()[0]; + paramDtor = param2.getDeclarator(); + IASTName name_param2 = paramDtor.getName(); + + // b; + IASTCompoundStatement compound = (IASTCompoundStatement) f_defn + .getBody(); + IASTExpressionStatement expStatement = (IASTExpressionStatement) compound + .getStatements()[0]; + IASTIdExpression idexp = (IASTIdExpression) expStatement + .getExpression(); + IASTName name_param3 = idexp.getName(); + + // bindings + IParameter param_1 = (IParameter) name_param3.resolveBinding(); + IParameter param_2 = (IParameter) name_param2.resolveBinding(); + IParameter param_3 = (IParameter) name_param1.resolveBinding(); + IFunction f_1 = (IFunction) f_name1.resolveBinding(); + IFunction f_2 = (IFunction) f_name2.resolveBinding(); + + assertNotNull(param_1); + assertNotNull(f_1); + assertSame(param_1, param_2); + assertSame(param_2, param_3); + assertSame(f_1, f_2); + + CVisitor.clearBindings(tu); + param_1 = (IParameter) name_param1.resolveBinding(); + param_2 = (IParameter) name_param3.resolveBinding(); + param_3 = (IParameter) name_param2.resolveBinding(); + f_1 = (IFunction) f_name2.resolveBinding(); + f_2 = (IFunction) f_name1.resolveBinding(); + assertNotNull(param_1); + assertNotNull(f_1); + assertSame(param_1, param_2); + assertSame(param_2, param_3); + assertSame(f_1, f_2); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(f_name1.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], f_name1); + assertEquals(decls[1], f_name2); + + decls = tu.getDeclarationsInAST(name_param1.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_param1); + assertEquals(decls[1], name_param2); + + decls = tu.getDeclarationsInAST(f_name2.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], f_name1); + assertEquals(decls[1], f_name2); + + decls = tu.getDeclarationsInAST(name_param2.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_param1); + assertEquals(decls[1], name_param2); + + tu = validateCopy(tu); + } } // void f( int a, int b ) { } public void testSimpleFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTFunctionDefinition fDef = (IASTFunctionDefinition) tu - .getDeclarations()[0]; - assertTrue(fDef.getDeclarator() instanceof IASTStandardFunctionDeclarator); - IASTStandardFunctionDeclarator fDtor = (IASTStandardFunctionDeclarator) fDef - .getDeclarator(); - IASTName fName = fDtor.getName(); - - IASTParameterDeclaration a = fDtor.getParameters()[0]; - IASTName name_a = a.getDeclarator().getName(); - - IASTParameterDeclaration b = fDtor.getParameters()[1]; - IASTName name_b = b.getDeclarator().getName(); - - IFunction function = (IFunction) fName.resolveBinding(); - IParameter param_a = (IParameter) name_a.resolveBinding(); - IParameter param_b = (IParameter) name_b.resolveBinding(); - - assertEquals("f", function.getName()); //$NON-NLS-1$ - assertEquals("a", param_a.getName()); //$NON-NLS-1$ - assertEquals("b", param_b.getName()); //$NON-NLS-1$ - - IParameter[] params = function.getParameters(); - assertEquals(2, params.length); - assertSame(params[0], param_a); - assertSame(params[1], param_b); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(fName.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fName); - - decls = tu.getDeclarationsInAST(name_a.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a); - - decls = tu.getDeclarationsInAST(name_b.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_b); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTFunctionDefinition fDef = (IASTFunctionDefinition) tu + .getDeclarations()[0]; + assertTrue(fDef.getDeclarator() instanceof IASTStandardFunctionDeclarator); + IASTStandardFunctionDeclarator fDtor = (IASTStandardFunctionDeclarator) fDef + .getDeclarator(); + IASTName fName = fDtor.getName(); + + IASTParameterDeclaration a = fDtor.getParameters()[0]; + IASTName name_a = a.getDeclarator().getName(); + + IASTParameterDeclaration b = fDtor.getParameters()[1]; + IASTName name_b = b.getDeclarator().getName(); + + IFunction function = (IFunction) fName.resolveBinding(); + IParameter param_a = (IParameter) name_a.resolveBinding(); + IParameter param_b = (IParameter) name_b.resolveBinding(); + + assertEquals("f", function.getName()); //$NON-NLS-1$ + assertEquals("a", param_a.getName()); //$NON-NLS-1$ + assertEquals("b", param_b.getName()); //$NON-NLS-1$ + + IParameter[] params = function.getParameters(); + assertEquals(2, params.length); + assertSame(params[0], param_a); + assertSame(params[1], param_b); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(fName.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fName); + + decls = tu.getDeclarationsInAST(name_a.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a); + + decls = tu.getDeclarationsInAST(name_b.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_b); + + tu = validateCopy(tu); + } } // void f(); @@ -1023,64 +1071,69 @@ public class AST2Tests extends AST2BaseTest { public void testSimpleFunctionCall() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - // void f(); - IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) fdecl - .getDeclarators()[0]; - IASTName name_f = fdtor.getName(); - - // void g() { - IASTFunctionDefinition gdef = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - - // f(); - IASTCompoundStatement compound = (IASTCompoundStatement) gdef.getBody(); - IASTExpressionStatement expStatement = (IASTExpressionStatement) compound - .getStatements()[0]; - IASTFunctionCallExpression fcall = (IASTFunctionCallExpression) expStatement - .getExpression(); - IASTIdExpression fcall_id = (IASTIdExpression) fcall - .getFunctionNameExpression(); - IASTName name_fcall = fcall_id.getName(); - assertNull(fcall.getParameterExpression()); - - // void f() {} - IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu - .getDeclarations()[2]; - assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator); - fdtor = (IASTStandardFunctionDeclarator) fdef.getDeclarator(); - IASTName name_fdef = fdtor.getName(); - - // bindings - IFunction function_1 = (IFunction) name_fcall.resolveBinding(); - IFunction function_2 = (IFunction) name_f.resolveBinding(); - IFunction function_3 = (IFunction) name_fdef.resolveBinding(); - - assertNotNull(function_1); - assertSame(function_1, function_2); - assertSame(function_2, function_3); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_f.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_f); - assertEquals(decls[1], name_fdef); - - decls = tu.getDeclarationsInAST(gdef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], gdef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(name_fcall.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_f); - assertEquals(decls[1], name_fdef); - - decls = tu.getDeclarationsInAST(name_fdef.resolveBinding()); - assertEquals(decls.length, 2); - assertEquals(decls[0], name_f); - assertEquals(decls[1], name_fdef); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // void f(); + IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) fdecl + .getDeclarators()[0]; + IASTName name_f = fdtor.getName(); + + // void g() { + IASTFunctionDefinition gdef = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + + // f(); + IASTCompoundStatement compound = (IASTCompoundStatement) gdef.getBody(); + IASTExpressionStatement expStatement = (IASTExpressionStatement) compound + .getStatements()[0]; + IASTFunctionCallExpression fcall = (IASTFunctionCallExpression) expStatement + .getExpression(); + IASTIdExpression fcall_id = (IASTIdExpression) fcall + .getFunctionNameExpression(); + IASTName name_fcall = fcall_id.getName(); + assertNull(fcall.getParameterExpression()); + + // void f() {} + IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu + .getDeclarations()[2]; + assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator); + fdtor = (IASTStandardFunctionDeclarator) fdef.getDeclarator(); + IASTName name_fdef = fdtor.getName(); + + // bindings + IFunction function_1 = (IFunction) name_fcall.resolveBinding(); + IFunction function_2 = (IFunction) name_f.resolveBinding(); + IFunction function_3 = (IFunction) name_fdef.resolveBinding(); + + assertNotNull(function_1); + assertSame(function_1, function_2); + assertSame(function_2, function_3); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_f.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_f); + assertEquals(decls[1], name_fdef); + + decls = tu.getDeclarationsInAST(gdef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], gdef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(name_fcall.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_f); + assertEquals(decls[1], name_fdef); + + decls = tu.getDeclarationsInAST(name_fdef.resolveBinding()); + assertEquals(decls.length, 2); + assertEquals(decls[0], name_f); + assertEquals(decls[1], name_fdef); + + tu = validateCopy(tu); + } } // void f() { @@ -1090,72 +1143,76 @@ public class AST2Tests extends AST2BaseTest { // } public void testForLoop() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - // void f() { - IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu - .getDeclarations()[0]; - IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody(); - - // for( - IASTForStatement for_stmt = (IASTForStatement) compound.getStatements()[0]; - // int i = 0; - - IASTSimpleDeclaration initDecl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) for_stmt - .getInitializerStatement()).getDeclaration(); - IASTDeclarator dtor = initDecl.getDeclarators()[0]; - IASTName name_i = dtor.getName(); - // i < 5; - IASTBinaryExpression exp = (IASTBinaryExpression) for_stmt - .getConditionExpression(); - IASTIdExpression id_i = (IASTIdExpression) exp.getOperand1(); - IASTName name_i2 = id_i.getName(); - IASTLiteralExpression lit_5 = (IASTLiteralExpression) exp.getOperand2(); - assertEquals(IASTLiteralExpression.lk_integer_constant, lit_5.getKind()); - // i++ ) { - IASTUnaryExpression un = (IASTUnaryExpression) for_stmt - .getIterationExpression(); - IASTIdExpression id_i2 = (IASTIdExpression) un.getOperand(); - IASTName name_i3 = id_i2.getName(); - assertEquals(IASTUnaryExpression.op_postFixIncr, un.getOperator()); - - // i; - compound = (IASTCompoundStatement) for_stmt.getBody(); - IASTExpressionStatement exprSt = (IASTExpressionStatement) compound - .getStatements()[0]; - IASTIdExpression id_i3 = (IASTIdExpression) exprSt.getExpression(); - IASTName name_i4 = id_i3.getName(); - - // bindings - IVariable var_1 = (IVariable) name_i4.resolveBinding(); - IVariable var_2 = (IVariable) name_i.resolveBinding(); - IVariable var_3 = (IVariable) name_i2.resolveBinding(); - IVariable var_4 = (IVariable) name_i3.resolveBinding(); - - assertSame(var_1, var_2); - assertSame(var_2, var_3); - assertSame(var_3, var_4); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fdef.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(name_i.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); - - decls = tu.getDeclarationsInAST(name_i2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); - - decls = tu.getDeclarationsInAST(name_i3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); - - decls = tu.getDeclarationsInAST(name_i4.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // void f() { + IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu + .getDeclarations()[0]; + IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody(); + + // for( + IASTForStatement for_stmt = (IASTForStatement) compound.getStatements()[0]; + // int i = 0; + + IASTSimpleDeclaration initDecl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) for_stmt + .getInitializerStatement()).getDeclaration(); + IASTDeclarator dtor = initDecl.getDeclarators()[0]; + IASTName name_i = dtor.getName(); + // i < 5; + IASTBinaryExpression exp = (IASTBinaryExpression) for_stmt + .getConditionExpression(); + IASTIdExpression id_i = (IASTIdExpression) exp.getOperand1(); + IASTName name_i2 = id_i.getName(); + IASTLiteralExpression lit_5 = (IASTLiteralExpression) exp.getOperand2(); + assertEquals(IASTLiteralExpression.lk_integer_constant, lit_5.getKind()); + // i++ ) { + IASTUnaryExpression un = (IASTUnaryExpression) for_stmt + .getIterationExpression(); + IASTIdExpression id_i2 = (IASTIdExpression) un.getOperand(); + IASTName name_i3 = id_i2.getName(); + assertEquals(IASTUnaryExpression.op_postFixIncr, un.getOperator()); + + // i; + compound = (IASTCompoundStatement) for_stmt.getBody(); + IASTExpressionStatement exprSt = (IASTExpressionStatement) compound + .getStatements()[0]; + IASTIdExpression id_i3 = (IASTIdExpression) exprSt.getExpression(); + IASTName name_i4 = id_i3.getName(); + + // bindings + IVariable var_1 = (IVariable) name_i4.resolveBinding(); + IVariable var_2 = (IVariable) name_i.resolveBinding(); + IVariable var_3 = (IVariable) name_i2.resolveBinding(); + IVariable var_4 = (IVariable) name_i3.resolveBinding(); + + assertSame(var_1, var_2); + assertSame(var_2, var_3); + assertSame(var_3, var_4); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fdef.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(name_i.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + decls = tu.getDeclarationsInAST(name_i2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + decls = tu.getDeclarationsInAST(name_i3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + decls = tu.getDeclarationsInAST(name_i4.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + tu = validateCopy(tu); + } } // struct A { int x; }; @@ -1164,56 +1221,60 @@ public class AST2Tests extends AST2BaseTest { // } public void testExpressionFieldReference() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTCompositeTypeSpecifier compType = (IASTCompositeTypeSpecifier) simpleDecl - .getDeclSpecifier(); - IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) compType - .getMembers()[0]; - IASTName name_x1 = decl_x.getDeclarators()[0].getName(); - IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - IASTCompoundStatement body = (IASTCompoundStatement) fdef.getBody(); - IASTExpressionStatement expStatement = (IASTExpressionStatement) body - .getStatements()[0]; - IASTFieldReference fieldRef = (IASTFieldReference) expStatement - .getExpression(); - IASTName name_x2 = fieldRef.getFieldName(); - - IField x1 = (IField) name_x1.resolveBinding(); - IField x2 = (IField) name_x2.resolveBinding(); - - assertNotNull(x1); - assertSame(x1, x2); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(compType.getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], compType.getName()); - - decls = tu.getDeclarationsInAST(name_x1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x1); - - decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fdef.getDeclarator().getName()); - - IASTCastExpression castExpression = (IASTCastExpression) ((IASTUnaryExpression) ((IASTFieldReference) expStatement - .getExpression()).getFieldOwner()).getOperand(); - IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression - .getTypeId().getDeclSpecifier()); - decls = tu.getDeclarationsInAST(elaboratedTypeSpecifier.getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], compType.getName()); - - decls = tu.getDeclarationsInAST(name_x2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x1); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTCompositeTypeSpecifier compType = (IASTCompositeTypeSpecifier) simpleDecl + .getDeclSpecifier(); + IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) compType + .getMembers()[0]; + IASTName name_x1 = decl_x.getDeclarators()[0].getName(); + IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + IASTCompoundStatement body = (IASTCompoundStatement) fdef.getBody(); + IASTExpressionStatement expStatement = (IASTExpressionStatement) body + .getStatements()[0]; + IASTFieldReference fieldRef = (IASTFieldReference) expStatement + .getExpression(); + IASTName name_x2 = fieldRef.getFieldName(); + + IField x1 = (IField) name_x1.resolveBinding(); + IField x2 = (IField) name_x2.resolveBinding(); + + assertNotNull(x1); + assertSame(x1, x2); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(compType.getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], compType.getName()); + + decls = tu.getDeclarationsInAST(name_x1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x1); + + decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fdef.getDeclarator().getName()); + + IASTCastExpression castExpression = (IASTCastExpression) ((IASTUnaryExpression) ((IASTFieldReference) expStatement + .getExpression()).getFieldOwner()).getOperand(); + IASTElaboratedTypeSpecifier elaboratedTypeSpecifier = ((IASTElaboratedTypeSpecifier) castExpression + .getTypeId().getDeclSpecifier()); + decls = tu.getDeclarationsInAST(elaboratedTypeSpecifier.getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], compType.getName()); + + decls = tu.getDeclarationsInAST(name_x2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x1); + + tu = validateCopy(tu); + } } // void f() { @@ -1225,67 +1286,76 @@ public class AST2Tests extends AST2BaseTest { // } public void testLabels() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - CNameCollector collector = new CNameCollector(); - tu.accept(collector); - - assertEquals(collector.size(), 3); - IFunction function = (IFunction) collector.getName(0).resolveBinding(); - ILabel label_1 = (ILabel) collector.getName(1).resolveBinding(); - ILabel label_2 = (ILabel) collector.getName(2).resolveBinding(); - assertNotNull(function); - assertNotNull(label_1); - assertEquals(label_1, label_2); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(collector.getName(0) - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], collector.getName(0)); - - decls = tu.getDeclarationsInAST(collector.getName(1).resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], collector.getName(2)); - - decls = tu.getDeclarationsInAST(collector.getName(2).resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], collector.getName(2)); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector collector = new CNameCollector(); + tu.accept(collector); + + assertEquals(collector.size(), 3); + IFunction function = (IFunction) collector.getName(0).resolveBinding(); + ILabel label_1 = (ILabel) collector.getName(1).resolveBinding(); + ILabel label_2 = (ILabel) collector.getName(2).resolveBinding(); + assertNotNull(function); + assertNotNull(label_1); + assertEquals(label_1, label_2); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(collector.getName(0) + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], collector.getName(0)); + + decls = tu.getDeclarationsInAST(collector.getName(1).resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], collector.getName(2)); + + decls = tu.getDeclarationsInAST(collector.getName(2).resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], collector.getName(2)); + + tu = validateCopy(tu); + } } // typedef struct { } X; // int f( X x ); public void testAnonStruct() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + // test tu.getDeclarationsInAST(IBinding) + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu + .getDeclarations()[1]; + IASTName name_X1 = decl1.getDeclarators()[0].getName(); + IASTName name_f = decl2.getDeclarators()[0].getName(); + IASTName name_X2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl2 + .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()) + .getName(); + IASTName name_x = ((IASTStandardFunctionDeclarator) decl2 + .getDeclarators()[0]).getParameters()[0].getDeclarator() + .getName(); + + IASTName[] decls = tu.getDeclarationsInAST(name_X1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_X1); + + decls = tu.getDeclarationsInAST(name_f.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_f); + + decls = tu.getDeclarationsInAST(name_X2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_X1); + + decls = tu.getDeclarationsInAST(name_x.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + tu = validateCopy(tu); + } - // test tu.getDeclarationsInAST(IBinding) - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu - .getDeclarations()[1]; - IASTName name_X1 = decl1.getDeclarators()[0].getName(); - IASTName name_f = decl2.getDeclarators()[0].getName(); - IASTName name_X2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl2 - .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()) - .getName(); - IASTName name_x = ((IASTStandardFunctionDeclarator) decl2 - .getDeclarators()[0]).getParameters()[0].getDeclarator() - .getName(); - - IASTName[] decls = tu.getDeclarationsInAST(name_X1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_X1); - - decls = tu.getDeclarationsInAST(name_f.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_f); - - decls = tu.getDeclarationsInAST(name_X2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_X1); - - decls = tu.getDeclarationsInAST(name_x.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); } public void testLongLong() throws ParserException { @@ -1311,166 +1381,175 @@ public class AST2Tests extends AST2BaseTest { // } public void testEnumerations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - assertEquals(decl1.getDeclarators().length, 0); - ICASTEnumerationSpecifier enumSpec = (ICASTEnumerationSpecifier) decl1 - .getDeclSpecifier(); - IASTEnumerator e1 = enumSpec.getEnumerators()[0]; - IASTEnumerator e2 = enumSpec.getEnumerators()[1]; - IASTEnumerator e3 = enumSpec.getEnumerators()[2]; - IASTName name_hue = enumSpec.getName(); - - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu - .getDeclarations()[1]; - IASTDeclarator dtor = decl2.getDeclarators()[0]; - IASTName name_col = dtor.getName(); - dtor = decl2.getDeclarators()[1]; - IASTName name_cp = dtor.getName(); - IASTElaboratedTypeSpecifier spec = (IASTElaboratedTypeSpecifier) decl2 - .getDeclSpecifier(); - assertEquals(spec.getKind(), IASTElaboratedTypeSpecifier.k_enum); - IASTName name_hue2 = spec.getName(); - - IASTFunctionDefinition fn = (IASTFunctionDefinition) tu - .getDeclarations()[2]; - IASTCompoundStatement compound = (IASTCompoundStatement) fn.getBody(); - IASTExpressionStatement expStatement1 = (IASTExpressionStatement) compound - .getStatements()[0]; - IASTBinaryExpression exp = (IASTBinaryExpression) expStatement1 - .getExpression(); - assertEquals(exp.getOperator(), IASTBinaryExpression.op_assign); - IASTIdExpression id1 = (IASTIdExpression) exp.getOperand1(); - IASTIdExpression id2 = (IASTIdExpression) exp.getOperand2(); - IASTName r_col = id1.getName(); - IASTName r_blue = id2.getName(); - - IASTExpressionStatement expStatement2 = (IASTExpressionStatement) compound - .getStatements()[1]; - exp = (IASTBinaryExpression) expStatement2.getExpression(); - assertEquals(exp.getOperator(), IASTBinaryExpression.op_assign); - id1 = (IASTIdExpression) exp.getOperand1(); - IASTUnaryExpression ue = (IASTUnaryExpression) exp.getOperand2(); - id2 = (IASTIdExpression) ue.getOperand(); - IASTName r_cp = id1.getName(); - IASTName r_col2 = id2.getName(); - - IASTIfStatement ifStatement = (IASTIfStatement) compound - .getStatements()[2]; - exp = (IASTBinaryExpression) ifStatement.getConditionExpression(); - ue = (IASTUnaryExpression) exp.getOperand1(); - id1 = (IASTIdExpression) ue.getOperand(); - id2 = (IASTIdExpression) exp.getOperand2(); - - IASTName r_cp2 = id1.getName(); - IASTName r_red = id2.getName(); - - IEnumeration hue = (IEnumeration) name_hue.resolveBinding(); - IEnumerator red = (IEnumerator) e1.getName().resolveBinding(); - IEnumerator blue = (IEnumerator) e2.getName().resolveBinding(); - IEnumerator green = (IEnumerator) e3.getName().resolveBinding(); - IVariable col = (IVariable) name_col.resolveBinding(); - IVariable cp = (IVariable) name_cp.resolveBinding(); - IEnumeration hue_2 = (IEnumeration) name_hue2.resolveBinding(); - IVariable col2 = (IVariable) r_col.resolveBinding(); - IEnumerator blue2 = (IEnumerator) r_blue.resolveBinding(); - IVariable cp2 = (IVariable) r_cp.resolveBinding(); - IVariable col3 = (IVariable) r_col2.resolveBinding(); - IVariable cp3 = (IVariable) r_cp2.resolveBinding(); - IEnumerator red2 = (IEnumerator) r_red.resolveBinding(); - - assertNotNull(hue); - assertSame(hue, hue_2); - assertNotNull(red); - assertNotNull(green); - assertNotNull(blue); - assertNotNull(col); - assertNotNull(cp); - assertSame(col, col2); - assertSame(blue, blue2); - assertSame(cp, cp2); - assertSame(col, col3); - assertSame(cp, cp3); - assertSame(red, red2); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_hue.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_hue); - - decls = tu.getDeclarationsInAST(e1.getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], e1.getName()); - - decls = tu.getDeclarationsInAST(e2.getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], e2.getName()); - - decls = tu.getDeclarationsInAST(e3.getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], e3.getName()); - - decls = tu.getDeclarationsInAST(name_hue2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_hue); - - decls = tu.getDeclarationsInAST(name_col.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_col); - - decls = tu.getDeclarationsInAST(name_cp.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_cp); - - decls = tu.getDeclarationsInAST(fn.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], fn.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(r_col.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_col); - - decls = tu.getDeclarationsInAST(r_blue.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], e2.getName()); - - decls = tu.getDeclarationsInAST(r_cp.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_cp); - - decls = tu.getDeclarationsInAST(r_col2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_col); - - decls = tu.getDeclarationsInAST(r_cp2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_cp); - - decls = tu.getDeclarationsInAST(r_red.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], e1.getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + assertEquals(decl1.getDeclarators().length, 0); + ICASTEnumerationSpecifier enumSpec = (ICASTEnumerationSpecifier) decl1 + .getDeclSpecifier(); + IASTEnumerator e1 = enumSpec.getEnumerators()[0]; + IASTEnumerator e2 = enumSpec.getEnumerators()[1]; + IASTEnumerator e3 = enumSpec.getEnumerators()[2]; + IASTName name_hue = enumSpec.getName(); + + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu + .getDeclarations()[1]; + IASTDeclarator dtor = decl2.getDeclarators()[0]; + IASTName name_col = dtor.getName(); + dtor = decl2.getDeclarators()[1]; + IASTName name_cp = dtor.getName(); + IASTElaboratedTypeSpecifier spec = (IASTElaboratedTypeSpecifier) decl2 + .getDeclSpecifier(); + assertEquals(spec.getKind(), IASTElaboratedTypeSpecifier.k_enum); + IASTName name_hue2 = spec.getName(); + + IASTFunctionDefinition fn = (IASTFunctionDefinition) tu + .getDeclarations()[2]; + IASTCompoundStatement compound = (IASTCompoundStatement) fn.getBody(); + IASTExpressionStatement expStatement1 = (IASTExpressionStatement) compound + .getStatements()[0]; + IASTBinaryExpression exp = (IASTBinaryExpression) expStatement1 + .getExpression(); + assertEquals(exp.getOperator(), IASTBinaryExpression.op_assign); + IASTIdExpression id1 = (IASTIdExpression) exp.getOperand1(); + IASTIdExpression id2 = (IASTIdExpression) exp.getOperand2(); + IASTName r_col = id1.getName(); + IASTName r_blue = id2.getName(); + + IASTExpressionStatement expStatement2 = (IASTExpressionStatement) compound + .getStatements()[1]; + exp = (IASTBinaryExpression) expStatement2.getExpression(); + assertEquals(exp.getOperator(), IASTBinaryExpression.op_assign); + id1 = (IASTIdExpression) exp.getOperand1(); + IASTUnaryExpression ue = (IASTUnaryExpression) exp.getOperand2(); + id2 = (IASTIdExpression) ue.getOperand(); + IASTName r_cp = id1.getName(); + IASTName r_col2 = id2.getName(); + + IASTIfStatement ifStatement = (IASTIfStatement) compound + .getStatements()[2]; + exp = (IASTBinaryExpression) ifStatement.getConditionExpression(); + ue = (IASTUnaryExpression) exp.getOperand1(); + id1 = (IASTIdExpression) ue.getOperand(); + id2 = (IASTIdExpression) exp.getOperand2(); + + IASTName r_cp2 = id1.getName(); + IASTName r_red = id2.getName(); + + IEnumeration hue = (IEnumeration) name_hue.resolveBinding(); + IEnumerator red = (IEnumerator) e1.getName().resolveBinding(); + IEnumerator blue = (IEnumerator) e2.getName().resolveBinding(); + IEnumerator green = (IEnumerator) e3.getName().resolveBinding(); + IVariable col = (IVariable) name_col.resolveBinding(); + IVariable cp = (IVariable) name_cp.resolveBinding(); + IEnumeration hue_2 = (IEnumeration) name_hue2.resolveBinding(); + IVariable col2 = (IVariable) r_col.resolveBinding(); + IEnumerator blue2 = (IEnumerator) r_blue.resolveBinding(); + IVariable cp2 = (IVariable) r_cp.resolveBinding(); + IVariable col3 = (IVariable) r_col2.resolveBinding(); + IVariable cp3 = (IVariable) r_cp2.resolveBinding(); + IEnumerator red2 = (IEnumerator) r_red.resolveBinding(); + + assertNotNull(hue); + assertSame(hue, hue_2); + assertNotNull(red); + assertNotNull(green); + assertNotNull(blue); + assertNotNull(col); + assertNotNull(cp); + assertSame(col, col2); + assertSame(blue, blue2); + assertSame(cp, cp2); + assertSame(col, col3); + assertSame(cp, cp3); + assertSame(red, red2); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_hue.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_hue); + + decls = tu.getDeclarationsInAST(e1.getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], e1.getName()); + + decls = tu.getDeclarationsInAST(e2.getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], e2.getName()); + + decls = tu.getDeclarationsInAST(e3.getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], e3.getName()); + + decls = tu.getDeclarationsInAST(name_hue2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_hue); + + decls = tu.getDeclarationsInAST(name_col.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_col); + + decls = tu.getDeclarationsInAST(name_cp.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_cp); + + decls = tu.getDeclarationsInAST(fn.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], fn.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(r_col.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_col); + + decls = tu.getDeclarationsInAST(r_blue.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], e2.getName()); + + decls = tu.getDeclarationsInAST(r_cp.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_cp); + + decls = tu.getDeclarationsInAST(r_col2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_col); + + decls = tu.getDeclarationsInAST(r_cp2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_cp); + + decls = tu.getDeclarationsInAST(r_red.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], e1.getName()); + + tu = validateCopy(tu); + } } public void testPointerToFunction() throws Exception { IASTTranslationUnit tu = parse("int (*pfi)();", ParserLanguage.C); //$NON-NLS-1$ - assertEquals(tu.getDeclarations().length, 1); - IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - assertEquals(d.getDeclarators().length, 1); - IASTStandardFunctionDeclarator f = (IASTStandardFunctionDeclarator) d - .getDeclarators()[0]; - assertEquals(f.getName().toString(), ""); //$NON-NLS-1$ - assertNotNull(f.getNestedDeclarator()); - assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$ - assertTrue(f.getPointerOperators().length == 0); - assertFalse(f.getNestedDeclarator().getPointerOperators().length == 0); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(f.getNestedDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], f.getNestedDeclarator().getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + assertEquals(tu.getDeclarations().length, 1); + IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0]; + assertEquals(d.getDeclarators().length, 1); + IASTStandardFunctionDeclarator f = (IASTStandardFunctionDeclarator) d + .getDeclarators()[0]; + assertEquals(f.getName().toString(), ""); //$NON-NLS-1$ + assertNotNull(f.getNestedDeclarator()); + assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$ + assertTrue(f.getPointerOperators().length == 0); + assertFalse(f.getNestedDeclarator().getPointerOperators().length == 0); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(f.getNestedDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], f.getNestedDeclarator().getName()); + + tu = validateCopy(tu); + } } // int a; @@ -1481,97 +1560,101 @@ public class AST2Tests extends AST2BaseTest { // const char * const * const volatile ** const * f; public void testBasicTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IVariable a = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; - IVariable b = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; - IVariable c = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; - IVariable d = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[4]; - IVariable e = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[5]; - IVariable f = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - - IType t_a_1 = a.getType(); - assertTrue(t_a_1 instanceof IBasicType); - assertFalse(((IBasicType) t_a_1).isLong()); - assertFalse(((IBasicType) t_a_1).isShort()); - assertFalse(((IBasicType) t_a_1).isSigned()); - assertFalse(((IBasicType) t_a_1).isUnsigned()); - assertEquals(((IBasicType) t_a_1).getType(), IBasicType.t_int); - - IType t_b_1 = b.getType(); - assertTrue(t_b_1 instanceof IPointerType); - IType t_b_2 = ((IPointerType) t_b_1).getType(); - assertTrue(t_b_2 instanceof IBasicType); - assertEquals(((IBasicType) t_b_2).getType(), IBasicType.t_char); - - IType t_c_1 = c.getType(); - assertTrue(t_c_1 instanceof IQualifierType); - assertTrue(((IQualifierType) t_c_1).isConst()); - IType t_c_2 = ((IQualifierType) t_c_1).getType(); - assertTrue(t_c_2 instanceof IBasicType); - assertEquals(((IBasicType) t_c_2).getType(), IBasicType.t_int); - - IType t_d_1 = d.getType(); - assertTrue(t_d_1 instanceof IPointerType); - assertTrue(((IPointerType) t_d_1).isConst()); - IType t_d_2 = ((IPointerType) t_d_1).getType(); - assertTrue(t_d_2 instanceof IQualifierType); - assertTrue(((IQualifierType) t_d_2).isConst()); - IType t_d_3 = ((IQualifierType) t_d_2).getType(); - assertTrue(t_d_3 instanceof IBasicType); - assertEquals(((IBasicType) t_d_3).getType(), IBasicType.t_char); - - IType t_e_1 = e.getType(); - assertTrue(t_e_1 instanceof IPointerType); - assertFalse(((IPointerType) t_e_1).isConst()); - IType t_e_2 = ((IPointerType) t_e_1).getType(); - assertTrue(t_e_2 instanceof IPointerType); - assertFalse(((IPointerType) t_e_2).isConst()); - IType t_e_3 = ((IPointerType) t_e_2).getType(); - assertTrue(t_e_3 instanceof IQualifierType); - assertTrue(((IQualifierType) t_e_3).isConst()); - IType t_e_4 = ((IQualifierType) t_e_3).getType(); - assertTrue(t_e_4 instanceof IBasicType); - assertEquals(((IBasicType) t_e_4).getType(), IBasicType.t_char); - - IType t_f_1 = f.getType(); - assertTrue(t_f_1 instanceof IPointerType); - assertFalse(((IPointerType) t_f_1).isConst()); - assertFalse(((IPointerType) t_f_1).isVolatile()); - IType t_f_2 = ((IPointerType) t_f_1).getType(); - assertTrue(t_f_2 instanceof IPointerType); - assertTrue(((IPointerType) t_f_2).isConst()); - assertFalse(((IPointerType) t_f_2).isVolatile()); - IType t_f_3 = ((IPointerType) t_f_2).getType(); - assertTrue(t_f_3 instanceof IPointerType); - assertFalse(((IPointerType) t_f_3).isConst()); - assertFalse(((IPointerType) t_f_3).isVolatile()); - IType t_f_4 = ((IPointerType) t_f_3).getType(); - assertTrue(t_f_4 instanceof IPointerType); - assertTrue(((IPointerType) t_f_4).isConst()); - assertTrue(((IPointerType) t_f_4).isVolatile()); - IType t_f_5 = ((IPointerType) t_f_4).getType(); - assertTrue(t_f_5 instanceof IPointerType); - assertTrue(((IPointerType) t_f_5).isConst()); - assertFalse(((IPointerType) t_f_5).isVolatile()); - IType t_f_6 = ((IPointerType) t_f_5).getType(); - assertTrue(t_f_6 instanceof IQualifierType); - assertTrue(((IQualifierType) t_f_6).isConst()); - IType t_f_7 = ((IQualifierType) t_f_6).getType(); - assertTrue(t_f_7 instanceof IBasicType); - assertEquals(((IBasicType) t_f_7).getType(), IBasicType.t_char); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IVariable a = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IVariable b = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; + IVariable c = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; + IVariable d = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[4]; + IVariable e = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[5]; + IVariable f = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + + IType t_a_1 = a.getType(); + assertTrue(t_a_1 instanceof IBasicType); + assertFalse(((IBasicType) t_a_1).isLong()); + assertFalse(((IBasicType) t_a_1).isShort()); + assertFalse(((IBasicType) t_a_1).isSigned()); + assertFalse(((IBasicType) t_a_1).isUnsigned()); + assertEquals(((IBasicType) t_a_1).getType(), IBasicType.t_int); + + IType t_b_1 = b.getType(); + assertTrue(t_b_1 instanceof IPointerType); + IType t_b_2 = ((IPointerType) t_b_1).getType(); + assertTrue(t_b_2 instanceof IBasicType); + assertEquals(((IBasicType) t_b_2).getType(), IBasicType.t_char); + + IType t_c_1 = c.getType(); + assertTrue(t_c_1 instanceof IQualifierType); + assertTrue(((IQualifierType) t_c_1).isConst()); + IType t_c_2 = ((IQualifierType) t_c_1).getType(); + assertTrue(t_c_2 instanceof IBasicType); + assertEquals(((IBasicType) t_c_2).getType(), IBasicType.t_int); + + IType t_d_1 = d.getType(); + assertTrue(t_d_1 instanceof IPointerType); + assertTrue(((IPointerType) t_d_1).isConst()); + IType t_d_2 = ((IPointerType) t_d_1).getType(); + assertTrue(t_d_2 instanceof IQualifierType); + assertTrue(((IQualifierType) t_d_2).isConst()); + IType t_d_3 = ((IQualifierType) t_d_2).getType(); + assertTrue(t_d_3 instanceof IBasicType); + assertEquals(((IBasicType) t_d_3).getType(), IBasicType.t_char); + + IType t_e_1 = e.getType(); + assertTrue(t_e_1 instanceof IPointerType); + assertFalse(((IPointerType) t_e_1).isConst()); + IType t_e_2 = ((IPointerType) t_e_1).getType(); + assertTrue(t_e_2 instanceof IPointerType); + assertFalse(((IPointerType) t_e_2).isConst()); + IType t_e_3 = ((IPointerType) t_e_2).getType(); + assertTrue(t_e_3 instanceof IQualifierType); + assertTrue(((IQualifierType) t_e_3).isConst()); + IType t_e_4 = ((IQualifierType) t_e_3).getType(); + assertTrue(t_e_4 instanceof IBasicType); + assertEquals(((IBasicType) t_e_4).getType(), IBasicType.t_char); + + IType t_f_1 = f.getType(); + assertTrue(t_f_1 instanceof IPointerType); + assertFalse(((IPointerType) t_f_1).isConst()); + assertFalse(((IPointerType) t_f_1).isVolatile()); + IType t_f_2 = ((IPointerType) t_f_1).getType(); + assertTrue(t_f_2 instanceof IPointerType); + assertTrue(((IPointerType) t_f_2).isConst()); + assertFalse(((IPointerType) t_f_2).isVolatile()); + IType t_f_3 = ((IPointerType) t_f_2).getType(); + assertTrue(t_f_3 instanceof IPointerType); + assertFalse(((IPointerType) t_f_3).isConst()); + assertFalse(((IPointerType) t_f_3).isVolatile()); + IType t_f_4 = ((IPointerType) t_f_3).getType(); + assertTrue(t_f_4 instanceof IPointerType); + assertTrue(((IPointerType) t_f_4).isConst()); + assertTrue(((IPointerType) t_f_4).isVolatile()); + IType t_f_5 = ((IPointerType) t_f_4).getType(); + assertTrue(t_f_5 instanceof IPointerType); + assertTrue(((IPointerType) t_f_5).isConst()); + assertFalse(((IPointerType) t_f_5).isVolatile()); + IType t_f_6 = ((IPointerType) t_f_5).getType(); + assertTrue(t_f_6 instanceof IQualifierType); + assertTrue(((IQualifierType) t_f_6).isConst()); + IType t_f_7 = ((IQualifierType) t_f_6).getType(); + assertTrue(t_f_7 instanceof IBasicType); + assertEquals(((IBasicType) t_f_7).getType(), IBasicType.t_char); + + tu = validateCopy(tu); + } } // struct A {} a1; @@ -1580,81 +1663,85 @@ public class AST2Tests extends AST2BaseTest { // AP a3; public void testCompositeTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl - .getDeclSpecifier(); - ICompositeType A = (ICompositeType) compSpec.getName().resolveBinding(); - IASTName name_a1 = decl.getDeclarators()[0].getName(); - IVariable a1 = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; - IASTName name_A2 = ((IASTElaboratedTypeSpecifier) decl - .getDeclSpecifier()).getName(); - IASTName name_AP = decl.getDeclarators()[0].getName(); - ITypedef AP = (ITypedef) decl.getDeclarators()[0].getName() - .resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; - IASTName name_A3 = ((IASTElaboratedTypeSpecifier) decl - .getDeclSpecifier()).getName(); - IVariable a2 = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - IASTName name_a2 = decl.getDeclarators()[0].getName(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; - IVariable a3 = (IVariable) decl.getDeclarators()[0].getName() - .resolveBinding(); - IASTName name_a3 = decl.getDeclarators()[0].getName(); - IASTName name_AP2 = ((IASTNamedTypeSpecifier) decl.getDeclSpecifier()) - .getName(); - - IType t_a1 = a1.getType(); - assertSame(t_a1, A); - - IType t_a2 = a2.getType(); - assertTrue(t_a2 instanceof IPointerType); - assertTrue(((IPointerType) t_a2).isConst()); - assertSame(((IPointerType) t_a2).getType(), A); - - IType t_a3 = a3.getType(); - assertSame(t_a3, AP); - IType t_AP = AP.getType(); - assertTrue(t_AP instanceof IPointerType); - assertSame(((IPointerType) t_AP).getType(), A); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(compSpec.getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], compSpec.getName()); - - decls = tu.getDeclarationsInAST(name_a1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a1); - - decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], compSpec.getName()); - - decls = tu.getDeclarationsInAST(name_AP.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_AP); - - decls = tu.getDeclarationsInAST(name_A3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], compSpec.getName()); - - decls = tu.getDeclarationsInAST(name_a2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a2); - - decls = tu.getDeclarationsInAST(name_AP2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_AP); - - decls = tu.getDeclarationsInAST(name_a3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a3); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl + .getDeclSpecifier(); + ICompositeType A = (ICompositeType) compSpec.getName().resolveBinding(); + IASTName name_a1 = decl.getDeclarators()[0].getName(); + IVariable a1 = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IASTName name_A2 = ((IASTElaboratedTypeSpecifier) decl + .getDeclSpecifier()).getName(); + IASTName name_AP = decl.getDeclarators()[0].getName(); + ITypedef AP = (ITypedef) decl.getDeclarators()[0].getName() + .resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; + IASTName name_A3 = ((IASTElaboratedTypeSpecifier) decl + .getDeclSpecifier()).getName(); + IVariable a2 = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + IASTName name_a2 = decl.getDeclarators()[0].getName(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; + IVariable a3 = (IVariable) decl.getDeclarators()[0].getName() + .resolveBinding(); + IASTName name_a3 = decl.getDeclarators()[0].getName(); + IASTName name_AP2 = ((IASTNamedTypeSpecifier) decl.getDeclSpecifier()) + .getName(); + + IType t_a1 = a1.getType(); + assertSame(t_a1, A); + + IType t_a2 = a2.getType(); + assertTrue(t_a2 instanceof IPointerType); + assertTrue(((IPointerType) t_a2).isConst()); + assertSame(((IPointerType) t_a2).getType(), A); + + IType t_a3 = a3.getType(); + assertSame(t_a3, AP); + IType t_AP = AP.getType(); + assertTrue(t_AP instanceof IPointerType); + assertSame(((IPointerType) t_AP).getType(), A); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(compSpec.getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], compSpec.getName()); + + decls = tu.getDeclarationsInAST(name_a1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a1); + + decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], compSpec.getName()); + + decls = tu.getDeclarationsInAST(name_AP.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_AP); + + decls = tu.getDeclarationsInAST(name_A3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], compSpec.getName()); + + decls = tu.getDeclarationsInAST(name_a2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a2); + + decls = tu.getDeclarationsInAST(name_AP2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_AP); + + decls = tu.getDeclarationsInAST(name_a3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a3); + + tu = validateCopy(tu); + } } // int a[restrict]; @@ -1663,75 +1750,79 @@ public class AST2Tests extends AST2BaseTest { // char* d[const][]; public void testArrayTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - IASTName name_a = decl.getDeclarators()[0].getName(); - IVariable a = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; - IASTName name_b = decl.getDeclarators()[0].getName(); - IVariable b = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; - IASTName name_c = decl.getDeclarators()[0].getName(); - IVariable c = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); - decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; - IASTName name_d = decl.getDeclarators()[0].getName(); - IVariable d = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); - - IType t_a_1 = a.getType(); - assertTrue(t_a_1 instanceof ICArrayType); - assertTrue(((ICArrayType) t_a_1).isRestrict()); - IType t_a_2 = ((IArrayType) t_a_1).getType(); - assertTrue(t_a_2 instanceof IBasicType); - assertEquals(((IBasicType) t_a_2).getType(), IBasicType.t_int); - - IType t_b_1 = b.getType(); - assertTrue(t_b_1 instanceof IArrayType); - IType t_b_2 = ((IArrayType) t_b_1).getType(); - assertTrue(t_b_2 instanceof IArrayType); - IType t_b_3 = ((IArrayType) t_b_2).getType(); - assertTrue(t_b_3 instanceof IPointerType); - IType t_b_4 = ((IPointerType) t_b_3).getType(); - assertTrue(t_b_4 instanceof IBasicType); - assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char); - - t_b_1 = d.getType(); - assertTrue(t_b_1 instanceof IArrayType); - t_b_2 = ((IArrayType) t_b_1).getType(); - assertTrue(t_b_2 instanceof IArrayType); - t_b_3 = ((IArrayType) t_b_2).getType(); - assertTrue(t_b_3 instanceof IPointerType); - t_b_4 = ((IPointerType) t_b_3).getType(); - assertTrue(t_b_4 instanceof IBasicType); - assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; + IASTName name_a = decl.getDeclarators()[0].getName(); + IVariable a = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IASTName name_b = decl.getDeclarators()[0].getName(); + IVariable b = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; + IASTName name_c = decl.getDeclarators()[0].getName(); + IVariable c = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); + decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; + IASTName name_d = decl.getDeclarators()[0].getName(); + IVariable d = (IVariable) decl.getDeclarators()[0].getName().resolveBinding(); + + IType t_a_1 = a.getType(); + assertTrue(t_a_1 instanceof ICArrayType); + assertTrue(((ICArrayType) t_a_1).isRestrict()); + IType t_a_2 = ((IArrayType) t_a_1).getType(); + assertTrue(t_a_2 instanceof IBasicType); + assertEquals(((IBasicType) t_a_2).getType(), IBasicType.t_int); + + IType t_b_1 = b.getType(); + assertTrue(t_b_1 instanceof IArrayType); + IType t_b_2 = ((IArrayType) t_b_1).getType(); + assertTrue(t_b_2 instanceof IArrayType); + IType t_b_3 = ((IArrayType) t_b_2).getType(); + assertTrue(t_b_3 instanceof IPointerType); + IType t_b_4 = ((IPointerType) t_b_3).getType(); + assertTrue(t_b_4 instanceof IBasicType); + assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char); + + t_b_1 = d.getType(); + assertTrue(t_b_1 instanceof IArrayType); + t_b_2 = ((IArrayType) t_b_1).getType(); + assertTrue(t_b_2 instanceof IArrayType); + t_b_3 = ((IArrayType) t_b_2).getType(); + assertTrue(t_b_3 instanceof IPointerType); + t_b_4 = ((IPointerType) t_b_3).getType(); + assertTrue(t_b_4 instanceof IBasicType); + assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char); + + IType t_c_1 = c.getType(); + assertTrue(t_c_1 instanceof IArrayType); + IType t_c_2 = ((IArrayType) t_c_1).getType(); + assertTrue(t_c_2 instanceof IArrayType); + IType t_c_3 = ((IArrayType) t_c_2).getType(); + assertTrue(t_c_3 instanceof IArrayType); + IType t_c_4 = ((IArrayType) t_c_3).getType(); + assertTrue(t_c_4 instanceof IPointerType); + assertTrue(((IPointerType) t_c_4).isConst()); + IType t_c_5 = ((IPointerType) t_c_4).getType(); + assertTrue(t_c_5 instanceof IQualifierType); + assertTrue(((IQualifierType) t_c_5).isConst()); + IType t_c_6 = ((IQualifierType) t_c_5).getType(); + assertTrue(t_c_6 instanceof IBasicType); + assertEquals(((IBasicType) t_c_6).getType(), IBasicType.t_char); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_a.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_a); + + decls = tu.getDeclarationsInAST(name_b.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_b); + + decls = tu.getDeclarationsInAST(name_c.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_c); - IType t_c_1 = c.getType(); - assertTrue(t_c_1 instanceof IArrayType); - IType t_c_2 = ((IArrayType) t_c_1).getType(); - assertTrue(t_c_2 instanceof IArrayType); - IType t_c_3 = ((IArrayType) t_c_2).getType(); - assertTrue(t_c_3 instanceof IArrayType); - IType t_c_4 = ((IArrayType) t_c_3).getType(); - assertTrue(t_c_4 instanceof IPointerType); - assertTrue(((IPointerType) t_c_4).isConst()); - IType t_c_5 = ((IPointerType) t_c_4).getType(); - assertTrue(t_c_5 instanceof IQualifierType); - assertTrue(((IQualifierType) t_c_5).isConst()); - IType t_c_6 = ((IQualifierType) t_c_5).getType(); - assertTrue(t_c_6 instanceof IBasicType); - assertEquals(((IBasicType) t_c_6).getType(), IBasicType.t_char); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_a.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_a); - - decls = tu.getDeclarationsInAST(name_b.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_b); - - decls = tu.getDeclarationsInAST(name_c.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_c); + tu = validateCopy(tu); + } } // struct A; @@ -1740,131 +1831,135 @@ public class AST2Tests extends AST2BaseTest { // void (* (*h)(struct A**) ) ( int d ); public void testFunctionTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl - .getDeclSpecifier(); - ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding(); - IASTName name_A1 = elabSpec.getName(); - assertTrue(name_A1.isDeclaration()); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; - IFunction f = (IFunction) decl.getDeclarators()[0].getName() - .resolveBinding(); - IASTName name_f = decl.getDeclarators()[0].getName(); - IASTName name_i = ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getParameters()[0].getDeclarator() - .getName(); - IASTName name_c = ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getParameters()[1].getDeclarator() - .getName(); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; - IVariable g = (IVariable) decl.getDeclarators()[0] - .getNestedDeclarator().getName().resolveBinding(); - IASTName name_g = decl.getDeclarators()[0].getNestedDeclarator() - .getName(); - IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()) - .getName(); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; - IVariable h = (IVariable) decl.getDeclarators()[0] - .getNestedDeclarator().getNestedDeclarator().getName() - .resolveBinding(); - IASTName name_h = decl.getDeclarators()[0].getNestedDeclarator() - .getNestedDeclarator().getName(); - IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0].getNestedDeclarator()).getParameters()[0] - .getDeclSpecifier()).getName(); - IASTName name_d = ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getParameters()[0].getDeclarator() - .getName(); - - IFunctionType t_f = f.getType(); - IType t_f_return = t_f.getReturnType(); - assertTrue(t_f_return instanceof IPointerType); - assertTrue(((IPointerType) t_f_return).getType() instanceof IBasicType); - IType[] t_f_params = t_f.getParameterTypes(); - assertEquals(t_f_params.length, 2); - assertTrue(t_f_params[0] instanceof IBasicType); - assertTrue(t_f_params[1] instanceof IBasicType); - - // g is a pointer to a function that returns void and has 1 parameter - // struct A * - IType t_g = g.getType(); - assertTrue(t_g instanceof IPointerType); - assertTrue(((IPointerType) t_g).getType() instanceof IFunctionType); - IFunctionType t_g_func = (IFunctionType) ((IPointerType) t_g).getType(); - IType t_g_func_return = t_g_func.getReturnType(); - assertTrue(t_g_func_return instanceof IBasicType); - IType[] t_g_func_params = t_g_func.getParameterTypes(); - assertEquals(t_g_func_params.length, 1); - IType t_g_func_p1 = t_g_func_params[0]; - assertTrue(t_g_func_p1 instanceof IPointerType); - assertSame(((IPointerType) t_g_func_p1).getType(), A); - - // h is a pointer to a function that returns a pointer to a function - // the returned pointer to function returns void and takes 1 parameter - // int - // the *h function takes 1 parameter struct A** - IType t_h = h.getType(); - assertTrue(t_h instanceof IPointerType); - assertTrue(((IPointerType) t_h).getType() instanceof IFunctionType); - IFunctionType t_h_func = (IFunctionType) ((IPointerType) t_h).getType(); - IType t_h_func_return = t_h_func.getReturnType(); - IType[] t_h_func_params = t_h_func.getParameterTypes(); - assertEquals(t_h_func_params.length, 1); - IType t_h_func_p1 = t_h_func_params[0]; - assertTrue(t_h_func_p1 instanceof IPointerType); - assertTrue(((IPointerType) t_h_func_p1).getType() instanceof IPointerType); - assertSame(((IPointerType) ((IPointerType) t_h_func_p1).getType()) - .getType(), A); - - assertTrue(t_h_func_return instanceof IPointerType); - IFunctionType h_return = (IFunctionType) ((IPointerType) t_h_func_return) - .getType(); - IType h_r = h_return.getReturnType(); - IType[] h_ps = h_return.getParameterTypes(); - assertTrue(h_r instanceof IBasicType); - assertEquals(h_ps.length, 1); - assertTrue(h_ps[0] instanceof IBasicType); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_A1); - - decls = tu.getDeclarationsInAST(name_f.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_f); - - decls = tu.getDeclarationsInAST(name_i.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_i); - - decls = tu.getDeclarationsInAST(name_c.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_c); - - decls = tu.getDeclarationsInAST(name_g.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_g); - - decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_A1); - - decls = tu.getDeclarationsInAST(name_h.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_h); - - decls = tu.getDeclarationsInAST(name_A3.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_A1); - - assertNull("Expected null, got "+name_d.resolveBinding(), name_d.resolveBinding()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl + .getDeclSpecifier(); + ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding(); + IASTName name_A1 = elabSpec.getName(); + assertTrue(name_A1.isDeclaration()); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IFunction f = (IFunction) decl.getDeclarators()[0].getName() + .resolveBinding(); + IASTName name_f = decl.getDeclarators()[0].getName(); + IASTName name_i = ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getParameters()[0].getDeclarator() + .getName(); + IASTName name_c = ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getParameters()[1].getDeclarator() + .getName(); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; + IVariable g = (IVariable) decl.getDeclarators()[0] + .getNestedDeclarator().getName().resolveBinding(); + IASTName name_g = decl.getDeclarators()[0].getNestedDeclarator() + .getName(); + IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getParameters()[0].getDeclSpecifier()) + .getName(); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; + IVariable h = (IVariable) decl.getDeclarators()[0] + .getNestedDeclarator().getNestedDeclarator().getName() + .resolveBinding(); + IASTName name_h = decl.getDeclarators()[0].getNestedDeclarator() + .getNestedDeclarator().getName(); + IASTName name_A3 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0].getNestedDeclarator()).getParameters()[0] + .getDeclSpecifier()).getName(); + IASTName name_d = ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getParameters()[0].getDeclarator() + .getName(); + + IFunctionType t_f = f.getType(); + IType t_f_return = t_f.getReturnType(); + assertTrue(t_f_return instanceof IPointerType); + assertTrue(((IPointerType) t_f_return).getType() instanceof IBasicType); + IType[] t_f_params = t_f.getParameterTypes(); + assertEquals(t_f_params.length, 2); + assertTrue(t_f_params[0] instanceof IBasicType); + assertTrue(t_f_params[1] instanceof IBasicType); + + // g is a pointer to a function that returns void and has 1 parameter + // struct A * + IType t_g = g.getType(); + assertTrue(t_g instanceof IPointerType); + assertTrue(((IPointerType) t_g).getType() instanceof IFunctionType); + IFunctionType t_g_func = (IFunctionType) ((IPointerType) t_g).getType(); + IType t_g_func_return = t_g_func.getReturnType(); + assertTrue(t_g_func_return instanceof IBasicType); + IType[] t_g_func_params = t_g_func.getParameterTypes(); + assertEquals(t_g_func_params.length, 1); + IType t_g_func_p1 = t_g_func_params[0]; + assertTrue(t_g_func_p1 instanceof IPointerType); + assertSame(((IPointerType) t_g_func_p1).getType(), A); + + // h is a pointer to a function that returns a pointer to a function + // the returned pointer to function returns void and takes 1 parameter + // int + // the *h function takes 1 parameter struct A** + IType t_h = h.getType(); + assertTrue(t_h instanceof IPointerType); + assertTrue(((IPointerType) t_h).getType() instanceof IFunctionType); + IFunctionType t_h_func = (IFunctionType) ((IPointerType) t_h).getType(); + IType t_h_func_return = t_h_func.getReturnType(); + IType[] t_h_func_params = t_h_func.getParameterTypes(); + assertEquals(t_h_func_params.length, 1); + IType t_h_func_p1 = t_h_func_params[0]; + assertTrue(t_h_func_p1 instanceof IPointerType); + assertTrue(((IPointerType) t_h_func_p1).getType() instanceof IPointerType); + assertSame(((IPointerType) ((IPointerType) t_h_func_p1).getType()) + .getType(), A); + + assertTrue(t_h_func_return instanceof IPointerType); + IFunctionType h_return = (IFunctionType) ((IPointerType) t_h_func_return) + .getType(); + IType h_r = h_return.getReturnType(); + IType[] h_ps = h_return.getParameterTypes(); + assertTrue(h_r instanceof IBasicType); + assertEquals(h_ps.length, 1); + assertTrue(h_ps[0] instanceof IBasicType); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_A1); + + decls = tu.getDeclarationsInAST(name_f.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_f); + + decls = tu.getDeclarationsInAST(name_i.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_i); + + decls = tu.getDeclarationsInAST(name_c.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_c); + + decls = tu.getDeclarationsInAST(name_g.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_g); + + decls = tu.getDeclarationsInAST(name_A2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_A1); + + decls = tu.getDeclarationsInAST(name_h.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_h); + + decls = tu.getDeclarationsInAST(name_A3.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_A1); + + assertNull("Expected null, got "+name_d.resolveBinding(), name_d.resolveBinding()); + + tu = validateCopy(tu); + } } // typedef struct { @@ -1882,106 +1977,111 @@ public class AST2Tests extends AST2BaseTest { // } public void testDesignatedInitializers() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - assertNotNull(tu); - IASTDeclaration[] declarations = tu.getDeclarations(); - IASTName name_Coord = ((IASTSimpleDeclaration) declarations[0]) - .getDeclarators()[0].getName(); - IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]) - .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] - .getName(); - IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]) - .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] - .getName(); - IASTName name_Point = ((IASTSimpleDeclaration) declarations[1]) - .getDeclarators()[0].getName(); - IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]) - .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] - .getName(); - IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]) - .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] - .getName(); - IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[2]; - IASTStatement[] statements = ((IASTCompoundStatement) main.getBody()) - .getStatements(); - - IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0]) - .getDeclaration(); - IASTName name_Coord2 = ((IASTNamedTypeSpecifier) xy.getDeclSpecifier()) - .getName(); - IASTName name_xy = xy.getDeclarators()[0].getName(); - IASTDeclarator declarator_xy = xy.getDeclarators()[0]; - IASTInitializer[] initializers1 = ((IASTInitializerList) declarator_xy - .getInitializer()).getInitializers(); - IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0]) - .getDesignators()[0]).getName(); - - // test bug 87649 - assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0]) - .getLength(), 7); - - IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1]) - .getDesignators()[0]).getName(); - - IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1]) - .getDeclaration(); - IASTName name_Point2 = ((IASTNamedTypeSpecifier) point - .getDeclSpecifier()).getName(); - IASTName name_point = point.getDeclarators()[0].getName(); - IASTDeclarator declarator_point = point.getDeclarators()[0]; - IASTInitializer[] initializers2 = ((IASTInitializerList) declarator_point - .getInitializer()).getInitializers(); - IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0]) - .getDesignators()[0]).getName(); - IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1]) - .getDesignators()[0]).getName(); - IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTInitializerExpression) ((ICASTDesignatedInitializer) initializers2[1]) - .getOperandInitializer()).getExpression()).getOperand()) - .getName(); - - for (int i = 0; i < 2; ++i) { - ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[i]; - assertEquals(designatedInitializer.getDesignators().length, 1); - ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer - .getDesignators()[0]; - assertNotNull(fieldDesignator.getName().toString()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + assertNotNull(tu); + IASTDeclaration[] declarations = tu.getDeclarations(); + IASTName name_Coord = ((IASTSimpleDeclaration) declarations[0]) + .getDeclarators()[0].getName(); + IASTName name_x = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]) + .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] + .getName(); + IASTName name_y = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[0]) + .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] + .getName(); + IASTName name_Point = ((IASTSimpleDeclaration) declarations[1]) + .getDeclarators()[0].getName(); + IASTName name_pos = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]) + .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] + .getName(); + IASTName name_width = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) ((IASTSimpleDeclaration) declarations[1]) + .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] + .getName(); + IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[2]; + IASTStatement[] statements = ((IASTCompoundStatement) main.getBody()) + .getStatements(); + + IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0]) + .getDeclaration(); + IASTName name_Coord2 = ((IASTNamedTypeSpecifier) xy.getDeclSpecifier()) + .getName(); + IASTName name_xy = xy.getDeclarators()[0].getName(); + IASTDeclarator declarator_xy = xy.getDeclarators()[0]; + IASTInitializer[] initializers1 = ((IASTInitializerList) declarator_xy + .getInitializer()).getInitializers(); + IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0]) + .getDesignators()[0]).getName(); + + // test bug 87649 + assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0]) + .getLength(), 7); + + IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1]) + .getDesignators()[0]).getName(); + + IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1]) + .getDeclaration(); + IASTName name_Point2 = ((IASTNamedTypeSpecifier) point + .getDeclSpecifier()).getName(); + IASTName name_point = point.getDeclarators()[0].getName(); + IASTDeclarator declarator_point = point.getDeclarators()[0]; + IASTInitializer[] initializers2 = ((IASTInitializerList) declarator_point + .getInitializer()).getInitializers(); + IASTName name_width2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[0]) + .getDesignators()[0]).getName(); + IASTName name_pos2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers2[1]) + .getDesignators()[0]).getName(); + IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTInitializerExpression) ((ICASTDesignatedInitializer) initializers2[1]) + .getOperandInitializer()).getExpression()).getOperand()) + .getName(); + + for (int j = 0; j < 2; ++j) { + ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j]; + assertEquals(designatedInitializer.getDesignators().length, 1); + ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer + .getDesignators()[0]; + assertNotNull(fieldDesignator.getName().toString()); + } + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(name_Coord2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_Coord); + + decls = tu.getDeclarationsInAST(name_xy.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_xy); + + decls = tu.getDeclarationsInAST(name_y2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_y); + + decls = tu.getDeclarationsInAST(name_x2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_x); + + decls = tu.getDeclarationsInAST(name_Point2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_Point); + + decls = tu.getDeclarationsInAST(name_point.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_point); + + decls = tu.getDeclarationsInAST(name_width2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_width); + + decls = tu.getDeclarationsInAST(name_pos2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_pos); + + decls = tu.getDeclarationsInAST(name_xy2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_xy); + + tu = validateCopy(tu); } - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(name_Coord2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_Coord); - - decls = tu.getDeclarationsInAST(name_xy.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_xy); - - decls = tu.getDeclarationsInAST(name_y2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_y); - - decls = tu.getDeclarationsInAST(name_x2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_x); - - decls = tu.getDeclarationsInAST(name_Point2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_Point); - - decls = tu.getDeclarationsInAST(name_point.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_point); - - decls = tu.getDeclarationsInAST(name_width2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_width); - - decls = tu.getDeclarationsInAST(name_pos2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_pos); - - decls = tu.getDeclarationsInAST(name_xy2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_xy); } // struct S { @@ -1993,37 +2093,41 @@ public class AST2Tests extends AST2BaseTest { // } public void testMoregetDeclarationsInAST1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - - IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] - .getName(); - IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] - .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def - .getBody()).getStatements()[0]).getDeclaration()) - .getDeclarators()[0].getInitializer()).getInitializers()[0]) - .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def - .getBody()).getStatements()[0]).getDeclaration()) - .getDeclarators()[0].getInitializer()).getInitializers()[1]) - .getDesignators()[0]).getName(); - - assertEquals(a1.resolveBinding(), a2.resolveBinding()); - assertEquals(b1.resolveBinding(), b2.resolveBinding()); - - IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(a1, decls[0]); - - decls = tu.getDeclarationsInAST(b1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(b1, decls[0]); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + + IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] + .getName(); + IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] + .getName(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def + .getBody()).getStatements()[0]).getDeclaration()) + .getDeclarators()[0].getInitializer()).getInitializers()[0]) + .getDesignators()[0]).getName(); + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def + .getBody()).getStatements()[0]).getDeclaration()) + .getDeclarators()[0].getInitializer()).getInitializers()[1]) + .getDesignators()[0]).getName(); + + assertEquals(a1.resolveBinding(), a2.resolveBinding()); + assertEquals(b1.resolveBinding(), b2.resolveBinding()); + + IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(a1, decls[0]); + + decls = tu.getDeclarationsInAST(b1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(b1, decls[0]); + + tu = validateCopy(tu); + } } // struct S { @@ -2032,33 +2136,37 @@ public class AST2Tests extends AST2BaseTest { // } s = {.a=1,.b=2}; public void testMoregetDeclarationsInAST2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - - IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] - .getName(); - IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] - .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl - .getDeclarators()[0].getInitializer()).getInitializers()[0]) - .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl - .getDeclarators()[0].getInitializer()).getInitializers()[1]) - .getDesignators()[0]).getName(); - - assertEquals(a1.resolveBinding(), a2.resolveBinding()); - assertEquals(b1.resolveBinding(), b2.resolveBinding()); - - IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(a1, decls[0]); - - decls = tu.getDeclarationsInAST(b1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(b1, decls[0]); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + + IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] + .getName(); + IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] + .getName(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl + .getDeclarators()[0].getInitializer()).getInitializers()[0]) + .getDesignators()[0]).getName(); + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) S_decl + .getDeclarators()[0].getInitializer()).getInitializers()[1]) + .getDesignators()[0]).getName(); + + assertEquals(a1.resolveBinding(), a2.resolveBinding()); + assertEquals(b1.resolveBinding(), b2.resolveBinding()); + + IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(a1, decls[0]); + + decls = tu.getDeclarationsInAST(b1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(b1, decls[0]); + + tu = validateCopy(tu); + } } // typedef struct S { @@ -2070,54 +2178,62 @@ public class AST2Tests extends AST2BaseTest { // y x = {.a=1,.b=2}; public void testMoregetDeclarationsInAST3() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu - .getDeclarations()[3]; - - IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] - .getName(); - IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl - .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] - .getName(); - IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl - .getDeclarators()[0].getInitializer()).getInitializers()[0]) - .getDesignators()[0]).getName(); - IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl - .getDeclarators()[0].getInitializer()).getInitializers()[1]) - .getDesignators()[0]).getName(); - - assertEquals(a1.resolveBinding(), a2.resolveBinding()); - assertEquals(b1.resolveBinding(), b2.resolveBinding()); - - IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(a1, decls[0]); - - decls = tu.getDeclarationsInAST(b1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(b1, decls[0]); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu + .getDeclarations()[3]; + + IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[0]).getDeclarators()[0] + .getName(); + IASTName b1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl + .getDeclSpecifier()).getMembers()[1]).getDeclarators()[0] + .getName(); + IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl + .getDeclarators()[0].getInitializer()).getInitializers()[0]) + .getDesignators()[0]).getName(); + IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) x_decl + .getDeclarators()[0].getInitializer()).getInitializers()[1]) + .getDesignators()[0]).getName(); + + assertEquals(a1.resolveBinding(), a2.resolveBinding()); + assertEquals(b1.resolveBinding(), b2.resolveBinding()); + + IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(a1, decls[0]); + + decls = tu.getDeclarationsInAST(b1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(b1, decls[0]); + + tu = validateCopy(tu); + } } public void testFnReturningPtrToFn() throws Exception { IASTTranslationUnit tu = parse( "void ( * f( int ) )(){}", ParserLanguage.C); //$NON-NLS-1$ - - IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0]; - final IASTName fname = def.getDeclarator().getName(); - IFunction f = (IFunction) fname.resolveBinding(); - - IFunctionType ft = f.getType(); - assertTrue(ft.getReturnType() instanceof IPointerType); - assertTrue(((IPointerType) ft.getReturnType()).getType() instanceof IFunctionType); - assertEquals(ft.getParameterTypes().length, 1); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(f); - assertEquals(decls.length, 1); - assertEquals(decls[0], fname); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0]; + final IASTName fname = def.getDeclarator().getName(); + IFunction f = (IFunction) fname.resolveBinding(); + + IFunctionType ft = f.getType(); + assertTrue(ft.getReturnType() instanceof IPointerType); + assertTrue(((IPointerType) ft.getReturnType()).getType() instanceof IFunctionType); + assertEquals(ft.getParameterTypes().length, 1); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(f); + assertEquals(decls.length, 1); + assertEquals(decls[0], fname); + + tu = validateCopy(tu); + } } // test C99: 6.7.5.3-7 A declaration of a parameter as ''array of type'' @@ -2128,23 +2244,27 @@ public class AST2Tests extends AST2BaseTest { public void testArrayTypeToQualifiedPointerTypeParm() throws Exception { IASTTranslationUnit tu = parse( "void f(int parm[const 3]);", ParserLanguage.C); //$NON-NLS-1$ - - IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IFunction f = (IFunction) def.getDeclarators()[0].getName() - .resolveBinding(); - - IFunctionType ft = f.getType(); - assertTrue(ft.getParameterTypes()[0] instanceof IPointerType); - assertTrue(((IPointerType) ft.getParameterTypes()[0]).isConst()); - - // test tu.getDeclarationsInAST(IBinding) - IASTName name_parm = ((IASTStandardFunctionDeclarator) def - .getDeclarators()[0]).getParameters()[0].getDeclarator() - .getName(); - IASTName[] decls = tu.getDeclarationsInAST(name_parm.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_parm); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IFunction f = (IFunction) def.getDeclarators()[0].getName() + .resolveBinding(); + + IFunctionType ft = f.getType(); + assertTrue(ft.getParameterTypes()[0] instanceof IPointerType); + assertTrue(((IPointerType) ft.getParameterTypes()[0]).isConst()); + + // test tu.getDeclarationsInAST(IBinding) + IASTName name_parm = ((IASTStandardFunctionDeclarator) def + .getDeclarators()[0]).getParameters()[0].getDeclarator() + .getName(); + IASTName[] decls = tu.getDeclarationsInAST(name_parm.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_parm); + + tu = validateCopy(tu); + } } // int f() {} @@ -2153,45 +2273,50 @@ public class AST2Tests extends AST2BaseTest { public void testFunctionDefTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu - .getDeclarations()[0]; - IFunction f = (IFunction) def1.getDeclarator().getName() - .resolveBinding(); - IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu - .getDeclarations()[1]; - IFunction f2 = (IFunction) def2.getDeclarator().getName() - .resolveBinding(); - IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu - .getDeclarations()[2]; - IFunction f3 = (IFunction) def3.getDeclarator().getName() - .resolveBinding(); - - IFunctionType ft = f.getType(); - IFunctionType ft2 = f2.getType(); - IFunctionType ft3 = f3.getType(); - - assertTrue(ft.getReturnType() instanceof IBasicType); - assertTrue(ft2.getReturnType() instanceof IPointerType); - assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType); - assertTrue(ft3.getReturnType() instanceof IPointerType); - assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType); - assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()) - .getType()).getReturnType() instanceof IBasicType); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], def1.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(def2.getDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], def2.getDeclarator().getName()); - - decls = tu.getDeclarationsInAST(def3.getDeclarator().getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], def3.getDeclarator().getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu + .getDeclarations()[0]; + IFunction f = (IFunction) def1.getDeclarator().getName() + .resolveBinding(); + IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu + .getDeclarations()[1]; + IFunction f2 = (IFunction) def2.getDeclarator().getName() + .resolveBinding(); + IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu + .getDeclarations()[2]; + IFunction f3 = (IFunction) def3.getDeclarator().getName() + .resolveBinding(); + + IFunctionType ft = f.getType(); + IFunctionType ft2 = f2.getType(); + IFunctionType ft3 = f3.getType(); + + assertTrue(ft.getReturnType() instanceof IBasicType); + assertTrue(ft2.getReturnType() instanceof IPointerType); + assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType); + assertTrue(ft3.getReturnType() instanceof IPointerType); + assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType); + assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()) + .getType()).getReturnType() instanceof IBasicType); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], def1.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(def2.getDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], def2.getDeclarator().getName()); + + decls = tu.getDeclarationsInAST(def3.getDeclarator().getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], def3.getDeclarator().getName()); + + tu = validateCopy(tu); + } } // any parameter to type function returning T is adjusted to be pointer to @@ -2199,76 +2324,85 @@ public class AST2Tests extends AST2BaseTest { public void testParmToFunction() throws Exception { IASTTranslationUnit tu = parse( "int f(int g(void)) { return g();}", ParserLanguage.C); //$NON-NLS-1$ - - IASTFunctionDefinition def = (IASTFunctionDefinition) tu - .getDeclarations()[0]; - IFunction f = (IFunction) def.getDeclarator().getName() - .resolveBinding(); - - IType ft = ((CFunction) f).getType(); - assertTrue(ft instanceof IFunctionType); - IType gt_1 = ((IFunctionType) ft).getParameterTypes()[0]; - assertTrue(gt_1 instanceof IPointerType); - IType gt_2 = ((IPointerType) gt_1).getType(); - assertTrue(gt_2 instanceof IFunctionType); - IType gt_ret = ((IFunctionType) gt_2).getReturnType(); - assertTrue(gt_ret instanceof IBasicType); - assertEquals(((IBasicType) gt_ret).getType(), IBasicType.t_int); - IType gt_parm = ((IFunctionType) gt_2).getParameterTypes()[0]; - assertTrue(gt_parm instanceof IBasicType); - assertEquals(((IBasicType) gt_parm).getType(), IBasicType.t_void); - - // test tu.getDeclarationsInAST(IBinding) - assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator); - IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()) - .getParameters()[0].getDeclarator().getName(); - IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def - .getBody()).getStatements()[0]).getReturnValue()) - .getFunctionNameExpression()).getName(); - IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_g); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTFunctionDefinition def = (IASTFunctionDefinition) tu + .getDeclarations()[0]; + IFunction f = (IFunction) def.getDeclarator().getName() + .resolveBinding(); + + IType ft = ((CFunction) f).getType(); + assertTrue(ft instanceof IFunctionType); + IType gt_1 = ((IFunctionType) ft).getParameterTypes()[0]; + assertTrue(gt_1 instanceof IPointerType); + IType gt_2 = ((IPointerType) gt_1).getType(); + assertTrue(gt_2 instanceof IFunctionType); + IType gt_ret = ((IFunctionType) gt_2).getReturnType(); + assertTrue(gt_ret instanceof IBasicType); + assertEquals(((IBasicType) gt_ret).getType(), IBasicType.t_int); + IType gt_parm = ((IFunctionType) gt_2).getParameterTypes()[0]; + assertTrue(gt_parm instanceof IBasicType); + assertEquals(((IBasicType) gt_parm).getType(), IBasicType.t_void); + + // test tu.getDeclarationsInAST(IBinding) + assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator); + IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator()) + .getParameters()[0].getDeclarator().getName(); + IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def + .getBody()).getStatements()[0]).getReturnValue()) + .getFunctionNameExpression()).getName(); + IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_g); + + tu = validateCopy(tu); + } } public void testArrayPointerFunction() throws Exception { IASTTranslationUnit tu = parse( "int (*v[])(int *x, int *y);", ParserLanguage.C); //$NON-NLS-1$ - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getNestedDeclarator().getName() - .resolveBinding(); - - IType vt_1 = v.getType(); - assertTrue(vt_1 instanceof IArrayType); - IType vt_2 = ((IArrayType) vt_1).getType(); - assertTrue(vt_2 instanceof IPointerType); - IType vt_3 = ((IPointerType) vt_2).getType(); - assertTrue(vt_3 instanceof IFunctionType); - IType vt_ret = ((IFunctionType) vt_3).getReturnType(); - assertTrue(vt_ret instanceof IBasicType); - assertEquals(((IBasicType) vt_ret).getType(), IBasicType.t_int); - assertEquals(((IFunctionType) vt_3).getParameterTypes().length, 2); - IType vpt_1 = ((IFunctionType) vt_3).getParameterTypes()[0]; - assertTrue(vpt_1 instanceof IPointerType); - IType vpt_1_2 = ((IPointerType) vpt_1).getType(); - assertTrue(vpt_1_2 instanceof IBasicType); - assertEquals(((IBasicType) vpt_1_2).getType(), IBasicType.t_int); - IType vpt_2 = ((IFunctionType) vt_3).getParameterTypes()[0]; - assertTrue(vpt_2 instanceof IPointerType); - IType vpt_2_2 = ((IPointerType) vpt_1).getType(); - assertTrue(vpt_2_2 instanceof IBasicType); - assertEquals(((IBasicType) vpt_2_2).getType(), IBasicType.t_int); - - // test tu.getDeclarationsInAST(IBinding) - IASTName[] decls = tu - .getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getNestedDeclarator().getName() - .resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl - .getDeclarators()[0]).getNestedDeclarator().getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getNestedDeclarator().getName() + .resolveBinding(); + + IType vt_1 = v.getType(); + assertTrue(vt_1 instanceof IArrayType); + IType vt_2 = ((IArrayType) vt_1).getType(); + assertTrue(vt_2 instanceof IPointerType); + IType vt_3 = ((IPointerType) vt_2).getType(); + assertTrue(vt_3 instanceof IFunctionType); + IType vt_ret = ((IFunctionType) vt_3).getReturnType(); + assertTrue(vt_ret instanceof IBasicType); + assertEquals(((IBasicType) vt_ret).getType(), IBasicType.t_int); + assertEquals(((IFunctionType) vt_3).getParameterTypes().length, 2); + IType vpt_1 = ((IFunctionType) vt_3).getParameterTypes()[0]; + assertTrue(vpt_1 instanceof IPointerType); + IType vpt_1_2 = ((IPointerType) vpt_1).getType(); + assertTrue(vpt_1_2 instanceof IBasicType); + assertEquals(((IBasicType) vpt_1_2).getType(), IBasicType.t_int); + IType vpt_2 = ((IFunctionType) vt_3).getParameterTypes()[0]; + assertTrue(vpt_2 instanceof IPointerType); + IType vpt_2_2 = ((IPointerType) vpt_1).getType(); + assertTrue(vpt_2_2 instanceof IBasicType); + assertEquals(((IBasicType) vpt_2_2).getType(), IBasicType.t_int); + + // test tu.getDeclarationsInAST(IBinding) + IASTName[] decls = tu + .getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getNestedDeclarator().getName() + .resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl + .getDeclarators()[0]).getNestedDeclarator().getName()); + + tu = validateCopy(tu); + } } // typedef void DWORD; @@ -2277,54 +2411,59 @@ public class AST2Tests extends AST2BaseTest { public void testTypedefExample4a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() - .resolveBinding(); - IType dword_t = dword.getType(); - assertTrue(dword_t instanceof IBasicType); - assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void); - - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu - .getDeclarations()[1]; - ITypedef v = (ITypedef) decl2.getDeclarators()[0].getName() - .resolveBinding(); - IType v_t_1 = v.getType(); - assertTrue(v_t_1 instanceof ITypedef); - IType v_t_2 = ((ITypedef) v_t_1).getType(); - assertTrue(v_t_2 instanceof IBasicType); - assertEquals(((IBasicType) v_t_2).getType(), IBasicType.t_void); - - IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu - .getDeclarations()[2]; - IFunction signal = (IFunction) decl3.getDeclarators()[0].getName() - .resolveBinding(); - IFunctionType signal_t = signal.getType(); - IType signal_ret = signal_t.getReturnType(); - assertTrue(signal_ret instanceof ITypedef); - IType signal_ret2 = ((ITypedef) signal_ret).getType(); - assertTrue(signal_ret2 instanceof ITypedef); - IType signal_ret3 = ((ITypedef) signal_ret2).getType(); - assertTrue(signal_ret3 instanceof IBasicType); - assertEquals(((IBasicType) signal_ret3).getType(), IBasicType.t_void); - - // test tu.getDeclarationsInAST(IBinding) - IASTName name_DWORD = decl1.getDeclarators()[0].getName(); - IASTName name_v = decl2.getDeclarators()[0].getName(); - - IASTName[] decls = tu.getDeclarationsInAST(name_DWORD.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_DWORD); - - decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2 - .getDeclSpecifier()).getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_DWORD); - - decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl3 - .getDeclSpecifier()).getName().resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_v); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() + .resolveBinding(); + IType dword_t = dword.getType(); + assertTrue(dword_t instanceof IBasicType); + assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void); + + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu + .getDeclarations()[1]; + ITypedef v = (ITypedef) decl2.getDeclarators()[0].getName() + .resolveBinding(); + IType v_t_1 = v.getType(); + assertTrue(v_t_1 instanceof ITypedef); + IType v_t_2 = ((ITypedef) v_t_1).getType(); + assertTrue(v_t_2 instanceof IBasicType); + assertEquals(((IBasicType) v_t_2).getType(), IBasicType.t_void); + + IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu + .getDeclarations()[2]; + IFunction signal = (IFunction) decl3.getDeclarators()[0].getName() + .resolveBinding(); + IFunctionType signal_t = signal.getType(); + IType signal_ret = signal_t.getReturnType(); + assertTrue(signal_ret instanceof ITypedef); + IType signal_ret2 = ((ITypedef) signal_ret).getType(); + assertTrue(signal_ret2 instanceof ITypedef); + IType signal_ret3 = ((ITypedef) signal_ret2).getType(); + assertTrue(signal_ret3 instanceof IBasicType); + assertEquals(((IBasicType) signal_ret3).getType(), IBasicType.t_void); + + // test tu.getDeclarationsInAST(IBinding) + IASTName name_DWORD = decl1.getDeclarators()[0].getName(); + IASTName name_v = decl2.getDeclarators()[0].getName(); + + IASTName[] decls = tu.getDeclarationsInAST(name_DWORD.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_DWORD); + + decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2 + .getDeclSpecifier()).getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_DWORD); + + decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl3 + .getDeclSpecifier()).getName().resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_v); + + tu = validateCopy(tu); + } } // typedef void DWORD; @@ -2332,87 +2471,91 @@ public class AST2Tests extends AST2BaseTest { // pfv signal(int, pfv); public void testTypedefExample4b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - - IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() - .resolveBinding(); - IType dword_t = dword.getType(); - assertTrue(dword_t instanceof IBasicType); - assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void); - - IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu - .getDeclarations()[1]; - ITypedef pfv = (ITypedef) decl2.getDeclarators()[0] - .getNestedDeclarator().getName().resolveBinding(); - IType pfv_t_1 = pfv.getType(); - assertTrue(pfv_t_1 instanceof IPointerType); - IType pfv_t_2 = ((IPointerType) pfv_t_1).getType(); - assertTrue(pfv_t_2 instanceof IFunctionType); - IType pfv_t_2_ret_1 = ((IFunctionType) pfv_t_2).getReturnType(); - assertTrue(pfv_t_2_ret_1 instanceof ITypedef); - IType pfv_t_2_ret_2 = ((ITypedef) pfv_t_2_ret_1).getType(); - assertTrue(pfv_t_2_ret_2 instanceof IBasicType); - assertEquals(((IBasicType) pfv_t_2_ret_2).getType(), IBasicType.t_void); - assertTrue(((ITypedef) pfv_t_2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ - IType pfv_t_2_parm = ((IFunctionType) pfv_t_2).getParameterTypes()[0]; - assertTrue(pfv_t_2_parm instanceof IBasicType); - assertEquals(((IBasicType) pfv_t_2_parm).getType(), IBasicType.t_int); - - IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu - .getDeclarations()[2]; - IFunction signal = (IFunction) decl3.getDeclarators()[0].getName() - .resolveBinding(); - IFunctionType signal_t = signal.getType(); - IType signal_ret_1 = signal_t.getReturnType(); - assertTrue(signal_ret_1 instanceof ITypedef); - IType signal_ret_2 = ((ITypedef) signal_ret_1).getType(); - assertTrue(signal_ret_2 instanceof IPointerType); - IType signal_ret_3 = ((IPointerType) signal_ret_2).getType(); - assertTrue(signal_ret_3 instanceof IFunctionType); - IType signal_ret_ret_1 = ((IFunctionType) signal_ret_3).getReturnType(); - assertTrue(signal_ret_ret_1 instanceof ITypedef); - IType signal_ret_ret_2 = ((ITypedef) signal_ret_ret_1).getType(); - assertTrue(signal_ret_ret_2 instanceof IBasicType); - assertEquals(((IBasicType) signal_ret_ret_2).getType(), - IBasicType.t_void); - assertTrue(((ITypedef) signal_ret_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ - - IType signal_parm_t1 = signal_t.getParameterTypes()[0]; - assertTrue(signal_parm_t1 instanceof IBasicType); - assertEquals(((IBasicType) signal_parm_t1).getType(), IBasicType.t_int); - IType signal_parm_t2 = signal_t.getParameterTypes()[1]; - assertTrue(signal_parm_t2 instanceof ITypedef); - IType signal_parm_t2_1 = ((ITypedef) signal_parm_t2).getType(); - assertTrue(signal_parm_t2_1 instanceof IPointerType); - IType signal_parm_t2_2 = ((IPointerType) signal_parm_t2_1).getType(); - assertTrue(signal_parm_t2_2 instanceof IFunctionType); - IType signal_parm_t2_ret_1 = ((IFunctionType) signal_parm_t2_2) - .getReturnType(); - assertTrue(signal_parm_t2_ret_1 instanceof ITypedef); - IType signal_parm_t2_ret_2 = ((ITypedef) signal_parm_t2_ret_1) - .getType(); - assertTrue(signal_parm_t2_ret_2 instanceof IBasicType); - assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(), - IBasicType.t_void); - assertTrue(((ITypedef) signal_parm_t2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ - - // test tu.getDeclarationsInAST(IBinding) - IASTName name_pfv = decl2.getDeclarators()[0].getNestedDeclarator() - .getName(); - IASTName name_pfv1 = ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()) - .getName(); - IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3 - .getDeclarators()[0]).getParameters()[1].getDeclSpecifier()) - .getName(); - - IASTName[] decls = tu.getDeclarationsInAST(name_pfv1.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_pfv); - - decls = tu.getDeclarationsInAST(name_pfv2.resolveBinding()); - assertEquals(decls.length, 1); - assertEquals(decls[0], name_pfv); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + ITypedef dword = (ITypedef) decl1.getDeclarators()[0].getName() + .resolveBinding(); + IType dword_t = dword.getType(); + assertTrue(dword_t instanceof IBasicType); + assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void); + + IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu + .getDeclarations()[1]; + ITypedef pfv = (ITypedef) decl2.getDeclarators()[0] + .getNestedDeclarator().getName().resolveBinding(); + IType pfv_t_1 = pfv.getType(); + assertTrue(pfv_t_1 instanceof IPointerType); + IType pfv_t_2 = ((IPointerType) pfv_t_1).getType(); + assertTrue(pfv_t_2 instanceof IFunctionType); + IType pfv_t_2_ret_1 = ((IFunctionType) pfv_t_2).getReturnType(); + assertTrue(pfv_t_2_ret_1 instanceof ITypedef); + IType pfv_t_2_ret_2 = ((ITypedef) pfv_t_2_ret_1).getType(); + assertTrue(pfv_t_2_ret_2 instanceof IBasicType); + assertEquals(((IBasicType) pfv_t_2_ret_2).getType(), IBasicType.t_void); + assertTrue(((ITypedef) pfv_t_2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ + IType pfv_t_2_parm = ((IFunctionType) pfv_t_2).getParameterTypes()[0]; + assertTrue(pfv_t_2_parm instanceof IBasicType); + assertEquals(((IBasicType) pfv_t_2_parm).getType(), IBasicType.t_int); + + IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu + .getDeclarations()[2]; + IFunction signal = (IFunction) decl3.getDeclarators()[0].getName() + .resolveBinding(); + IFunctionType signal_t = signal.getType(); + IType signal_ret_1 = signal_t.getReturnType(); + assertTrue(signal_ret_1 instanceof ITypedef); + IType signal_ret_2 = ((ITypedef) signal_ret_1).getType(); + assertTrue(signal_ret_2 instanceof IPointerType); + IType signal_ret_3 = ((IPointerType) signal_ret_2).getType(); + assertTrue(signal_ret_3 instanceof IFunctionType); + IType signal_ret_ret_1 = ((IFunctionType) signal_ret_3).getReturnType(); + assertTrue(signal_ret_ret_1 instanceof ITypedef); + IType signal_ret_ret_2 = ((ITypedef) signal_ret_ret_1).getType(); + assertTrue(signal_ret_ret_2 instanceof IBasicType); + assertEquals(((IBasicType) signal_ret_ret_2).getType(), + IBasicType.t_void); + assertTrue(((ITypedef) signal_ret_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ + + IType signal_parm_t1 = signal_t.getParameterTypes()[0]; + assertTrue(signal_parm_t1 instanceof IBasicType); + assertEquals(((IBasicType) signal_parm_t1).getType(), IBasicType.t_int); + IType signal_parm_t2 = signal_t.getParameterTypes()[1]; + assertTrue(signal_parm_t2 instanceof ITypedef); + IType signal_parm_t2_1 = ((ITypedef) signal_parm_t2).getType(); + assertTrue(signal_parm_t2_1 instanceof IPointerType); + IType signal_parm_t2_2 = ((IPointerType) signal_parm_t2_1).getType(); + assertTrue(signal_parm_t2_2 instanceof IFunctionType); + IType signal_parm_t2_ret_1 = ((IFunctionType) signal_parm_t2_2) + .getReturnType(); + assertTrue(signal_parm_t2_ret_1 instanceof ITypedef); + IType signal_parm_t2_ret_2 = ((ITypedef) signal_parm_t2_ret_1) + .getType(); + assertTrue(signal_parm_t2_ret_2 instanceof IBasicType); + assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(), + IBasicType.t_void); + assertTrue(((ITypedef) signal_parm_t2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$ + + // test tu.getDeclarationsInAST(IBinding) + IASTName name_pfv = decl2.getDeclarators()[0].getNestedDeclarator() + .getName(); + IASTName name_pfv1 = ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()) + .getName(); + IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3 + .getDeclarators()[0]).getParameters()[1].getDeclSpecifier()) + .getName(); + + IASTName[] decls = tu.getDeclarationsInAST(name_pfv1.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_pfv); + + decls = tu.getDeclarationsInAST(name_pfv2.resolveBinding()); + assertEquals(decls.length, 1); + assertEquals(decls[0], name_pfv); + + tu = validateCopy(tu); + } } // typedef void fv(int), (*pfv)(int); @@ -2422,86 +2565,91 @@ public class AST2Tests extends AST2BaseTest { public void testTypedefExample4c() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu - .getDeclarations()[0]; - ITypedef fv = (ITypedef) decl.getDeclarators()[0].getName() - .resolveBinding(); - ITypedef pfv = (ITypedef) decl.getDeclarators()[1] - .getNestedDeclarator().getName().resolveBinding(); - - IType fv_t = fv.getType(); - assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()) - .getType(), IBasicType.t_void); - assertEquals( - ((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]) - .getType(), IBasicType.t_int); - - IType pfv_t = pfv.getType(); - assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t) - .getType()).getReturnType()).getType(), IBasicType.t_void); - assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv - .getType()).getType()).getParameterTypes()[0]).getType(), - IBasicType.t_int); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; - IFunction signal1 = (IFunction) decl.getDeclarators()[0] - .getNestedDeclarator().getName().resolveBinding(); - IType signal1_t = signal1.getType(); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; - IFunction signal2 = (IFunction) decl.getDeclarators()[0].getName() - .resolveBinding(); - IType signal2_t = signal2.getType(); - - decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; - IFunction signal3 = (IFunction) decl.getDeclarators()[0].getName() - .resolveBinding(); - IType signal3_t = signal3.getType(); - - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) - .getReturnType()).getType()).getReturnType()).getType(), - IBasicType.t_void); - assertEquals(((IBasicType) ((IFunctionType) signal1_t) - .getParameterTypes()[0]).getType(), IBasicType.t_int); - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) - .getParameterTypes()[1]).getType()).getReturnType()) - .getType(), IBasicType.t_void); - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) - .getParameterTypes()[1]).getType()).getParameterTypes()[0]) - .getType(), IBasicType.t_int); - - assertEquals( - ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) - .getReturnType()).getType()).getType()).getReturnType()) - .getType(), IBasicType.t_void); - assertEquals(((IBasicType) ((IFunctionType) signal2_t) - .getParameterTypes()[0]).getType(), IBasicType.t_int); - assertEquals( - ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) - .getParameterTypes()[1]).getType()).getType()) - .getReturnType()).getType(), IBasicType.t_void); - assertEquals( - ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) - .getParameterTypes()[1]).getType()).getType()) - .getParameterTypes()[0]).getType(), IBasicType.t_int); - - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) - .getReturnType()).getType()).getType()).getReturnType()) - .getType(), IBasicType.t_void); - assertEquals(((IBasicType) ((IFunctionType) signal3_t) - .getParameterTypes()[0]).getType(), IBasicType.t_int); - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) - .getParameterTypes()[1]).getType()).getType()) - .getReturnType()).getType(), IBasicType.t_void); - assertEquals( - ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) - .getParameterTypes()[1]).getType()).getType()) - .getParameterTypes()[0]).getType(), IBasicType.t_int); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu + .getDeclarations()[0]; + ITypedef fv = (ITypedef) decl.getDeclarators()[0].getName() + .resolveBinding(); + ITypedef pfv = (ITypedef) decl.getDeclarators()[1] + .getNestedDeclarator().getName().resolveBinding(); + + IType fv_t = fv.getType(); + assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType()) + .getType(), IBasicType.t_void); + assertEquals( + ((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0]) + .getType(), IBasicType.t_int); + + IType pfv_t = pfv.getType(); + assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t) + .getType()).getReturnType()).getType(), IBasicType.t_void); + assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv + .getType()).getType()).getParameterTypes()[0]).getType(), + IBasicType.t_int); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[1]; + IFunction signal1 = (IFunction) decl.getDeclarators()[0] + .getNestedDeclarator().getName().resolveBinding(); + IType signal1_t = signal1.getType(); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[2]; + IFunction signal2 = (IFunction) decl.getDeclarators()[0].getName() + .resolveBinding(); + IType signal2_t = signal2.getType(); + + decl = (IASTSimpleDeclaration) tu.getDeclarations()[3]; + IFunction signal3 = (IFunction) decl.getDeclarators()[0].getName() + .resolveBinding(); + IType signal3_t = signal3.getType(); + + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) + .getReturnType()).getType()).getReturnType()).getType(), + IBasicType.t_void); + assertEquals(((IBasicType) ((IFunctionType) signal1_t) + .getParameterTypes()[0]).getType(), IBasicType.t_int); + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) + .getParameterTypes()[1]).getType()).getReturnType()) + .getType(), IBasicType.t_void); + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t) + .getParameterTypes()[1]).getType()).getParameterTypes()[0]) + .getType(), IBasicType.t_int); + + assertEquals( + ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) + .getReturnType()).getType()).getType()).getReturnType()) + .getType(), IBasicType.t_void); + assertEquals(((IBasicType) ((IFunctionType) signal2_t) + .getParameterTypes()[0]).getType(), IBasicType.t_int); + assertEquals( + ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) + .getParameterTypes()[1]).getType()).getType()) + .getReturnType()).getType(), IBasicType.t_void); + assertEquals( + ((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t) + .getParameterTypes()[1]).getType()).getType()) + .getParameterTypes()[0]).getType(), IBasicType.t_int); + + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) + .getReturnType()).getType()).getType()).getReturnType()) + .getType(), IBasicType.t_void); + assertEquals(((IBasicType) ((IFunctionType) signal3_t) + .getParameterTypes()[0]).getType(), IBasicType.t_int); + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) + .getParameterTypes()[1]).getType()).getType()) + .getReturnType()).getType(), IBasicType.t_void); + assertEquals( + ((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t) + .getParameterTypes()[1]).getType()).getType()) + .getParameterTypes()[0]).getType(), IBasicType.t_int); + + tu = validateCopy(tu); + } } @@ -2559,18 +2707,23 @@ public class AST2Tests extends AST2BaseTest { // } public void testExternalDefs() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - IVariable a = (IVariable) col.getName(1).resolveBinding(); - IFunction g = (IFunction) col.getName(3).resolveBinding(); - assertNotNull(a); - assertNotNull(g); - assertTrue(g instanceof ICExternalBinding); - - assertEquals(col.size(), 11); - assertInstances(col, a, 7); - assertInstances(col, g, 3); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + IVariable a = (IVariable) col.getName(1).resolveBinding(); + IFunction g = (IFunction) col.getName(3).resolveBinding(); + assertNotNull(a); + assertNotNull(g); + assertTrue(g instanceof ICExternalBinding); + + assertEquals(col.size(), 11); + assertInstances(col, a, 7); + assertInstances(col, g, 3); + + tu = validateCopy(tu); + } } // typedef struct { int x; int y; } Coord; @@ -2579,17 +2732,22 @@ public class AST2Tests extends AST2BaseTest { // } public void testFieldDesignators() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - assertEquals(col.size(), 9); - IField x = (IField) col.getName(1).resolveBinding(); - IField y = (IField) col.getName(2).resolveBinding(); - ITypedef Coord = (ITypedef) col.getName(3).resolveBinding(); - - assertInstances(col, x, 2); - assertInstances(col, y, 2); - assertInstances(col, Coord, 2); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + assertEquals(col.size(), 9); + IField x = (IField) col.getName(1).resolveBinding(); + IField y = (IField) col.getName(2).resolveBinding(); + ITypedef Coord = (ITypedef) col.getName(3).resolveBinding(); + + assertInstances(col, x, 2); + assertInstances(col, y, 2); + assertInstances(col, Coord, 2); + + tu = validateCopy(tu); + } } // enum { member_one, member_two }; @@ -2599,15 +2757,20 @@ public class AST2Tests extends AST2BaseTest { // }; public void testArrayDesignator() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - assertEquals(col.size(), 6); - IEnumerator one = (IEnumerator) col.getName(1).resolveBinding(); - IEnumerator two = (IEnumerator) col.getName(2).resolveBinding(); - - assertInstances(col, one, 2); - assertInstances(col, two, 2); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + assertEquals(col.size(), 6); + IEnumerator one = (IEnumerator) col.getName(1).resolveBinding(); + IEnumerator two = (IEnumerator) col.getName(2).resolveBinding(); + + assertInstances(col, one, 2); + assertInstances(col, two, 2); + + tu = validateCopy(tu); + } } // void f() { @@ -2620,21 +2783,26 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug83737() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu - .getDeclarations()[0]).getBody()).getStatements()[0]; - assertEquals(((IASTBinaryExpression) if_statement - .getConditionExpression()).getOperator(), - IASTBinaryExpression.op_equals); - IASTIfStatement second_if_statement = (IASTIfStatement) if_statement - .getElseClause(); - assertEquals(((IASTBinaryExpression) second_if_statement - .getConditionExpression()).getOperator(), - IASTBinaryExpression.op_lessThan); - IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement - .getElseClause(); - assertEquals(((IASTBinaryExpression) third_if_statement - .getConditionExpression()).getOperator(), - IASTBinaryExpression.op_greaterThan); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu + .getDeclarations()[0]).getBody()).getStatements()[0]; + assertEquals(((IASTBinaryExpression) if_statement + .getConditionExpression()).getOperator(), + IASTBinaryExpression.op_equals); + IASTIfStatement second_if_statement = (IASTIfStatement) if_statement + .getElseClause(); + assertEquals(((IASTBinaryExpression) second_if_statement + .getConditionExpression()).getOperator(), + IASTBinaryExpression.op_lessThan); + IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement + .getElseClause(); + assertEquals(((IASTBinaryExpression) third_if_statement + .getConditionExpression()).getOperator(), + IASTBinaryExpression.op_greaterThan); + + tu = validateCopy(tu); + } } // void f() { @@ -2645,44 +2813,59 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug84090_LabelReferences() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - assertEquals(col.size(), 3); - ILabel end = (ILabel) col.getName(1).resolveBinding(); - - IASTName[] refs = tu.getReferences(end); - assertEquals(refs.length, 1); - assertSame(refs[0].resolveBinding(), end); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + assertEquals(col.size(), 3); + ILabel end = (ILabel) col.getName(1).resolveBinding(); + + IASTName[] refs = tu.getReferences(end); + assertEquals(refs.length, 1); + assertSame(refs[0].resolveBinding(), end); + + tu = validateCopy(tu); + } } // enum col { red, blue }; // enum col c; public void testBug84092_EnumReferences() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector collector = new CNameCollector(); - tu.accept(collector); - - assertEquals(collector.size(), 5); - IEnumeration col = (IEnumeration) collector.getName(0).resolveBinding(); - - IASTName[] refs = tu.getReferences(col); - assertEquals(refs.length, 1); - assertSame(refs[0].resolveBinding(), col); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector collector = new CNameCollector(); + tu.accept(collector); + + assertEquals(collector.size(), 5); + IEnumeration col = (IEnumeration) collector.getName(0).resolveBinding(); + + IASTName[] refs = tu.getReferences(col); + assertEquals(refs.length, 1); + assertSame(refs[0].resolveBinding(), col); + + tu = validateCopy(tu); + } } public void testBug84096_FieldDesignatorRef() throws Exception { IASTTranslationUnit tu = parse( "struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$ - CNameCollector collector = new CNameCollector(); - tu.accept(collector); - - assertEquals(collector.size(), 4); - IField a = (IField) collector.getName(1).resolveBinding(); - - IASTName[] refs = tu.getReferences(a); - assertEquals(refs.length, 1); - assertSame(refs[0].resolveBinding(), a); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector collector = new CNameCollector(); + tu.accept(collector); + + assertEquals(collector.size(), 4); + IField a = (IField) collector.getName(1).resolveBinding(); + + IASTName[] refs = tu.getReferences(a); + assertEquals(refs.length, 1); + assertSame(refs[0].resolveBinding(), a); + + tu = validateCopy(tu); + } } public void testProblems() throws Exception { @@ -2698,16 +2881,21 @@ public class AST2Tests extends AST2BaseTest { // enum e{ one }; public void testEnumerationForwards() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - assertEquals(col.size(), 3); - IEnumeration e = (IEnumeration) col.getName(0).resolveBinding(); - IEnumerator[] etors = e.getEnumerators(); - assertTrue(etors.length == 1); - assertFalse(etors[0] instanceof IProblemBinding); - - assertInstances(col, e, 2); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + assertEquals(col.size(), 3); + IEnumeration e = (IEnumeration) col.getName(0).resolveBinding(); + IEnumerator[] etors = e.getEnumerators(); + assertTrue(etors.length == 1); + assertFalse(etors[0] instanceof IProblemBinding); + + assertInstances(col, e, 2); + + tu = validateCopy(tu); + } } // void f() { @@ -3633,16 +3821,21 @@ public class AST2Tests extends AST2BaseTest { // }; public void test186736() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); - CNameCollector col = new CNameCollector(); - tu.accept(col); - IBinding methodb= col.getName(27).resolveBinding(); - IBinding methodc= col.getName(30).resolveBinding(); - assertEquals("method", methodb.getName()); - assertEquals("method", methodc.getName()); - assertInstance(methodb, ICPPMethod.class); - assertInstance(methodc, ICPPMethod.class); - assertEquals("A", ((ICPPMethod)methodb).getClassOwner().getName()); - assertEquals("A", ((ICPPMethod)methodc).getClassOwner().getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + IBinding methodb= col.getName(27).resolveBinding(); + IBinding methodc= col.getName(30).resolveBinding(); + assertEquals("method", methodb.getName()); + assertEquals("method", methodc.getName()); + assertInstance(methodb, ICPPMethod.class); + assertInstance(methodc, ICPPMethod.class); + assertEquals("A", ((ICPPMethod)methodb).getClassOwner().getName()); + assertEquals("A", ((ICPPMethod)methodc).getClassOwner().getName()); + + tu = validateCopy(tu); + } } // template @@ -3680,16 +3873,21 @@ public class AST2Tests extends AST2BaseTest { // }; public void test186736_variant1() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); - CNameCollector col = new CNameCollector(); - tu.accept(col); - IBinding methodA= col.getName(30).resolveBinding(); - IBinding methodAA= col.getName(33).resolveBinding(); - assertEquals("method", methodA.getName()); - assertEquals("method", methodAA.getName()); - assertInstance(methodA, ICPPMethod.class); - assertInstance(methodAA, ICPPMethod.class); - assertEquals("A", ((ICPPMethod)methodA).getClassOwner().getName()); - assertEquals("AA", ((ICPPMethod)methodAA).getClassOwner().getName()); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + IBinding methodA= col.getName(30).resolveBinding(); + IBinding methodAA= col.getName(33).resolveBinding(); + assertEquals("method", methodA.getName()); + assertEquals("method", methodAA.getName()); + assertInstance(methodA, ICPPMethod.class); + assertInstance(methodAA, ICPPMethod.class); + assertEquals("A", ((ICPPMethod)methodA).getClassOwner().getName()); + assertEquals("AA", ((ICPPMethod)methodAA).getClassOwner().getName()); + + tu = validateCopy(tu); + } } // class B { @@ -3713,6 +3911,7 @@ public class AST2Tests extends AST2BaseTest { // } public void test186736_variant2() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + validateCopy(tu); } // typedef int int32; @@ -3840,12 +4039,17 @@ public class AST2Tests extends AST2BaseTest { // class NameClash2 {}; public void testBug202271_nameClash() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings( getAboveComment(), ParserLanguage.CPP, true ); - CNameCollector col = new CNameCollector(); - tu.accept(col); - assertInstance(col.getName(0).resolveBinding(), ICPPClassType.class); - assertInstance(col.getName(1).resolveBinding(), ICPPNamespace.class); - assertInstance(col.getName(2).resolveBinding(), ICPPNamespace.class); - assertInstance(col.getName(3).resolveBinding(), ICPPClassType.class); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + assertInstance(col.getName(0).resolveBinding(), ICPPClassType.class); + assertInstance(col.getName(1).resolveBinding(), ICPPNamespace.class); + assertInstance(col.getName(2).resolveBinding(), ICPPNamespace.class); + assertInstance(col.getName(3).resolveBinding(), ICPPClassType.class); + + tu = validateCopy(tu); + } } // #define WRAP(var) var @@ -4023,28 +4227,33 @@ public class AST2Tests extends AST2BaseTest { // }; public void testBug210019_designatedInitializers() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); - CNameCollector col = new CNameCollector(); - tu.accept(col); - - assertField(col.getName(6).resolveBinding(), "f", "S1"); - assertField(col.getName(7).resolveBinding(), "i", "S1"); - assertField(col.getName(8).resolveBinding(), "a", "S1"); - - assertField(col.getName(18).resolveBinding(), "y", "S2"); - assertField(col.getName(19).resolveBinding(), "x", "S2"); - assertField(col.getName(20).resolveBinding(), "y", "S2"); - assertField(col.getName(21).resolveBinding(), "x", "S2"); - assertField(col.getName(22).resolveBinding(), "y", "S2"); - assertField(col.getName(23).resolveBinding(), "x", "S2"); - - assertField(col.getName(26).resolveBinding(), "x", "S2"); - assertField(col.getName(27).resolveBinding(), "y", "S2"); - assertField(col.getName(28).resolveBinding(), "x", "S2"); - assertField(col.getName(29).resolveBinding(), "y", "S2"); - assertField(col.getName(30).resolveBinding(), "y", "S2"); - - assertField(col.getName(33).resolveBinding(), "x", "S2"); - assertField(col.getName(34).resolveBinding(), "x", "S2"); + assertTrue(tu.isFrozen()); + for(int i = 0; i < NUM_TESTS; i++) { + CNameCollector col = new CNameCollector(); + tu.accept(col); + + assertField(col.getName(6).resolveBinding(), "f", "S1"); + assertField(col.getName(7).resolveBinding(), "i", "S1"); + assertField(col.getName(8).resolveBinding(), "a", "S1"); + + assertField(col.getName(18).resolveBinding(), "y", "S2"); + assertField(col.getName(19).resolveBinding(), "x", "S2"); + assertField(col.getName(20).resolveBinding(), "y", "S2"); + assertField(col.getName(21).resolveBinding(), "x", "S2"); + assertField(col.getName(22).resolveBinding(), "y", "S2"); + assertField(col.getName(23).resolveBinding(), "x", "S2"); + + assertField(col.getName(26).resolveBinding(), "x", "S2"); + assertField(col.getName(27).resolveBinding(), "y", "S2"); + assertField(col.getName(28).resolveBinding(), "x", "S2"); + assertField(col.getName(29).resolveBinding(), "y", "S2"); + assertField(col.getName(30).resolveBinding(), "y", "S2"); + + assertField(col.getName(33).resolveBinding(), "x", "S2"); + assertField(col.getName(34).resolveBinding(), "x", "S2"); + + tu = validateCopy(tu); + } } // extern "C" { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java index 436cc3e7d93..443417fb10a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler; import junit.framework.TestCase; import org.eclipse.cdt.core.dom.ast.IASTComment; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -141,5 +142,8 @@ public class NodeCommentMapTest extends TestCase { } //not used public boolean isBlockComment() {return false;} + public IASTNode copy() { + return null; + } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTASMDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTASMDeclaration.java index 8b2b66f2734..fb6578ee950 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTASMDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTASMDeclaration.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * ASM Statement as a Declaration. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTASMDeclaration extends IASTDeclaration { @@ -29,4 +30,10 @@ public interface IASTASMDeclaration extends IASTDeclaration { * @param assembly */ public void setAssembly(String assembly); + + + /** + * @since 5.1 + */ + public IASTASMDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayDeclarator.java index 175d423adcc..e43a756d56b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayDeclarator.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is the declarator for an array. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTArrayDeclarator extends IASTDeclarator { @@ -38,5 +39,10 @@ public interface IASTArrayDeclarator extends IASTDeclarator { * IASTArrayModifier to be added */ public void addArrayModifier(IASTArrayModifier arrayModifier); + + /** + * @since 5.1 + */ + public IASTArrayDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayModifier.java index 92a5765b6b6..e1112f4d0df 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArrayModifier.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * declares a variable/type which is an array. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTArrayModifier extends IASTNode { @@ -45,4 +46,8 @@ public interface IASTArrayModifier extends IASTNode { */ public void setConstantExpression(IASTExpression expression); + /** + * @since 5.1 + */ + public IASTArrayModifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java index 11c476920d2..13f29324c27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * y.z()[ t * t ] * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTArraySubscriptExpression extends IASTExpression { @@ -63,4 +64,8 @@ public interface IASTArraySubscriptExpression extends IASTExpression { */ public void setSubscriptExpression(IASTExpression expression); + /** + * @since 5.1 + */ + public IASTArraySubscriptExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java index 788969bd55a..59f97301a49 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * This interface represents a binary expression. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTBinaryExpression extends IASTExpression { @@ -258,4 +259,9 @@ public interface IASTBinaryExpression extends IASTExpression { * IASTExpression value */ public void setOperand2(IASTExpression expression); + + /** + * @since 5.1 + */ + public IASTBinaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java index a5e88efbab5..393e06fb171 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java @@ -14,7 +14,12 @@ package org.eclipse.cdt.core.dom.ast; * This is the break clause in a loop. * * @author Doug Schaefer + * @noimplement */ public interface IASTBreakStatement extends IASTStatement { + /** + * @since 5.1 + */ + public IASTBreakStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java index 52324bf9703..49eade63e28 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java @@ -17,6 +17,7 @@ package org.eclipse.cdt.core.dom.ast; * following this clause. * * @author Doug Schaefer + * @noimplement */ public interface IASTCaseStatement extends IASTStatement { @@ -40,4 +41,8 @@ public interface IASTCaseStatement extends IASTStatement { */ public void setExpression(IASTExpression expression); + /** + * @since 5.1 + */ + public IASTCaseStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java index db949469505..e4d5a36bf72 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCastExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This interface represents a cast expression of the form (TypeId)operand. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTCastExpression extends IASTExpression { @@ -83,4 +84,8 @@ public interface IASTCastExpression extends IASTExpression { */ public IASTTypeId getTypeId(); + /** + * @since 5.1 + */ + public IASTCastExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java index 39eba9d134e..71a5952c1ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * declarations). * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTNameOwner { @@ -96,4 +97,9 @@ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTName * */ public IScope getScope(); + + /** + * @since 5.1 + */ + public IASTCompositeTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java index b173c4a6db0..26f863277da 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This represents a block of statements. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTCompoundStatement extends IASTStatement { @@ -47,4 +48,9 @@ public interface IASTCompoundStatement extends IASTStatement { * @return the IScope */ public IScope getScope(); + + /** + * @since 5.1 + */ + public IASTCompoundStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTConditionalExpression.java index 5f157cda823..0c0fb22b1a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTConditionalExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Conditional Expression of the format X ? Y : Z * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTConditionalExpression extends IASTExpression { @@ -86,5 +87,10 @@ public interface IASTConditionalExpression extends IASTExpression { * IASTExpression */ public void setNegativeResultExpression(IASTExpression expression); + + /** + * @since 5.1 + */ + public IASTConditionalExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java index 05184648f49..5a98f227919 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java @@ -14,7 +14,12 @@ package org.eclipse.cdt.core.dom.ast; * This is the continue clause in a loop. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTContinueStatement extends IASTStatement { + /** + * @since 5.1 + */ + public IASTContinueStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java index 8725585db52..dff04eecdd7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is the base interface that represents a declaration specifier sequence. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDeclSpecifier extends IASTNode { @@ -124,5 +125,10 @@ public interface IASTDeclSpecifier extends IASTNode { * @return String */ public String getRawSignature(); + + /** + * @since 5.1 + */ + public IASTDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java index 792762043fc..aa386265797 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java @@ -14,8 +14,13 @@ package org.eclipse.cdt.core.dom.ast; * This is the root class of all declarations. * * @author Doug Schaefer + * @noimplement */ public interface IASTDeclaration extends IASTNode { public static final IASTDeclaration[] EMPTY_DECLARATION_ARRAY = new IASTDeclaration[0]; + /** + * @since 5.1 + */ + public IASTDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java index ab15fafc73b..8e8474e9892 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * A declaration statement that introduces a declaration. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDeclarationStatement extends IASTStatement { @@ -37,5 +38,10 @@ public interface IASTDeclarationStatement extends IASTStatement { * @param declaration */ public void setDeclaration(IASTDeclaration declaration); + + /** + * @since 5.1 + */ + public IASTDeclarationStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarator.java index 5abbf2e4cc1..5b6298d6ced 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarator.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Base interface for a declarator. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDeclarator extends IASTNode, IASTNameOwner { @@ -106,5 +107,10 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner { * IASTInitializer */ public void setInitializer(IASTInitializer initializer); + + /** + * @since 5.1 + */ + public IASTDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java index ce4f062f485..8b37a21080d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java @@ -17,7 +17,12 @@ package org.eclipse.cdt.core.dom.ast; * one statement following this clause. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDefaultStatement extends IASTStatement { + /** + * @since 5.1 + */ + public IASTDefaultStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java index 3f0e904f757..37c884193d5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Ye ol' do statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDoStatement extends IASTStatement { @@ -61,5 +62,10 @@ public interface IASTDoStatement extends IASTStatement { * an IASTExpression */ public void setCondition(IASTExpression condition); + + /** + * @since 5.1 + */ + public IASTDoStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java index 966848393d6..15075f19acc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This represents an elaborated type specifier in the C & C++ language grammar. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { @@ -74,4 +75,8 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName */ public void setName(IASTName name); + /** + * @since 5.1 + */ + public IASTElaboratedTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java index d50abe3ab84..422a5249e11 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This interface represents enumerations in C and C++. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner { @@ -21,6 +22,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn * This interface represents an enumerator member of an enum specifier. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTEnumerator extends IASTNode, IASTNameOwner { /** @@ -69,6 +71,11 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn * @return IASTExpression value */ public IASTExpression getValue(); + + /** + * @since 5.1 + */ + public IASTEnumerator copy(); } @@ -114,4 +121,8 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn */ public IASTName getName(); + /** + * @since 5.1 + */ + public IASTEnumerationSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java index 0f97025cc64..2a4e5a58dc4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is the root class of expressions. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTExpression extends IASTNode { /** @@ -23,4 +24,8 @@ public interface IASTExpression extends IASTNode { public IType getExpressionType(); + /** + * @since 5.1 + */ + public IASTExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java index 1467f0545ed..31244dbb89f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Expression List (Comma separated list of expressions). * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTExpressionList extends IASTExpression { @@ -39,4 +40,9 @@ public interface IASTExpressionList extends IASTExpression { * IASTExpression value to be added. */ public void addExpression(IASTExpression expression); + + /** + * @since 5.1 + */ + public IASTExpressionList copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionStatement.java index 43fc4e3540e..8c538e6e3d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Expression statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTExpressionStatement extends IASTStatement { @@ -37,4 +38,9 @@ public interface IASTExpressionStatement extends IASTStatement { * @param expression */ public void setExpression(IASTExpression expression); + + /** + * @since 5.1 + */ + public IASTExpressionStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldDeclarator.java index 87d6099796a..4446bda9e96 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldDeclarator.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * size for a bit field. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFieldDeclarator extends IASTDeclarator { @@ -41,4 +42,8 @@ public interface IASTFieldDeclarator extends IASTDeclarator { */ public void setBitFieldSize(IASTExpression size); + /** + * @since 5.1 + */ + public IASTFieldDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java index cb4495e1081..faf5e0e72e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java @@ -16,6 +16,7 @@ package org.eclipse.cdt.core.dom.ast; * expression, def is the field name. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFieldReference extends IASTExpression, IASTNameOwner { @@ -78,5 +79,10 @@ public interface IASTFieldReference extends IASTExpression, IASTNameOwner { * boolean */ public void setIsPointerDereference(boolean value); + + /** + * @since 5.1 + */ + public IASTFieldReference copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTForStatement.java index 779da13f292..d4b90e1472c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTForStatement.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * declaration but not both. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTForStatement extends IASTStatement { @@ -111,4 +112,9 @@ public interface IASTForStatement extends IASTStatement { * @return IScope */ public IScope getScope(); + + /** + * @since 5.1 + */ + public IASTForStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java index 1ef536dd2a8..04e3f6c2319 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * function name expression, x is the parameter expression. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFunctionCallExpression extends IASTExpression { @@ -63,5 +64,10 @@ public interface IASTFunctionCallExpression extends IASTExpression { * @return IASTExpression representing the parameters */ public IASTExpression getParameterExpression(); + + /** + * @since 5.1 + */ + public IASTFunctionCallExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDeclarator.java index 7e80986550f..4a14698d62b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDeclarator.java @@ -14,7 +14,12 @@ package org.eclipse.cdt.core.dom.ast; * This is a declarator for a function. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFunctionDeclarator extends IASTDeclarator { + /** + * @since 5.1 + */ + public IASTFunctionDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java index 905436961f1..be78521f2ef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is a function definition, i.e. it has a body. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFunctionDefinition extends IASTDeclaration { @@ -98,4 +99,9 @@ public interface IASTFunctionDefinition extends IASTDeclaration { * @return IScope representing function body. */ public IScope getScope(); + + /** + * @since 5.1 + */ + public IASTFunctionDefinition copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionStyleMacroParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionStyleMacroParameter.java index af61a205a2b..02c3cefbde5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionStyleMacroParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionStyleMacroParameter.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * is not an IASTName, as there are not any bindings for * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTFunctionStyleMacroParameter extends IASTNode { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTGotoStatement.java index 2f48df69cd1..a3056b8f505 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTGotoStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Represents a goto statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTGotoStatement extends IASTStatement, IASTNameOwner { @@ -33,5 +34,10 @@ public interface IASTGotoStatement extends IASTStatement, IASTNameOwner { * IASTName */ public void setName(IASTName name); + + /** + * @since 5.1 + */ + public IASTGotoStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIdExpression.java index 2e47ba39ec8..1ad9a1b4e6d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIdExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is a name used in an expression. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTIdExpression extends IASTExpression, IASTNameOwner { @@ -37,4 +38,9 @@ public interface IASTIdExpression extends IASTExpression, IASTNameOwner { * @param name */ public void setName(IASTName name); + + /** + * @since 5.1 + */ + public IASTIdExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIfStatement.java index f734b4238b6..7d431665df6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTIfStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * The if statement including the optional else clause. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTIfStatement extends IASTStatement { @@ -84,4 +85,8 @@ public interface IASTIfStatement extends IASTStatement { */ public void setElseClause(IASTStatement elseClause); + /** + * @since 5.1 + */ + public IASTIfStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializer.java index e5bf9666f9d..0e1b1723b84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializer.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This represents an initializer for a declarator. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTInitializer extends IASTNode { @@ -22,4 +23,8 @@ public interface IASTInitializer extends IASTNode { */ public final static IASTInitializer[] EMPTY_INITIALIZER_ARRAY = new IASTInitializer[0]; + /** + * @since 5.1 + */ + public IASTInitializer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java index a029e78614b..d284589b419 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is an initializer that is simply an expression. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTInitializerExpression extends IASTInitializer { @@ -38,4 +39,9 @@ public interface IASTInitializerExpression extends IASTInitializer { * IASTExpression */ public void setExpression(IASTExpression expression); + + /** + * @since 5.1 + */ + public IASTInitializerExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java index 6756e48f8bc..25cf799af57 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is an an initializer that is a list of initializers. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTInitializerList extends IASTInitializer { @@ -38,4 +39,9 @@ public interface IASTInitializerList extends IASTInitializer { * IASTInitializer */ public void addInitializer(IASTInitializer initializer); + + /** + * @since 5.1 + */ + public IASTInitializerList copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java index 3e912213f46..c319db00350 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLabelStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Represents a label statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTLabelStatement extends IASTStatement, IASTNameOwner { @@ -41,5 +42,10 @@ public interface IASTLabelStatement extends IASTStatement, IASTNameOwner { * @param s */ public void setNestedStatement( IASTStatement s ); + + /** + * @since 5.1 + */ + public IASTLabelStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java index b38a062f0a1..8e6172d850b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java @@ -95,5 +95,10 @@ public interface IASTLiteralExpression extends IASTExpression { * @deprecated, use {@link #setValue(char[])}, instead. */ public void setValue(String value); + + /** + * @since 5.1 + */ + public IASTLiteralExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java index 04bbe3f2444..69be975a7c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java @@ -95,4 +95,9 @@ public interface IASTName extends IASTNode, IName { * @since 5.1 */ public IASTName getLastName(); + + /** + * @since 5.1 + */ + public IASTName copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java index 9e4c538cee8..4067770cc3c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * class/struct/union names in C. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { @@ -39,4 +40,8 @@ public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner */ public void setName(IASTName name); + /** + * @since 5.1 + */ + public IASTNamedTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java index 64835ded59e..cc86a5a3302 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java @@ -193,4 +193,23 @@ public interface IASTNode { * @since 5.1 */ public boolean isFrozen(); + + + /** + * Returns a copy of the tree rooted at this node. + * The following postconditions hold: + * + * + * copy.getParent() == null + * copy.getPropertyInParent() == null + * copy.isFrozen() == false + * + * + * Preprocessor nodes do not currently support being copied. + * + * @since 5.1 + * @throws UnsupportedOperationException if this node or one of its descendants + * does not support copying + */ + public IASTNode copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNullStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNullStatement.java index 167bb447518..a8be6170c3e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNullStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNullStatement.java @@ -14,7 +14,12 @@ package org.eclipse.cdt.core.dom.ast; * This node represents a null statement. ';' * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTNullStatement extends IASTStatement { + /** + * @since 5.1 + */ + public IASTNullStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java index d142052cf33..da896b03caf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This class represents a parameter declaration * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTParameterDeclaration extends IASTNode { /** @@ -67,4 +68,8 @@ public interface IASTParameterDeclaration extends IASTNode { */ public void setDeclarator(IASTDeclarator declarator); + /** + * @since 5.1 + */ + public IASTParameterDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointer.java index 208247ef8b3..d7826fd41cc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointer.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This represents the good ol' * pointer operator. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTPointer extends IASTPointerOperator { @@ -47,5 +48,11 @@ public interface IASTPointer extends IASTPointerOperator { * the value */ public void setVolatile(boolean value); + + + /** + * @since 5.1 + */ + public IASTPointer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java index 0dffcc52e02..4f1c4120eb1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast; /** * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTPointerOperator extends IASTNode { @@ -20,4 +21,8 @@ public interface IASTPointerOperator extends IASTNode { */ public static final IASTPointerOperator[] EMPTY_ARRAY = new IASTPointerOperator[0]; + /** + * @since 5.1 + */ + public IASTPointerOperator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java index ff9f596dce4..8166fb68cfb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java @@ -15,6 +15,12 @@ import org.eclipse.cdt.core.parser.IProblem; /** * Interface for problems in the ast tree. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTProblem extends IProblem, IASTNode { + + /** + * @since 5.1 + */ + public IASTProblem copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemDeclaration.java index 4d73dbab916..3f6701ca0a0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemDeclaration.java @@ -15,8 +15,12 @@ package org.eclipse.cdt.core.dom.ast; * declaration. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTProblemDeclaration extends IASTDeclaration, - IASTProblemHolder { +public interface IASTProblemDeclaration extends IASTDeclaration, IASTProblemHolder { + /** + * @since 5.1 + */ + public IASTProblemDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemExpression.java index 7b410d813bd..289601a1560 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemExpression.java @@ -15,8 +15,12 @@ package org.eclipse.cdt.core.dom.ast; * expression. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTProblemExpression extends IASTExpression, - IASTProblemHolder { +public interface IASTProblemExpression extends IASTExpression, IASTProblemHolder { + /** + * @since 5.1 + */ + public IASTProblemExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemHolder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemHolder.java index d33efb84d58..e5acaa1d714 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemHolder.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemHolder.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * holder. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTProblemHolder { /** @@ -37,4 +38,5 @@ public interface IASTProblemHolder { * IASTProblem */ public void setProblem(IASTProblem p); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemStatement.java index bd1ec5b7380..bceec03d63e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemStatement.java @@ -15,7 +15,12 @@ package org.eclipse.cdt.core.dom.ast; * statement. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTProblemStatement extends IASTStatement, IASTProblemHolder { + /** + * @since 5.1 + */ + public IASTProblemStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemTypeId.java index b453e3735f3..7944589d02a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblemTypeId.java @@ -15,7 +15,12 @@ package org.eclipse.cdt.core.dom.ast; * type-id. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTProblemTypeId extends IASTTypeId, IASTProblemHolder { + /** + * @since 5.1 + */ + public IASTProblemTypeId copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java index bc37fa75538..fcc331ae34b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast; /** * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTReturnStatement extends IASTStatement { @@ -38,4 +39,8 @@ public interface IASTReturnStatement extends IASTStatement { */ public void setReturnValue(IASTExpression returnValue); + /** + * @since 5.1 + */ + public IASTReturnStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java index 4c059398c62..56ee6a1a18c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This represents a decl specifier for a built-in type. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { @@ -129,5 +130,10 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { * boolean */ public void setShort(boolean value); + + /** + * @since 5.1 + */ + public IASTSimpleDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclaration.java index 857b8300e4a..a6d66081064 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclaration.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * followed by a list of declarators. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTSimpleDeclaration extends IASTDeclaration { @@ -65,4 +66,8 @@ public interface IASTSimpleDeclaration extends IASTDeclaration { */ public void addDeclarator(IASTDeclarator declarator); + /** + * @since 5.1 + */ + public IASTSimpleDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java index 1c3bc04768c..82b1fd5eb6c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This is a declarator for a non K&R C function. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator { @@ -54,4 +55,9 @@ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator { * boolean */ public void setVarArgs(boolean value); + + /** + * @since 5.1 + */ + public IASTStandardFunctionDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java index 116551ed07e..79f3fff7323 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java @@ -14,11 +14,17 @@ package org.eclipse.cdt.core.dom.ast; * This is the root interface for statements. * * @author Doug Schaefer + * @noimplement */ public interface IASTStatement extends IASTNode { /** * Constant. */ public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = new IASTStatement[0]; + + /** + * @since 5.1 + */ + public IASTStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java index 6b73647ed47..0b8be619594 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * The switch statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTSwitchStatement extends IASTStatement { @@ -64,4 +65,8 @@ public interface IASTSwitchStatement extends IASTStatement { */ public void setBody(IASTStatement body); + /** + * @since 5.1 + */ + public IASTSwitchStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java index fa6d3ab262b..4b781f6667b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java @@ -292,4 +292,16 @@ public interface IASTTranslationUnit extends IASTNode, IAdaptable { * @since 5.1 */ public void freeze(); + + + /** + * Returns a copy of the AST, however the ILocationResolver + * and the preprocessor nodes are not copied. + * + * @see IASTNode#copy() + * + * @noreference This method is not intended to be referenced by clients. + * @since 5.1 + */ + public IASTTranslationUnit copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java index 396ba9e81a7..e3e94ac7043 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTTypeId extends IASTNode { @@ -58,4 +59,9 @@ public interface IASTTypeId extends IASTNode { * @param abstractDeclarator IASTDeclarator */ public void setAbstractDeclarator(IASTDeclarator abstractDeclarator); + + /** + * @since 5.1 + */ + public IASTTypeId copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java index 2401e0fc5bf..ca41adff808 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTTypeIdExpression extends IASTExpression { @@ -75,4 +76,8 @@ public interface IASTTypeIdExpression extends IASTExpression { */ public IASTTypeId getTypeId(); + /** + * @since 5.1 + */ + public IASTTypeIdExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java index fccc2787627..d354582d705 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * This interface is used to represent a unary expression in the AST. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTUnaryExpression extends IASTExpression { @@ -152,4 +153,8 @@ public interface IASTUnaryExpression extends IASTExpression { */ public void setOperand(IASTExpression expression); + /** + * @since 5.1 + */ + public IASTUnaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java index 43c84ddf1e8..f81220388fd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast; * Ye ol' while statement. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTWhileStatement extends IASTStatement { @@ -58,4 +59,8 @@ public interface IASTWhileStatement extends IASTStatement { */ public void setBody(IASTStatement body); + /** + * @since 5.1 + */ + public IASTWhileStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java index 29ccd86ebfa..ef8df960b7f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; * instance = { def[0] = 9 }; * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTArrayDesignator extends ICASTDesignator { @@ -43,4 +44,8 @@ public interface ICASTArrayDesignator extends ICASTDesignator { */ public void setSubscriptExpression(IASTExpression value); + /** + * @since 5.1 + */ + public ICASTArrayDesignator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayModifier.java index 4b0faf60e09..ca2939b882e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayModifier.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; * modifiers (const, restrict, etc.) as well as variable sized arrays. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTArrayModifier extends IASTArrayModifier { @@ -94,4 +95,9 @@ public interface ICASTArrayModifier extends IASTArrayModifier { * boolean */ public void setVariableSized(boolean value); + + /** + * @since 5.1 + */ + public ICASTArrayModifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTCompositeTypeSpecifier.java index bec66f24b01..4195c00f031 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTCompositeTypeSpecifier.java @@ -16,8 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; * Structs and Unions in C can be qualified w/restrict keyword. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifier, ICASTDeclSpecifier { + /** + * @since 5.1 + */ + public ICASTCompositeTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java index 940d3678ae1..844b3a73761 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; * C extension to IASTDeclSpecifier. (restrict keyword) * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTDeclSpecifier extends IASTDeclSpecifier { @@ -32,5 +33,10 @@ public interface ICASTDeclSpecifier extends IASTDeclSpecifier { * @param value */ public void setRestrict(boolean value); + + /** + * @since 5.1 + */ + public ICASTDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java index ab090b6c712..91708806bf4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer; * .t[1] = 3 }; * * @author jcamelon - * + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTDesignatedInitializer extends IASTInitializer { @@ -72,4 +72,9 @@ public interface ICASTDesignatedInitializer extends IASTInitializer { * IASTInitializer */ public void setOperandInitializer(IASTInitializer rhs); + + /** + * @since 5.1 + */ + public ICASTDesignatedInitializer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java index 77b31ffed18..0b4bde3a738 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java @@ -16,7 +16,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * Base interface for all C-style designators. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTDesignator extends IASTNode { + /** + * @since 5.1 + */ + public ICASTDesignator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTElaboratedTypeSpecifier.java index 5cc864ebe36..dba522d671d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTElaboratedTypeSpecifier.java @@ -17,8 +17,13 @@ import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; * for the addition of the restrict keyword. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTElaboratedTypeSpecifier extends IASTElaboratedTypeSpecifier, ICASTDeclSpecifier { + /** + * @since 5.1 + */ + public ICASTElaboratedTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTEnumerationSpecifier.java index 899642a9024..8b4299dbc0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTEnumerationSpecifier.java @@ -16,8 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; * C Enumeration decl specifier. Allows for "restrict enum X { a, b, c }; * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTEnumerationSpecifier extends ICASTDeclSpecifier, IASTEnumerationSpecifier { + /** + * @since 5.1 + */ + public ICASTEnumerationSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTFieldDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTFieldDesignator.java index 12ad0758806..b2ccd454f38 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTFieldDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTFieldDesignator.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName; * Specific Designator that represents a field reference. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTFieldDesignator extends ICASTDesignator { @@ -41,4 +42,9 @@ public interface ICASTFieldDesignator extends ICASTDesignator { * IASTName */ public void setName(IASTName name); + + /** + * @since 5.1 + */ + public ICASTFieldDesignator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTPointer.java index 1059f914cda..56c25324f9c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTPointer.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer; * C-specific pointer. (includes restrict modifier). * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTPointer extends IASTPointer { @@ -32,5 +33,10 @@ public interface ICASTPointer extends IASTPointer { * @param value */ void setRestrict(boolean value); + + /** + * @since 5.1 + */ + public ICASTPointer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java index f3c2ade8799..094486c292b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTSimpleDeclSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; * This interface represents a built-in type in C. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICASTDeclSpecifier { @@ -70,5 +71,10 @@ public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, * boolean */ public void setLongLong(boolean value); + + /** + * @since 5.1 + */ + public ICASTSimpleDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypeIdInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypeIdInitializerExpression.java index 91553a864c4..3bd1c74ff69 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypeIdInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypeIdInitializerExpression.java @@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * C Expression of the format type-id { initializer } * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. + * */ public interface ICASTTypeIdInitializerExpression extends IASTExpression { @@ -66,5 +68,10 @@ public interface ICASTTypeIdInitializerExpression extends IASTExpression { * IASTInitializer */ public void setInitializer(IASTInitializer initializer); + + /** + * @since 5.1 + */ + public ICASTTypeIdInitializerExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypedefNameSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypedefNameSpecifier.java index 92e643e838b..5b0ca70738a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypedefNameSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTTypedefNameSpecifier.java @@ -17,8 +17,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; * includes the abiliy to use the restrict modifier. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICASTTypedefNameSpecifier extends IASTNamedTypeSpecifier, - ICASTDeclSpecifier { +public interface ICASTTypedefNameSpecifier extends IASTNamedTypeSpecifier, ICASTDeclSpecifier { + /** + * @since 5.1 + */ + public ICASTTypedefNameSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java index 756ffdd8426..ecac9bad98e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; * C++ adds a few more binary expressions over C. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTBinaryExpression extends IASTBinaryExpression { @@ -35,4 +36,9 @@ public interface ICPPASTBinaryExpression extends IASTBinaryExpression { */ @Deprecated public static final int op_last = IASTBinaryExpression.op_last; + + /** + * @since 5.1 + */ + public ICPPASTBinaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java index b1cd1c4af51..2f58620a723 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCastExpression; * C++ adds in additional cast-style expressions. * * @author jcamelon + * @noimplement */ public interface ICPPASTCastExpression extends IASTCastExpression { @@ -43,4 +44,10 @@ public interface ICPPASTCastExpression extends IASTCastExpression { * op_last is for subinterfaces to extend. */ public static final int op_last = op_const_cast; + + + /** + * @since 5.1 + */ + public ICPPASTCastExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java index 5372e80133f..4943433d3e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; * @see ICPPASTFunctionWithTryBlock * @see ICPPASTTryBlockStatement * - * @noimplement This interface is not intended to be implemented by clients. + * @noimplement */ public interface ICPPASTCatchHandler extends IASTStatement { @@ -73,4 +73,9 @@ public interface ICPPASTCatchHandler extends IASTStatement { * @since 5.1 */ public IScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTCatchHandler copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java index 1149d72cca7..bd88be36192 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java @@ -51,6 +51,7 @@ public interface ICPPASTCompositeTypeSpecifier extends * Base Specifiers are where a class expresses from whom it inherits. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner { /** @@ -125,6 +126,11 @@ public interface ICPPASTCompositeTypeSpecifier extends * IASTName */ public void setName(IASTName name); + + /** + * @since 5.1 + */ + public ICPPASTBaseSpecifier copy(); } /** @@ -146,4 +152,9 @@ public interface ICPPASTCompositeTypeSpecifier extends * @since 5.1 */ public ICPPClassScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTCompositeTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java index 3b26a9b9fb7..49cbec33945 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java @@ -23,6 +23,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * X(); * }; * X::X : a(0) {} // a(0) is a constructor chain initializer. + * + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTConstructorChainInitializer extends IASTInitializer, IASTNameOwner { /** @@ -73,4 +75,8 @@ public interface ICPPASTConstructorChainInitializer extends IASTInitializer, IAS */ public void setInitializerValue(IASTExpression expression); + /** + * @since 5.1 + */ + public ICPPASTConstructorChainInitializer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java index 4e1e02a32e2..bd8166e7271 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer; * This is an initializer that is a call to the constructor for the declarator. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTConstructorInitializer extends IASTInitializer { @@ -42,4 +43,8 @@ public interface ICPPASTConstructorInitializer extends IASTInitializer { */ public void setExpression(IASTExpression expression); + /** + * @since 5.1 + */ + public ICPPASTConstructorInitializer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConversionName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConversionName.java index 2c77d35e3b4..bf64ad12d8e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConversionName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConversionName.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * This interface represents a C++ conversion member function. * * @author dsteffle + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTConversionName extends IASTName { public static final ASTNodeProperty TYPE_ID=new ASTNodeProperty( @@ -37,4 +38,9 @@ public interface ICPPASTConversionName extends IASTName { * @param typeId */ public void setTypeId(IASTTypeId typeId); + + /** + * @since 5.1 + */ + public ICPPASTConversionName copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java index 2c555cb5b98..f5975290bb9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; * C++ adds additional modifiers and types for decl specifier sequence. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { @@ -75,5 +76,10 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { * boolean */ public void setExplicit(boolean value); + + /** + * @since 5.1 + */ + public ICPPASTDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeleteExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeleteExpression.java index cdfd4de41a1..620a9584d7b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeleteExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeleteExpression.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; * This interface represents a delete expression. delete [] operand; * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTDeleteExpression extends IASTExpression { @@ -69,4 +70,10 @@ public interface ICPPASTDeleteExpression extends IASTExpression { */ public boolean isVectored(); + + /** + * @since 5.1 + */ + public ICPPASTDeleteExpression copy(); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTElaboratedTypeSpecifier.java index 1712efdb464..317281b10fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTElaboratedTypeSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; * Elaborated types in C++ include classes. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTElaboratedTypeSpecifier extends IASTElaboratedTypeSpecifier, ICPPASTDeclSpecifier { @@ -29,5 +30,10 @@ public interface ICPPASTElaboratedTypeSpecifier extends * k_last is defined for subinterfaces. */ public static final int k_last = k_class; + + /** + * @since 5.1 + */ + public ICPPASTElaboratedTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExplicitTemplateInstantiation.java index 4692fbb2f47..5a6c1f20639 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExplicitTemplateInstantiation.java @@ -17,6 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * This interface represents an explict template instantiation. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. + * */ public interface ICPPASTExplicitTemplateInstantiation extends IASTDeclaration { @@ -42,4 +44,8 @@ public interface ICPPASTExplicitTemplateInstantiation extends IASTDeclaration { */ public void setDeclaration(IASTDeclaration declaration); + /** + * @since 5.1 + */ + public ICPPASTExplicitTemplateInstantiation copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java index be0c08a6af0..015f6fb7893 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFieldReference; * specify the parse. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTFieldReference extends IASTFieldReference { @@ -32,5 +33,10 @@ public interface ICPPASTFieldReference extends IASTFieldReference { * @param value */ public void setIsTemplate(boolean value); + + /** + * @since 5.1 + */ + public ICPPASTFieldReference copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTForStatement.java index fa617ff8b9b..ba3ae0f1a5a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTForStatement.java @@ -14,10 +14,19 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTForStatement; +/** + * + * + * @noimplement This interface is not intended to be implemented by clients. + */ public interface ICPPASTForStatement extends IASTForStatement { public static final ASTNodeProperty CONDITION_DECLARATION = new ASTNodeProperty( "org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement"); //$NON-NLS-1$ public void setConditionDeclaration( IASTDeclaration d ); public IASTDeclaration getConditionDeclaration(); + /** + * @since 5.1 + */ + public ICPPASTForStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java index 20e3b037826..189f217a613 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java @@ -103,4 +103,9 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato @Deprecated public void addConstructorToChain(ICPPASTConstructorChainInitializer initializer); + + /** + * @since 5.1 + */ + public ICPPASTFunctionDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java index 32481635936..57f3b730e3b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java @@ -37,4 +37,9 @@ public interface ICPPASTFunctionDefinition extends IASTFunctionDefinition { * Adds a member initializer to this function definition. */ public void addMemberInitializer(ICPPASTConstructorChainInitializer initializer); + + /** + * @since 5.1 + */ + public ICPPASTFunctionDefinition copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionTryBlockDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionTryBlockDeclarator.java index cae34e2c4ba..ffc45aa2df2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionTryBlockDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionTryBlockDeclarator.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; /** * @deprecated, use {@link ICPPASTFunctionWithTryBlock}, instead. + * @noimplement This interface is not intended to be implemented by clients. */ @Deprecated public interface ICPPASTFunctionTryBlockDeclarator extends @@ -41,4 +42,9 @@ public interface ICPPASTFunctionTryBlockDeclarator extends * @return ICPPASTCatchHandler */ public ICPPASTCatchHandler[] getCatchHandlers(); + + /** + * @since 5.1 + */ + public ICPPASTFunctionTryBlockDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java index 39721ba81aa..7316f4009bd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java @@ -39,5 +39,10 @@ public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition { * Returns an array of catch handlers. */ public ICPPASTCatchHandler[] getCatchHandlers(); + + /** + * @since 5.1 + */ + public ICPPASTFunctionWithTryBlock copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTIfStatement.java index de3cf69a7eb..7b5b517f9f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTIfStatement.java @@ -14,6 +14,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IScope; +/** + * + * @noimplement This interface is not intended to be implemented by clients. + * + */ public interface ICPPASTIfStatement extends IASTIfStatement { public IASTDeclaration getConditionDeclaration(); @@ -25,4 +30,9 @@ public interface ICPPASTIfStatement extends IASTIfStatement { * @return IScope */ public IScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTIfStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLinkageSpecification.java index fe958db5f0e..0c99233b557 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLinkageSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLinkageSpecification.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * This interface represents a linkage specification. e.g. extern "C" { ... } * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTLinkageSpecification extends IASTDeclaration { @@ -56,4 +57,9 @@ public interface ICPPASTLinkageSpecification extends IASTDeclaration { * IASTDeclaration */ public void addDeclaration(IASTDeclaration declaration); + + /** + * @since 5.1 + */ + public ICPPASTLinkageSpecification copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java index ec366f6c9c1..d89c67a1ace 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java @@ -38,4 +38,10 @@ public interface ICPPASTLiteralExpression extends IASTLiteralExpression { * lk_last is maintained for future subinterfaces. */ public static final int lk_last = lk_false; + + + /** + * @since 5.1 + */ + public ICPPASTLiteralExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamedTypeSpecifier.java index e88ded42b5b..918f1535f49 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamedTypeSpecifier.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; * typename. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNamedTypeSpecifier extends IASTNamedTypeSpecifier, ICPPASTDeclSpecifier { @@ -35,5 +36,10 @@ public interface ICPPASTNamedTypeSpecifier extends IASTNamedTypeSpecifier, * boolean */ public void setIsTypename(boolean value); + + /** + * @since 5.1 + */ + public ICPPASTNamedTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java index fbb7e1c16ce..79730be627c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * x; } namspace DEF = ABC; * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner { @@ -66,5 +67,11 @@ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner { * IASTName */ public void setMappingName(IASTName qualifiedName); + + + /** + * @since 5.1 + */ + public ICPPASTNamespaceAlias copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java index 83d5600081a..d2352bafccd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; * This interface repesents a namespace definition in C++. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner { @@ -73,4 +74,9 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn * @return IScope */ public IScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTNamespaceDefinition copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java index c560b0eec3f..adb5d0532f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * This interface represents a new expression. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNewExpression extends IASTExpression { @@ -126,5 +127,11 @@ public interface ICPPASTNewExpression extends IASTExpression { */ @Deprecated public void addNewTypeIdArrayExpression(IASTExpression expression); + + + /** + * @since 5.1 + */ + public ICPPASTNewExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTOperatorName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTOperatorName.java index d36026aa8fc..ce95d2acf33 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTOperatorName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTOperatorName.java @@ -15,6 +15,12 @@ import org.eclipse.cdt.core.dom.ast.IASTName; /** * This interface represents a C++ overloaded operator member function name. + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTOperatorName extends IASTName { + + /** + * @since 5.1 + */ + public ICPPASTOperatorName copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java index 8cdacd362f0..caed816cb00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java @@ -14,8 +14,13 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTParameterDeclaration extends ICPPASTTemplateParameter, IASTParameterDeclaration { + /** + * @since 5.1 + */ + public ICPPASTParameterDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPointerToMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPointerToMember.java index 1db2abca857..e7450c47487 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPointerToMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTPointerToMember.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer; * This is a pointer to member pointer operator for declarators. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTPointerToMember extends IASTPointer, IASTNameOwner { @@ -41,5 +42,10 @@ public interface ICPPASTPointerToMember extends IASTPointer, IASTNameOwner { * @return IASTName */ public IASTName getName(); + + /** + * @since 5.1 + */ + public ICPPASTPointerToMember copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java index c8ddba7c932..62c3d38009b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * This interface is a qualified name in C++. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner { @@ -69,4 +70,9 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner { * */ public boolean isConversionOrOperator(); + + /** + * @since 5.1 + */ + public ICPPASTQualifiedName copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java index 015faa7c511..04017bc430d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java @@ -16,7 +16,12 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; * This is C++'s reference operator, i.e. &, used in a declarator. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTReferenceOperator extends IASTPointerOperator { - + + /** + * @since 5.1 + */ + public ICPPASTReferenceOperator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java index 83b8407197c..e904db2fe1d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleDeclSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; * This interface represents a built-in type in C++. * * @author Doug Schaefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICPPASTDeclSpecifier { @@ -34,5 +35,10 @@ public interface ICPPASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, * t_last is specified for subinterfaces. */ public static final int t_last = t_wchar_t; + + /** + * @since 5.1 + */ + public ICPPASTSimpleDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java index 35fecce7555..4ec30bd4fee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; * Simple type constructor postfix expression. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTSimpleTypeConstructorExpression extends IASTExpression { @@ -121,4 +122,8 @@ public interface ICPPASTSimpleTypeConstructorExpression extends IASTExpression { */ public void setInitialValue(IASTExpression expression); + /** + * @since 5.1 + */ + public ICPPASTSimpleTypeConstructorExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java index 2ad61769f10..b140ac6066d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * This interface represents a simple type template parameter. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTSimpleTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner { @@ -89,5 +90,10 @@ public interface ICPPASTSimpleTypeTemplateParameter extends * IASTTypeId */ public void setDefaultType(IASTTypeId typeId); + + /** + * @since 5.1 + */ + public ICPPASTSimpleTypeTemplateParameter copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSwitchStatement.java index 217d3a2615c..f152932667c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSwitchStatement.java @@ -15,6 +15,10 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement; import org.eclipse.cdt.core.dom.ast.IScope; +/** + * + * @noimplement This interface is not intended to be implemented by clients. + */ public interface ICPPASTSwitchStatement extends IASTSwitchStatement { /** @@ -46,4 +50,8 @@ public interface ICPPASTSwitchStatement extends IASTSwitchStatement { */ public IScope getScope(); + /** + * @since 5.1 + */ + public ICPPASTSwitchStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java index 57add73bc39..9b7154ab62a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * Template declaration. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateDeclaration extends IASTDeclaration { @@ -83,4 +84,9 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration { * @return ICPPTemplateScope */ public ICPPTemplateScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTTemplateDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateId.java index 1485149a186..097df9ce7e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateId.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateId extends IASTName, IASTNameOwner { @@ -82,5 +83,10 @@ public interface ICPPASTTemplateId extends IASTName, IASTNameOwner { * @return IASTNode [] */ public IASTNode[] getTemplateArguments(); + + /** + * @since 5.1 + */ + public ICPPASTTemplateId copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java index 9b5dd74c771..bc7684f0151 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * Base interface for all template parameters. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateParameter extends IASTNode { /** @@ -23,4 +24,8 @@ public interface ICPPASTTemplateParameter extends IASTNode { */ public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0]; + /** + * @since 5.1 + */ + public ICPPASTTemplateParameter copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateSpecialization.java index ef890c856ff..baedf48c5f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateSpecialization.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * This interface represents a template specialization. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateSpecialization extends IASTDeclaration { @@ -41,4 +42,8 @@ public interface ICPPASTTemplateSpecialization extends IASTDeclaration { */ public void setDeclaration(IASTDeclaration declaration); + /** + * @since 5.1 + */ + public ICPPASTTemplateSpecialization copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java index a086f98c2a8..0701739067a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * This is a templated template parameter. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplatedTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner { @@ -85,4 +86,9 @@ public interface ICPPASTTemplatedTypeTemplateParameter extends * IASTExpression */ public void setDefaultValue(IASTExpression expression); + + /** + * @since 5.1 + */ + public ICPPASTTemplatedTypeTemplateParameter copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTranslationUnit.java index 3584b91562b..46d145343ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTranslationUnit.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; /** * @author aniefer + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTranslationUnit extends IASTTranslationUnit { @@ -28,4 +29,9 @@ public interface ICPPASTTranslationUnit extends IASTTranslationUnit { */ public IBinding resolveBinding(); + + /** + * @since 5.1 + */ + public ICPPASTTranslationUnit copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java index c2ddc564e10..7f499d1eaad 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; * } * * @author jcamelon - * + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTryBlockStatement extends IASTStatement { @@ -63,5 +63,10 @@ public interface ICPPASTTryBlockStatement extends IASTStatement { * @return ICPPASTCatchHandler [] */ public ICPPASTCatchHandler[] getCatchHandlers(); + + /** + * @since 5.1 + */ + public ICPPASTTryBlockStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeIdExpression.java index d4f2a5a7472..b04124a81a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypeIdExpression.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTypeIdExpression extends IASTTypeIdExpression { @@ -25,4 +26,10 @@ public interface ICPPASTTypeIdExpression extends IASTTypeIdExpression { */ @Deprecated public static final int op_last = IASTTypeIdExpression.op_last; + + + /** + * @since 5.1 + */ + public ICPPASTTypeIdExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java index d871986ac88..c93dbd04885 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner { @@ -76,5 +77,10 @@ public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner * @return IASTExpression */ public IASTExpression getInitialValue(); + + /** + * @since 5.1 + */ + public ICPPASTTypenameExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java index 40deacb8837..ce20becdbae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; /** * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTUnaryExpression extends IASTUnaryExpression { @@ -32,4 +33,9 @@ public interface ICPPASTUnaryExpression extends IASTUnaryExpression { */ @Deprecated public static final int op_last = IASTUnaryExpression.op_last; + + /** + * @since 5.1 + */ + public ICPPASTUnaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDeclaration.java index 946959eb129..11441742658 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDeclaration.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * This interface represents a using declaration. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTUsingDeclaration extends IASTDeclaration, IASTNameOwner { @@ -57,4 +58,8 @@ public interface ICPPASTUsingDeclaration extends IASTDeclaration, IASTNameOwner */ public void setName(IASTName name); + /** + * @since 5.1 + */ + public ICPPASTUsingDeclaration copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java index 57251f9df42..912580c302a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUsingDirective.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * This interface represents a C++ using directive. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner { /** @@ -47,5 +48,10 @@ public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner { * IASTName */ public void setQualifiedName(IASTName qualifiedName); + + /** + * @since 5.1 + */ + public ICPPASTUsingDirective copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java index c7def696ff2..e03f069df61 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * specifiers. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTVisibilityLabel extends IASTDeclaration { @@ -50,4 +51,9 @@ public interface ICPPASTVisibilityLabel extends IASTDeclaration { */ public void setVisibility(int visibility); + + /** + * @since 5.1 + */ + public ICPPASTVisibilityLabel copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java index 0c2255b0c70..dc0b3b96579 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; * This inteface accommodates C++ allows for broader while loop syntax. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTWhileStatement extends IASTWhileStatement { @@ -49,4 +50,9 @@ public interface ICPPASTWhileStatement extends IASTWhileStatement { * @return IScope */ public IScope getScope(); + + /** + * @since 5.1 + */ + public ICPPASTWhileStatement copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTCompoundStatementExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTCompoundStatementExpression.java index e49400aad73..4925e905374 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTCompoundStatementExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTCompoundStatementExpression.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; * statement's as expressions. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGNUASTCompoundStatementExpression extends IASTExpression { @@ -45,4 +46,8 @@ public interface IGNUASTCompoundStatementExpression extends IASTExpression { */ public void setCompoundStatement(IASTCompoundStatement statement); + /** + * @since 5.1 + */ + public IGNUASTCompoundStatementExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTTypeIdExpression.java index 6fd689c21c6..c3e02c32ea2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTTypeIdExpression.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression; * expressions for _alignOf() and typeof() along the lines of sizeof(). * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGNUASTTypeIdExpression extends IASTTypeIdExpression { @@ -37,4 +38,9 @@ public interface IGNUASTTypeIdExpression extends IASTTypeIdExpression { */ @Deprecated public static final int op_last = IASTTypeIdExpression.op_last; + + /** + * @since 5.1 + */ + public IGNUASTTypeIdExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java index d14430726a7..9c53e085900 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; * expressions for _alignOf() and typeof() along the lines of sizeof(). * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGNUASTUnaryExpression extends IASTUnaryExpression { @@ -37,4 +38,9 @@ public interface IGNUASTUnaryExpression extends IASTUnaryExpression { */ @Deprecated public static final int op_last = IASTUnaryExpression.op_last; + + /** + * @since 5.1 + */ + public IGNUASTUnaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java index c1addba0e10..9fdc9033c4b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * This is the declarator for a K&R C Function. * * @author dsteffle + * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator, IASTNameOwner { @@ -74,4 +75,9 @@ public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator, IAST * @param name IASTName */ public IASTDeclarator getDeclaratorForParameterName(IASTName name); + + /** + * @since 5.1 + */ + public ICASTKnRFunctionDeclarator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java index 65876fab116..f1b37b63e25 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator; * struct ABC { int def[10]; } abc = { def[4...10] = 3 }; * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGCCASTArrayRangeDesignator extends ICASTDesignator { @@ -67,4 +68,9 @@ public interface IGCCASTArrayRangeDesignator extends ICASTDesignator { * IASTExpression */ public void setRangeCeiling(IASTExpression expression); + + /** + * @since 5.1 + */ + public IGCCASTArrayRangeDesignator copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java index 1293f794380..9ff78b3c1c0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTSimpleDeclSpecifier.java @@ -14,6 +14,9 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; +/** + * @noimplement This interface is not intended to be implemented by clients. + */ public interface IGCCASTSimpleDeclSpecifier extends ICASTSimpleDeclSpecifier { /** @@ -47,4 +50,9 @@ public interface IGCCASTSimpleDeclSpecifier extends ICASTSimpleDeclSpecifier { * @return IASTExpression */ public IASTExpression getTypeofExpression(); + + /** + * @since 5.1 + */ + public IGCCASTSimpleDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java index 0cf8f5f07c3..4fd6dc70fc7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; * G++ introduces additional operators. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGPPASTBinaryExpression extends ICPPASTBinaryExpression { @@ -36,5 +37,10 @@ public interface IGPPASTBinaryExpression extends ICPPASTBinaryExpression { */ @Deprecated public static final int op_last = IASTBinaryExpression.op_last; + + /** + * @since 5.1 + */ + public IGPPASTBinaryExpression copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java index 93603432b3f..ef3598fcf18 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; * G++ allows for restrict to be a modifier for the decl spec. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier { @@ -34,4 +35,8 @@ public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier { */ public void setRestrict(boolean value); + /** + * @since 5.1 + */ + public IGPPASTDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTExplicitTemplateInstantiation.java index a176786b7b4..527eb533c08 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTExplicitTemplateInstantiation.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; * G++ allows for instantiations to be qualified w/modifiers for scoping. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGPPASTExplicitTemplateInstantiation extends ICPPASTExplicitTemplateInstantiation { @@ -49,4 +50,9 @@ public interface IGPPASTExplicitTemplateInstantiation extends * (int) */ public void setModifier(int value); + + /** + * @since 5.1 + */ + public IGPPASTExplicitTemplateInstantiation copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointer.java index 2a09d928d5f..8cfef9861ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointer.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer; * g++ allows for restrict pointers. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ public interface IGPPASTPointer extends IASTPointer { @@ -33,4 +34,9 @@ public interface IGPPASTPointer extends IASTPointer { * boolean */ public void setRestrict(boolean value); + + /** + * @since 5.1 + */ + public IGPPASTPointer copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointerToMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointerToMember.java index 137fe0afa1c..f9a3bf71a25 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointerToMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTPointerToMember.java @@ -16,8 +16,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; * G++ Pointer 2 Members accept the restrict qualified as well. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ -public interface IGPPASTPointerToMember extends IGPPASTPointer, - ICPPASTPointerToMember { +public interface IGPPASTPointerToMember extends IGPPASTPointer, ICPPASTPointerToMember { + /** + * @since 5.1 + */ + public IGPPASTPointerToMember copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java index 884e4513ec7..3fadafb649e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTSimpleDeclSpecifier.java @@ -18,9 +18,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; * G++ adds its own modifiers and types to the Simple Decl Specifier. * * @author jcamelon + * @noimplement This interface is not intended to be implemented by clients. */ -public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, - ICPPASTSimpleDeclSpecifier { +public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, ICPPASTSimpleDeclSpecifier { /** * t_typeof represents a typeof() expression type. @@ -92,5 +92,10 @@ public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier, * @return IASTExpression */ public IASTExpression getTypeofExpression(); + + /** + * @since 5.1 + */ + public IGPPASTSimpleDeclSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java index 03048ed0b85..bf1c1f883da 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java @@ -46,6 +46,10 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTNode i fFunctionCallExpression= functionCall; } + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } + public void addExpression(IASTExpression e) { Assert.isLegal(false); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java index 5bf0a5e1a7e..2999c79708f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java @@ -35,6 +35,12 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I setName(name); setValue(value); } + + protected void copyAbstractEnumerator(ASTEnumerator copy) { + copy.setName(name == null ? null : name.copy()); + copy.setValue(value == null ? null : value.copy()); + copy.setOffsetAndLength(this); + } public void setName(IASTName name) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java index 7751d9f3dc0..cc7b392ef55 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java @@ -49,6 +49,12 @@ public class ASTProblem extends ASTNode implements IASTProblem { this.isError= isError; } + public ASTProblem copy() { + ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError); + problem.setOffsetAndLength(this); + return problem; + } + public int getID() { return id; } @@ -93,6 +99,10 @@ public class ASTProblem extends ASTNode implements IASTProblem { return arg == null ? new String[0] : new String[] {new String(arg)}; } + public char[] getArgument() { + return arg; + } + protected static final Map errorMessages; static { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java index af48519d648..ec19144401d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java @@ -60,7 +60,8 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat private boolean fIsHeader= true; private IIndexFileSet fIndexFileSet; private INodeFactory fNodeFactory; - + + @Override public final IASTTranslationUnit getTranslationUnit() { return this; @@ -362,4 +363,17 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat } }); } + + + protected void copyAbstractTU(ASTTranslationUnit copy) { + copy.setIndex(fIndex); + copy.setIsHeaderUnit(fIsHeader); + copy.setASTNodeFactory(fNodeFactory); + copy.setLocationResolver(fLocationResolver); + + for(IASTDeclaration declaration : getDeclarations()) + copy.addDeclaration(declaration == null ? null : declaration.copy()); + + copy.setOffsetAndLength(this); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java index 4dfd9c06106..7bc08231750 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; /** * Internal interface for c- or c++ enumeration specifiers. + * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier { /** @@ -21,4 +22,9 @@ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifi * first attempt to do so. */ boolean startValueComputation(); + + /** + * @since 5.1 + */ + public IASTInternalEnumerationSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTASMDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTASMDeclaration.java index 62888525d3b..4201b859b18 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTASMDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTASMDeclaration.java @@ -29,6 +29,13 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration { setAssembly(assembly); } + public CASTASMDeclaration copy() { + CASTASMDeclaration copy = new CASTASMDeclaration(); + copy.assembly = assembly == null ? null : assembly.clone(); + copy.setOffsetAndLength(this); + return copy; + } + public String getAssembly() { if( assembly == null ) return ""; //$NON-NLS-1$ return new String( assembly ); @@ -36,7 +43,7 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration { public void setAssembly(String assembly) { assertNotFrozen(); - this.assembly = assembly.toCharArray(); + this.assembly = assembly == null ? null : assembly.toCharArray(); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousBinaryVsCastExpression.java index 80ac21af0c0..5b66ee7495f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousBinaryVsCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousBinaryVsCastExpression.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; +import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousBinaryVsCastExpression; public class CASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousBinaryVsCastExpression { @@ -19,4 +20,8 @@ public class CASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousBinaryVsCas public CASTAmbiguousBinaryVsCastExpression(IASTBinaryExpression binaryExpr, IASTCastExpression castExpr) { super(binaryExpr, castExpr); } + + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousDeclarator.java index d79f577c9e0..ffa79493748 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousDeclarator.java @@ -97,4 +97,8 @@ public class CASTAmbiguousDeclarator extends CASTAmbiguity implements IASTAmbigu assertNotFrozen(); Assert.isLegal(false); } + + public IASTDeclarator copy() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousExpression.java index 6346bdc250b..13afb3948e2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousExpression.java @@ -57,5 +57,9 @@ public class CASTAmbiguousExpression extends CASTAmbiguity implements IASTAmbigu public IType getExpressionType() { return CVisitor.getExpressionType(this); } + + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousParameterDeclaration.java index a4cda4fc8cc..20aa19d522b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousParameterDeclaration.java @@ -71,4 +71,9 @@ public class CASTAmbiguousParameterDeclaration extends CASTAmbiguity implements assertNotFrozen(); Assert.isLegal(false); } + + public IASTParameterDeclaration copy() { + throw new UnsupportedOperationException(); + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java index 8cfb5f6f734..1d94cc204e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java @@ -16,8 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; -public class CASTAmbiguousStatement extends CASTAmbiguity implements - IASTAmbiguousStatement { +public class CASTAmbiguousStatement extends CASTAmbiguity implements IASTAmbiguousStatement { private IASTStatement [] stmts = new IASTStatement[2]; private int stmtsPos=-1; @@ -50,4 +49,9 @@ public class CASTAmbiguousStatement extends CASTAmbiguity implements } + public IASTStatement copy() { + throw new UnsupportedOperationException(); + } + + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDeclarator.java index 443e9bc414a..c5cce07557d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDeclarator.java @@ -36,6 +36,15 @@ public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDecl public CASTArrayDeclarator(IASTName name) { super(name); } + + @Override + public CASTArrayDeclarator copy() { + CASTArrayDeclarator copy = new CASTArrayDeclarator(); + copyBaseDeclarator(copy); + for(IASTArrayModifier modifier : getArrayModifiers()) + copy.addArrayModifier(modifier == null ? null : modifier.copy()); + return copy; + } public IASTArrayModifier[] getArrayModifiers() { if( arrayMods == null ) return IASTArrayModifier.EMPTY_ARRAY; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java index 1916818e067..ad45fc20754 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java @@ -36,6 +36,11 @@ public class CASTArrayDesignator extends ASTNode implements setSubscriptExpression(exp); } + public CASTArrayDesignator copy() { + CASTArrayDesignator copy = new CASTArrayDesignator(exp == null ? null : exp.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getSubscriptExpression() { return exp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayModifier.java index dc40f6e7548..b30a9b0deb4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayModifier.java @@ -33,6 +33,11 @@ public class CASTArrayModifier extends ASTNode implements IASTArrayModifier, IAS setConstantExpression(exp); } + public CASTArrayModifier copy() { + CASTArrayModifier copy = new CASTArrayModifier(exp == null ? null : exp.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getConstantExpression() { return exp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java index f050e30aeb9..ab651efdc2b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java @@ -36,6 +36,14 @@ public class CASTArrayRangeDesignator extends ASTNode implements setRangeCeiling(ceiling); } + public CASTArrayRangeDesignator copy() { + CASTArrayRangeDesignator copy = new CASTArrayRangeDesignator(); + copy.setRangeFloor(floor == null ? null : floor.copy()); + copy.setRangeCeiling(ceiling == null ? null : ceiling.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getRangeFloor() { return this.floor; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java index 58362b47774..20233ebbadd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java @@ -36,6 +36,14 @@ public class CASTArraySubscriptExpression extends ASTNode implements setSubscriptExpression(subscript); } + public CASTArraySubscriptExpression copy() { + CASTArraySubscriptExpression copy = new CASTArraySubscriptExpression(); + copy.setArrayExpression(array == null ? null : array.copy()); + copy.setSubscriptExpression(subscript == null ? null : subscript.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getArrayExpression() { return array; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java index 1a609995782..645072209c5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java @@ -25,6 +25,7 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode implements ICASTDecl protected boolean isRestrict; protected boolean isInline; + public boolean isRestrict() { return isRestrict; } @@ -69,4 +70,13 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode implements ICASTDecl assertNotFrozen(); this.isInline = value; } + + protected void copyBaseDeclSpec(CASTBaseDeclSpecifier copy) { + copy.storageClass = storageClass; + copy.isConst = isConst; + copy.isVolatile = isVolatile; + copy.isRestrict = isRestrict; + copy.isInline = isInline; + copy.setOffsetAndLength(this); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java index 4a785eb245a..d1bed861679 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java @@ -37,6 +37,15 @@ public class CASTBinaryExpression extends ASTNode implements setOperand1(operand1); setOperand2(operand2); } + + public CASTBinaryExpression copy() { + CASTBinaryExpression copy = new CASTBinaryExpression(); + copy.op = op; + copy.setOperand1(operand1 == null ? null : operand1.copy()); + copy.setOperand2(operand2 == null ? null : operand2.copy()); + copy.setOffsetAndLength(this); + return copy; + } public int getOperator() { return op; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java index 7b5b0e7ef07..6e677e60cdb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java @@ -40,4 +40,10 @@ public class CASTBreakStatement extends ASTNode implements IASTBreakStatement { return true; } + + public CASTBreakStatement copy() { + CASTBreakStatement copy = new CASTBreakStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java index b3cb4045d9e..c0cd0b572f0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java @@ -32,6 +32,12 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS public CASTCaseStatement(IASTExpression expression) { setExpression(expression); } + + public CASTCaseStatement copy() { + CASTCaseStatement copy = new CASTCaseStatement(expression == null ? null : expression.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getExpression() { return expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCastExpression.java index e219667af9f..29aa8060953 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCastExpression.java @@ -24,12 +24,23 @@ public class CASTCastExpression extends CASTUnaryExpression implements IASTCastE public CASTCastExpression() { + super(op_cast, null); } public CASTCastExpression(IASTTypeId typeId, IASTExpression operand) { super(op_cast, operand); setTypeId(typeId); } + + @Override + public CASTCastExpression copy() { + CASTCastExpression copy = new CASTCastExpression(); + copy.setTypeId(typeId == null ? null : typeId.copy()); + IASTExpression operand = getOperand(); + copy.setOperand(operand == null ? null : operand.copy()); + copy.setOffsetAndLength(this); + return copy; + } public void setTypeId(IASTTypeId typeId) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java index 7bcfd7bd8dd..35c2a1d78ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java @@ -37,6 +37,21 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements setName(name); } + public CASTCompositeTypeSpecifier copy() { + CASTCompositeTypeSpecifier copy = new CASTCompositeTypeSpecifier(); + copyCompositeTypeSpecifier(copy); + return copy; + } + + protected void copyCompositeTypeSpecifier(CASTCompositeTypeSpecifier copy) { + copyBaseDeclSpec(copy); + copy.setKey(key); + copy.setName(name == null ? null : name.copy()); + for(IASTDeclaration member : getMembers()) + copy.addMemberDeclaration(member == null ? null : member.copy()); + } + + public int getKey() { return key; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java index 38a774a83be..acbffeb83be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java @@ -30,6 +30,14 @@ public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatem private IScope scope = null; + public CASTCompoundStatement copy() { + CASTCompoundStatement copy = new CASTCompoundStatement(); + for(IASTStatement statement : getStatements()) + copy.addStatement(statement == null ? null : statement.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTStatement[] getStatements() { if( statements == null ) return IASTStatement.EMPTY_STATEMENT_ARRAY; return (IASTStatement[]) ArrayUtil.trim( IASTStatement.class, statements ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatementExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatementExpression.java index a78787ae33c..a995ed04ddd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatementExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatementExpression.java @@ -31,6 +31,13 @@ public class CASTCompoundStatementExpression extends ASTNode implements public CASTCompoundStatementExpression(IASTCompoundStatement statement) { setCompoundStatement(statement); } + + public CASTCompoundStatementExpression copy() { + CASTCompoundStatementExpression copy = new CASTCompoundStatementExpression(); + copy.setCompoundStatement(statement == null ? null : statement.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTCompoundStatement getCompoundStatement() { return statement; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java index 189fbf67b2b..105480b4e71 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTConditionalExpression.java @@ -38,6 +38,15 @@ public class CASTConditionalExpression extends ASTNode implements setPositiveResultExpression(positive); setNegativeResultExpression(negative); } + + public CASTConditionalExpression copy() { + CASTConditionalExpression copy = new CASTConditionalExpression(); + copy.setLogicalConditionExpression(condition == null ? null : condition.copy()); + copy.setPositiveResultExpression(positive == null ? null : positive.copy()); + copy.setNegativeResultExpression(negative == null ? null : negative.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getLogicalConditionExpression() { return condition; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTContinueStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTContinueStatement.java index c93d13a2126..017cd079e58 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTContinueStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTContinueStatement.java @@ -18,8 +18,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTContinueStatement extends ASTNode implements - IASTContinueStatement { +public class CASTContinueStatement extends ASTNode implements IASTContinueStatement { @Override public boolean accept( ASTVisitor action ){ @@ -39,4 +38,10 @@ public class CASTContinueStatement extends ASTNode implements } return true; } + + public CASTContinueStatement copy() { + CASTContinueStatement copy = new CASTContinueStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarationStatement.java index a4a39529fb7..3f4c5fefd50 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarationStatement.java @@ -31,6 +31,14 @@ public class CASTDeclarationStatement extends ASTNode implements IASTDeclaration setDeclaration(declaration); } + + public CASTDeclarationStatement copy() { + CASTDeclarationStatement copy = new CASTDeclarationStatement(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclaration getDeclaration() { return declaration; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java index 3be37d4cf65..dc02f58c747 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java @@ -51,6 +51,22 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig setName(name); } + public CASTDeclarator copy() { + CASTDeclarator copy = new CASTDeclarator(); + copyBaseDeclarator(copy); + return copy; + } + + protected void copyBaseDeclarator(CASTDeclarator copy) { + copy.setName(name == null ? null : name.copy()); + copy.setInitializer(initializer == null ? null : initializer.copy()); + copy.setNestedDeclarator(nestedDeclarator == null ? null : nestedDeclarator.copy()); + for(IASTPointerOperator pointer : getPointerOperators()) + copy.addPointerOperator(pointer == null ? null : pointer.copy()); + copy.setOffsetAndLength(this); + } + + public IASTPointerOperator[] getPointerOperators() { if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY; pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java index 65a93450d44..d8655f2fa44 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java @@ -18,8 +18,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTDefaultStatement extends ASTNode implements - IASTDefaultStatement { +public class CASTDefaultStatement extends ASTNode implements IASTDefaultStatement { @Override public boolean accept( ASTVisitor action ){ @@ -39,4 +38,10 @@ public class CASTDefaultStatement extends ASTNode implements } return true; } + + public CASTDefaultStatement copy() { + CASTDefaultStatement copy = new CASTDefaultStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java index d820630c0ae..0b746a82d3e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java @@ -21,8 +21,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTDesignatedInitializer extends ASTNode implements - ICASTDesignatedInitializer { +public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignatedInitializer { private IASTInitializer rhs; @@ -34,6 +33,14 @@ public class CASTDesignatedInitializer extends ASTNode implements setOperandInitializer(operandInitializer); } + public CASTDesignatedInitializer copy() { + CASTDesignatedInitializer copy = new CASTDesignatedInitializer(rhs == null ? null : rhs.copy()); + for(ICASTDesignator designator : getDesignators()) + copy.addDesignator(designator == null ? null : designator.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void addDesignator(ICASTDesignator designator) { assertNotFrozen(); if (designator != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java index 8c36926edc2..f67975a1e74 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java @@ -36,6 +36,14 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb setCondition(condition); } + public CASTDoStatement copy() { + CASTDoStatement copy = new CASTDoStatement(); + copy.setBody(body == null ? null : body.copy()); + copy.setCondition(condition == null ? null : condition.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTStatement getBody() { return body; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java index 87ada0e748b..0604e5ad64b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTElaboratedTypeSpecifier.java @@ -43,6 +43,12 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement setName(name); } + public CASTElaboratedTypeSpecifier copy() { + CASTElaboratedTypeSpecifier copy = new CASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy()); + copyBaseDeclSpec(copy); + return copy; + } + public int getKind() { return kind; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java index d0651af81d8..2ed80ab93c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java @@ -35,6 +35,20 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier setName(name); } + public CASTEnumerationSpecifier copy() { + CASTEnumerationSpecifier copy = new CASTEnumerationSpecifier(); + copyEnumerationSpecifier(copy); + return copy; + } + + protected void copyEnumerationSpecifier(CASTEnumerationSpecifier copy) { + copyBaseDeclSpec(copy); + copy.setName(name == null ? null : name.copy()); + for(IASTEnumerator enumerator : getEnumerators()) + copy.addEnumerator(enumerator == null ? null : enumerator.copy()); + } + + public boolean startValueComputation() { if (valuesComputed) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java index d37b3827853..9ec6dbbd240 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator; * C-specific enumerator */ public class CASTEnumerator extends ASTEnumerator { + public CASTEnumerator() { super(); } @@ -25,4 +26,10 @@ public class CASTEnumerator extends ASTEnumerator { public CASTEnumerator(IASTName name, IASTExpression value) { super(name, value); } + + public CASTEnumerator copy() { + CASTEnumerator copy = new CASTEnumerator(); + copyAbstractEnumerator(copy); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionList.java index 07c1fa6d3cc..b3c19110d04 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionList.java @@ -27,6 +27,14 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; public class CASTExpressionList extends ASTNode implements IASTExpressionList, IASTAmbiguityParent { + public CASTExpressionList copy() { + CASTExpressionList copy = new CASTExpressionList(); + for(IASTExpression expr : getExpressions()) + copy.addExpression(expr == null ? null : expr.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression[] getExpressions() { if (expressions == null) return IASTExpression.EMPTY_EXPRESSION_ARRAY; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java index 0938e15ab61..82f50113bea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java @@ -34,6 +34,13 @@ public class CASTExpressionStatement extends ASTNode implements setExpression(expression); } + public CASTExpressionStatement copy() { + CASTExpressionStatement copy = new CASTExpressionStatement(); + copy.setExpression(expression == null ? null : expression.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getExpression() { return expression; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDeclarator.java index acacb792500..e7bc7f185a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDeclarator.java @@ -31,6 +31,14 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl setBitFieldSize(bitFieldSize); } + @Override + public CASTFieldDeclarator copy() { + CASTFieldDeclarator copy = new CASTFieldDeclarator(); + copyBaseDeclarator(copy); + copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy()); + return copy; + } + public IASTExpression getBitFieldSize() { return bitFieldSize; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java index 2f51227469d..c541fdbf8e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java @@ -21,8 +21,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTFieldDesignator extends ASTNode implements - ICASTFieldDesignator { +public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator { private IASTName name; @@ -33,6 +32,12 @@ public class CASTFieldDesignator extends ASTNode implements public CASTFieldDesignator(IASTName name) { setName(name); } + + public CASTFieldDesignator copy() { + CASTFieldDesignator copy = new CASTFieldDesignator(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTName getName() { return name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldReference.java index 718a136ef48..414d05fdcb6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldReference.java @@ -46,6 +46,15 @@ public class CASTFieldReference extends ASTNode implements IASTFieldReference, I setFieldName(name); this.ptr = ptr; } + + public CASTFieldReference copy() { + CASTFieldReference copy = new CASTFieldReference(); + copy.setFieldOwner(owner == null ? null : owner.copy()); + copy.setFieldName(name == null ? null : name.copy()); + copy.ptr = ptr; + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getFieldOwner() { return owner; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java index bbd25c7d61e..30e23d5925e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java @@ -43,6 +43,20 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA setBody(body); } + public CASTForStatement copy() { + CASTForStatement copy = new CASTForStatement(); + copyForStatement(copy); + return copy; + } + + protected void copyForStatement(CASTForStatement copy) { + copy.setInitializerStatement(init == null ? null : init.copy()); + copy.setConditionExpression(condition == null ? null : condition.copy()); + copy.setIterationExpression(iterationExpression == null ? null : iterationExpression.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + } + public IASTExpression getConditionExpression() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java index 8bec97d282f..972de1bce84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java @@ -37,6 +37,14 @@ public class CASTFunctionCallExpression extends ASTNode implements setParameterExpression(parameter); } + public CASTFunctionCallExpression copy() { + CASTFunctionCallExpression copy = new CASTFunctionCallExpression(); + copy.setFunctionNameExpression(functionName == null ? null : functionName.copy()); + copy.setParameterExpression(parameter == null ? null : parameter.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void setFunctionNameExpression(IASTExpression expression) { assertNotFrozen(); this.functionName = expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDeclarator.java index b49708a0bb6..130dc32e735 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDeclarator.java @@ -34,6 +34,18 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda super(name); } + @Override + public CASTFunctionDeclarator copy() { + CASTFunctionDeclarator copy = new CASTFunctionDeclarator(); + copyBaseDeclarator(copy); + copy.varArgs = varArgs; + + for(IASTParameterDeclaration param : getParameters()) + copy.addParameterDeclaration(param == null ? null : param.copy()); + + return copy; + } + public IASTParameterDeclaration[] getParameters() { if( parameters == null ) return IASTParameterDeclaration.EMPTY_PARAMETERDECLARATION_ARRAY; parameters = (IASTParameterDeclaration[]) ArrayUtil.removeNullsAfter( IASTParameterDeclaration.class, parameters, parametersPos ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDefinition.java index b3fea48f7aa..5bf76095342 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionDefinition.java @@ -45,6 +45,21 @@ public class CASTFunctionDefinition extends ASTNode implements setBody(bodyStatement); } + public CASTFunctionDefinition copy() { + CASTFunctionDefinition copy = new CASTFunctionDefinition(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + + if(declarator != null) { + IASTDeclarator outer = CVisitor.findOutermostDeclarator(declarator); + outer = outer.copy(); + copy.setDeclarator((IASTFunctionDeclarator)CVisitor.findTypeRelevantDeclarator(outer)); + } + + copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java index 809dc41cf37..acf082c7de6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java @@ -30,6 +30,12 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement { setName(name); } + public CASTGotoStatement copy() { + CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getName() { return this.name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIdExpression.java index 4ff074aedf0..d7eb66cf7a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIdExpression.java @@ -39,6 +39,12 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC setName(name); } + public CASTIdExpression copy() { + CASTIdExpression copy = new CASTIdExpression(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getName() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java index 124857cbd13..ba8ccb9aaa2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java @@ -44,6 +44,15 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb setElseClause(elseClause); } + public CASTIfStatement copy() { + CASTIfStatement copy = new CASTIfStatement(); + copy.setConditionExpression(condition == null ? null : condition.copy()); + copy.setThenClause(thenClause == null ? null : thenClause.copy()); + copy.setElseClause(elseClause == null ? null : elseClause.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getConditionExpression() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java index 067810f74cf..34abea73a86 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java @@ -33,6 +33,13 @@ public class CASTInitializerExpression extends ASTNode implements public CASTInitializerExpression(IASTExpression expression) { setExpression(expression); } + + public CASTInitializerExpression copy() { + CASTInitializerExpression copy = new CASTInitializerExpression(); + copy.setExpression(expression == null ? null : expression.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getExpression() { return expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java index cd64fb29bc5..806abe0e1b4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java @@ -21,10 +21,16 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTInitializerList extends ASTNode implements - IASTInitializerList { - +public class CASTInitializerList extends ASTNode implements IASTInitializerList { + public CASTInitializerList copy() { + CASTInitializerList copy = new CASTInitializerList(); + for(IASTInitializer initializer : getInitializers()) + copy.addInitializer(initializer == null ? null : initializer.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTInitializer[] getInitializers() { if( initializers == null ) return IASTInitializer.EMPTY_INITIALIZER_ARRAY; initializers = (IASTInitializer[]) ArrayUtil.removeNullsAfter( IASTInitializer.class, initializers, initializersPos ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTKnRFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTKnRFunctionDeclarator.java index b4b8408176c..e3c0f08ade4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTKnRFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTKnRFunctionDeclarator.java @@ -38,6 +38,31 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn setParameterDeclarations(parameterDeclarations); } + @Override + public CASTKnRFunctionDeclarator copy() { + CASTKnRFunctionDeclarator copy = new CASTKnRFunctionDeclarator(); + copyBaseDeclarator(copy); + + copy.parameterNames = new IASTName[parameterNames.length]; + for(int i = 0; i < parameterNames.length; i++) { + if(parameterNames[i] != null) { + copy.parameterNames[i] = parameterNames[i].copy(); + copy.parameterNames[i].setParent(copy); + copy.parameterNames[i].setPropertyInParent(PARAMETER_NAME); + } + } + + copy.parameterDeclarations = new IASTDeclaration[parameterDeclarations.length]; + for(int i = 0; i < parameterDeclarations.length; i++) { + if(parameterDeclarations[i] != null) { + copy.parameterDeclarations[i] = parameterDeclarations[i].copy(); + copy.parameterDeclarations[i].setParent(copy); + copy.parameterDeclarations[i].setPropertyInParent(FUNCTION_PARAMETER); + } + } + + return copy; + } public void setParameterNames(IASTName[] names) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLabelStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLabelStatement.java index 0d40cf72cb8..423d7be59c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLabelStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLabelStatement.java @@ -35,6 +35,14 @@ public class CASTLabelStatement extends ASTNode implements IASTLabelStatement, I setName(name); setNestedStatement(nestedStatement); } + + public CASTLabelStatement copy() { + CASTLabelStatement copy = new CASTLabelStatement(); + copy.setName(name == null ? null : name.copy()); + copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTName getName() { return name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java index cd80ef5ceed..812774e4b2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java @@ -33,6 +33,12 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress this.kind = kind; this.value = value; } + + public CASTLiteralExpression copy() { + CASTLiteralExpression copy = new CASTLiteralExpression(kind, value == null ? null : value.clone()); + copy.setOffsetAndLength(this); + return copy; + } public int getKind() { return kind; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTModifiedArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTModifiedArrayModifier.java index 78012a1d884..a9aeac10b3c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTModifiedArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTModifiedArrayModifier.java @@ -31,6 +31,19 @@ public class CASTModifiedArrayModifier extends CASTArrayModifier implements ICAS super(exp); } + @Override + public CASTModifiedArrayModifier copy() { + IASTExpression exp = getConstantExpression(); + CASTModifiedArrayModifier copy = new CASTModifiedArrayModifier(exp == null ? null : exp.copy()); + copy.isVolatile = isVolatile; + copy.isRestrict = isRestrict; + copy.isStatic = isStatic; + copy.isConst = isConst; + copy.varSized = varSized; + copy.setOffsetAndLength(this); + return copy; + } + public boolean isConst() { return isConst; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java index dd8eae3bfab..48f2ea99b40 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java @@ -50,6 +50,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext name = EMPTY_CHAR_ARRAY; } + public CASTName copy() { + CASTName copy = new CASTName(name == null ? null : name.clone()); + copy.setOffsetAndLength(this); + return copy; + } + public IBinding resolveBinding() { if (binding == null) { CVisitor.createBinding(this); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java index ea15e951828..caa43d98709 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java @@ -38,4 +38,10 @@ public class CASTNullStatement extends ASTNode implements IASTNullStatement { } return true; } + + public CASTNullStatement copy() { + CASTNullStatement copy = new CASTNullStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTParameterDeclaration.java index 159137d5fc2..8dc941de1b6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTParameterDeclaration.java @@ -24,10 +24,10 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTParameterDeclaration extends ASTNode implements IASTParameterDeclaration, IASTAmbiguityParent { + private IASTDeclSpecifier declSpec; private IASTDeclarator declarator; - public CASTParameterDeclaration() { } @@ -36,6 +36,14 @@ public class CASTParameterDeclaration extends ASTNode implements IASTParameterDe setDeclarator(declarator); } + public CASTParameterDeclaration copy() { + CASTParameterDeclaration copy = new CASTParameterDeclaration(); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); + copy.setDeclarator(declarator == null ? null : declarator.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclSpecifier getDeclSpecifier() { return declSpec; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTPointer.java index 0be5518ff64..3e7d8aef2c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTPointer.java @@ -23,6 +23,15 @@ public class CASTPointer extends ASTNode implements ICASTPointer { private boolean isVolatile; private boolean isConst; + public CASTPointer copy() { + CASTPointer copy = new CASTPointer(); + copy.isRestrict = isRestrict; + copy.isVolatile = isVolatile; + copy.isConst = isConst; + copy.setOffsetAndLength(this); + return copy; + } + public boolean isRestrict() { return isRestrict; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblem.java index aecaad8b69c..aca1870b326 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblem.java @@ -25,6 +25,14 @@ public class CASTProblem extends ASTProblem { super(id, arg, isError); } + @Override + public CASTProblem copy() { + char[] arg = getArgument(); + CASTProblem problem = new CASTProblem(getID(), arg == null ? null : arg.clone(), isError()); + problem.setOffsetAndLength(this); + return problem; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitProblems ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java index 3fb8783bad9..5c2ff538de3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java @@ -30,6 +30,12 @@ public class CASTProblemDeclaration extends CASTProblemOwner implements super(problem); } + public CASTProblemDeclaration copy() { + CASTProblemDeclaration copy = new CASTProblemDeclaration(); + copyBaseProblem(copy); + return copy; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitDeclarations ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java index 1f4041aae68..ec1ba3a1b9b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java @@ -30,6 +30,12 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl super(problem); } + public CASTProblemExpression copy() { + CASTProblemExpression copy = new CASTProblemExpression(); + copyBaseProblem(copy); + return copy; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitExpressions ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java index b9c726df719..f3ca375da7c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java @@ -30,6 +30,11 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder { setProblem(problem); } + protected void copyBaseProblem(CASTProblemOwner copy) { + copy.setProblem(problem == null ? null : problem.copy()); + copy.setOffsetAndLength(this); + } + public IASTProblem getProblem() { return problem; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java index 91740787c4c..39f8af954ca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java @@ -28,6 +28,12 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble super(problem); } + public CASTProblemStatement copy() { + CASTProblemStatement copy = new CASTProblemStatement(); + copyBaseProblem(copy); + return copy; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitStatements ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java index 85c89a72aa9..e2cb41ae187 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java @@ -32,6 +32,12 @@ public class CASTReturnStatement extends ASTNode implements public CASTReturnStatement(IASTExpression retValue) { setReturnValue(retValue); } + + public CASTReturnStatement copy() { + CASTReturnStatement copy = new CASTReturnStatement(retValue == null ? null : retValue.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getReturnValue() { return retValue; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java index ddd2b84e5d6..e705e7d84c2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclSpecifier.java @@ -28,6 +28,25 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC private boolean complex=false; private boolean imaginary=false; + public CASTSimpleDeclSpecifier copy() { + CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier(); + copySimpleDeclSpec(copy); + return copy; + } + + protected void copySimpleDeclSpec(CASTSimpleDeclSpecifier copy) { + copyBaseDeclSpec(copy); + copy.simpleType = simpleType; + copy.isSigned = isSigned; + copy.isUnsigned = isUnsigned; + copy.isShort = isShort; + copy.isLong = isLong; + copy.longlong = longlong; + copy.complex = complex; + copy.imaginary = imaginary; + } + + public int getType() { return simpleType; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java index 623c01b0621..28ae1e24aae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java @@ -32,6 +32,17 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat setDeclSpecifier(declSpecifier); } + public CASTSimpleDeclaration copy() { + CASTSimpleDeclaration copy = new CASTSimpleDeclaration(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + + for(IASTDeclarator declarator : getDeclarators()) + copy.addDeclarator(declarator == null ? null : declarator.copy()); + + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java index 443845b7b74..b4a0223742f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java @@ -35,6 +35,14 @@ public class CASTSwitchStatement extends ASTNode implements setControllerExpression(controller); setBody(body); } + + public CASTSwitchStatement copy() { + CASTSwitchStatement copy = new CASTSwitchStatement(); + copy.setControllerExpression(controller == null ? null : controller.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getControllerExpression() { return controller; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java index 48235905c65..1171a817588 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java @@ -30,6 +30,13 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; public class CASTTranslationUnit extends ASTTranslationUnit { private CScope compilationUnit = null; + + public CASTTranslationUnit copy() { + CASTTranslationUnit copy = new CASTTranslationUnit(); + copyAbstractTU(copy); + return copy; + } + /* * (non-Javadoc) * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java index 1a7386f7714..8cf11a0e6ca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeId.java @@ -32,6 +32,14 @@ public class CASTTypeId extends ASTNode implements IASTTypeId { setDeclSpecifier(declSpecifier); setAbstractDeclarator(declarator); } + + public CASTTypeId copy() { + CASTTypeId copy = new CASTTypeId(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + copy.setAbstractDeclarator(declarator == null ? null : declarator.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdExpression.java index 146fc750208..8c9663b65f8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdExpression.java @@ -20,8 +20,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CASTTypeIdExpression extends ASTNode implements - IASTTypeIdExpression { +public class CASTTypeIdExpression extends ASTNode implements IASTTypeIdExpression { private int op; private IASTTypeId typeId; @@ -33,6 +32,12 @@ public class CASTTypeIdExpression extends ASTNode implements this.op = op; setTypeId(typeId); } + + public CASTTypeIdExpression copy() { + CASTTypeIdExpression copy = new CASTTypeIdExpression(op, typeId == null ? null : typeId.copy()); + copy.setOffsetAndLength(this); + return copy; + } public int getOperator() { return op; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdInitializerExpression.java index 19cb07cd078..6ba875e2c85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypeIdInitializerExpression.java @@ -36,6 +36,14 @@ public class CASTTypeIdInitializerExpression extends ASTNode implements setInitializer(i); } + public CASTTypeIdInitializerExpression copy() { + CASTTypeIdInitializerExpression copy = new CASTTypeIdInitializerExpression(); + copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setInitializer(initializer == null ? null : initializer.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTTypeId getTypeId() { return typeId; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypedefNameSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypedefNameSpecifier.java index eb67d985907..014f699613b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypedefNameSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypedefNameSpecifier.java @@ -36,6 +36,12 @@ public class CASTTypedefNameSpecifier extends CASTBaseDeclSpecifier implements setName(name); } + public CASTTypedefNameSpecifier copy() { + CASTTypedefNameSpecifier copy = new CASTTypedefNameSpecifier(name == null ? null : name.copy()); + copyBaseDeclSpec(copy); + return copy; + } + public IASTName getName() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java index 2425cdd594f..326c3031d78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java @@ -37,6 +37,12 @@ public class CASTUnaryExpression extends ASTNode implements setOperand(operand); } + public CASTUnaryExpression copy() { + CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null : operand.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getOperator() { return operator; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTWhileStatement.java index 5941a6d6726..e58325544d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTWhileStatement.java @@ -36,6 +36,14 @@ public class CASTWhileStatement extends ASTNode implements IASTWhileStatement, I setBody(body); } + public CASTWhileStatement copy() { + CASTWhileStatement copy = new CASTWhileStatement(); + copy.setCondition(condition == null ? null : condition.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getCondition() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java index 8ee8a38ba91..f1977c8de6d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCASTSimpleDeclSpecifier.java @@ -32,6 +32,14 @@ public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implement setTypeofExpression(typeofExpression); } + @Override + public GCCASTSimpleDeclSpecifier copy() { + GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier(); + copySimpleDeclSpec(copy); + copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy()); + return copy; + } + public void setTypeofExpression(IASTExpression typeofExpression) { this.typeOfExpression = typeofExpression; if (typeofExpression != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTASMDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTASMDeclaration.java index 4c47b26a780..183dcf28b69 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTASMDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTASMDeclaration.java @@ -27,6 +27,13 @@ public class CPPASTASMDeclaration extends ASTNode implements IASTASMDeclaration setAssembly(assembly); } + public CPPASTASMDeclaration copy() { + CPPASTASMDeclaration copy = new CPPASTASMDeclaration(); + copy.assembly = assembly.clone(); + copy.setOffsetAndLength(this); + return copy; + } + public String getAssembly() { if( assembly == null ) return ""; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java index 3e26049e014..a13c3c4cbd2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; +import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousBinaryVsCastExpression; public class CPPASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousBinaryVsCastExpression { @@ -19,4 +20,8 @@ public class CPPASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousBinaryVsC public CPPASTAmbiguousBinaryVsCastExpression(IASTBinaryExpression bexp, IASTCastExpression castExpr) { super(bexp, castExpr); } + + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclaration.java index 6118322dfbc..98c935d31bf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclaration.java @@ -21,6 +21,10 @@ public class CPPASTAmbiguousDeclaration extends CPPASTAmbiguity implements IASTA protected IASTNode[] getNodes() { return getDeclarations(); } + + public IASTDeclaration copy() { + throw new UnsupportedOperationException(); + } private IASTDeclaration [] decls = new IASTDeclaration[2]; private int declsPos=-1; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java index 66bcc8977e3..f610c2b0bbb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousDeclarator.java @@ -39,6 +39,10 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTAm } } + public IASTDeclarator copy() { + throw new UnsupportedOperationException(); + } + public void addDeclarator(IASTDeclarator d) { assertNotFrozen(); if (d != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java index 9909d069e88..c6e8ec80af4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java @@ -35,6 +35,11 @@ public class CPPASTAmbiguousExpression extends CPPASTAmbiguity implements addExpression(e); } + + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } + public void addExpression(IASTExpression e) { assertNotFrozen(); if (e != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java index a348a3bb5c7..dda23a5b7d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java @@ -26,6 +26,10 @@ public class CPPASTAmbiguousStatement extends CPPASTAmbiguity implements addStatement(s); } + public IASTStatement copy() { + throw new UnsupportedOperationException(); + } + public void addStatement(IASTStatement s) { assertNotFrozen(); if (s != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java index bbc3cdcf460..3e099d06028 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java @@ -49,6 +49,10 @@ public class CPPASTAmbiguousTemplateArgument extends CPPASTAmbiguity implements } } + public IASTNode copy() { + throw new UnsupportedOperationException(); + } + @Override protected IScope getAffectedScope() { // a template argument does not introduce names to a parent scope. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java index 60ed1825353..bc606c885ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayDeclarator.java @@ -21,8 +21,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; /** * @author jcamelon */ -public class CPPASTArrayDeclarator extends CPPASTDeclarator implements - IASTArrayDeclarator { +public class CPPASTArrayDeclarator extends CPPASTDeclarator implements IASTArrayDeclarator { private IASTArrayModifier [] arrayMods = null; private int arrayModsPos=-1; @@ -40,6 +39,16 @@ public class CPPASTArrayDeclarator extends CPPASTDeclarator implements public CPPASTArrayDeclarator() { } + @Override + public CPPASTArrayDeclarator copy() { + CPPASTArrayDeclarator copy = new CPPASTArrayDeclarator(); + copyBaseDeclarator(copy); + for(IASTArrayModifier modifier : getArrayModifiers()) + copy.addArrayModifier(modifier == null ? null : modifier.copy()); + return copy; + } + + public IASTArrayModifier[] getArrayModifiers() { if( arrayMods == null ) return IASTArrayModifier.EMPTY_ARRAY; arrayMods = (IASTArrayModifier[]) ArrayUtil.removeNullsAfter( IASTArrayModifier.class, arrayMods, arrayModsPos ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayModifier.java index f414205a24e..07d81b2974e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayModifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayModifier.java @@ -36,6 +36,12 @@ public class CPPASTArrayModifier extends ASTNode implements IASTArrayModifier, I return exp; } + public CPPASTArrayModifier copy() { + CPPASTArrayModifier copy = new CPPASTArrayModifier(exp == null ? null : exp.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void setConstantExpression(IASTExpression expression) { assertNotFrozen(); exp = expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java index 3dcfc77d85c..78b381e42ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java @@ -35,6 +35,15 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements IASTArray setArrayExpression(arrayExpression); setSubscriptExpression(subscriptExp); } + + public CPPASTArraySubscriptExpression copy() { + CPPASTArraySubscriptExpression copy = new CPPASTArraySubscriptExpression(); + copy.setArrayExpression(arrayExpression == null ? null : arrayExpression.copy()); + copy.setSubscriptExpression(subscriptExp == null ? null : subscriptExp.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getArrayExpression() { return arrayExpression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java index 3366c983052..f1cbae94fe5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java @@ -26,7 +26,7 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST private int sc; private boolean virtual; private boolean explicit; - + public boolean isFriend() { return friend; } @@ -90,6 +90,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST this.explicit = value; } + protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) { + other.friend = friend; + other.inline = inline; + other.volatil = volatil; + other.isConst = isConst; + other.virtual = virtual; + other.explicit = explicit; + other.sc = sc; + other.setOffsetAndLength(this); + } + @Override public String toString() { return ASTSignatureUtil.getSignature(this); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java index 431385ce674..8f24e23f8ab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java @@ -39,6 +39,10 @@ public class CPPASTBaseSpecifier extends ASTNode implements public CPPASTBaseSpecifier() { } + + public CPPASTBaseSpecifier(IASTName name) { + setName(name); + } public CPPASTBaseSpecifier(IASTName name, int visibility, boolean isVirtual) { this.isVirtual = isVirtual; @@ -46,6 +50,14 @@ public class CPPASTBaseSpecifier extends ASTNode implements setName(name); } + public CPPASTBaseSpecifier copy() { + CPPASTBaseSpecifier copy = new CPPASTBaseSpecifier(name == null ? null : name.copy()); + copy.isVirtual = isVirtual; + copy.visibility = visibility; + copy.setOffsetAndLength(this); + return copy; + } + public boolean isVirtual() { return isVirtual; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java index 618c995b140..64456400acf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java @@ -38,6 +38,15 @@ public class CPPASTBinaryExpression extends ASTNode implements setOperand2(operand2); } + public CPPASTBinaryExpression copy() { + CPPASTBinaryExpression copy = new CPPASTBinaryExpression(); + copy.op = op; + copy.setOperand1(operand1 == null ? null : operand1.copy()); + copy.setOperand2(operand2 == null ? null : operand2.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getOperator() { return op; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java index ffa194a8d03..133c0bcf14d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CPPASTBreakStatement extends ASTNode implements - IASTBreakStatement { +public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement { @Override public boolean accept( ASTVisitor action ){ @@ -40,4 +39,9 @@ public class CPPASTBreakStatement extends ASTNode implements return true; } + public CPPASTBreakStatement copy() { + CPPASTBreakStatement copy = new CPPASTBreakStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java index e3112278b85..8f24687dc8f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java @@ -30,6 +30,12 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I public CPPASTCaseStatement(IASTExpression expression) { setExpression(expression); } + + public CPPASTCaseStatement copy() { + CPPASTCaseStatement copy = new CPPASTCaseStatement(expression == null ? null : expression.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getExpression() { return expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java index c9cb3384b0b..8a8b9c419f7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java @@ -30,6 +30,18 @@ public class CPPASTCastExpression extends CPPASTUnaryExpression implements ICPPA super(operator, operand); setTypeId(typeId); } + + @Override + public CPPASTCastExpression copy() { + CPPASTCastExpression copy = new CPPASTCastExpression(); + copy.setOperator(getOperator()); + copy.setTypeId(typeId == null ? null : typeId.copy()); + IASTExpression operand = getOperand(); + copy.setOperand(operand == null ? null : operand.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void setTypeId(IASTTypeId typeId) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java index cdb33bae0f1..4f608de62fe 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java @@ -37,6 +37,15 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, setCatchBody(body); setDeclaration(declaration); } + + public CPPASTCatchHandler copy() { + CPPASTCatchHandler copy = new CPPASTCatchHandler(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setCatchBody(body == null ? null : body.copy()); + copy.setIsCatchAll(isCatchAll); + copy.setOffsetAndLength(this); + return copy; + } public void setIsCatchAll(boolean isEllipsis) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java index 1277b08e32a..3361679f802 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java @@ -40,6 +40,16 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier setName(n); } + public CPPASTCompositeTypeSpecifier copy() { + CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(k, n == null ? null : n.copy()); + copyBaseDeclSpec(copy); + for(IASTDeclaration member : getMembers()) + copy.addMemberDeclaration(member == null ? null : member.copy()); + for(ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) + copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy()); + return copy; + } + @Override public String getRawSignature() { return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java index c700cbd185a..ea424aff157 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java @@ -29,6 +29,14 @@ public class CPPASTCompoundStatement extends ASTNode implements private IASTStatement [] statements = new IASTStatement[2]; private ICPPScope scope = null; + + public CPPASTCompoundStatement copy() { + CPPASTCompoundStatement copy = new CPPASTCompoundStatement(); + for(IASTStatement statement : getStatements()) + copy.addStatement(statement == null ? null : statement.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTStatement[] getStatements() { if( statements == null ) return IASTStatement.EMPTY_STATEMENT_ARRAY; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java index 15ced24a36e..0b1ca787860 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatementExpression.java @@ -32,6 +32,13 @@ public class CPPASTCompoundStatementExpression extends ASTNode implements IGNUAS setCompoundStatement(statement); } + public CPPASTCompoundStatementExpression copy() { + CPPASTCompoundStatementExpression copy = new CPPASTCompoundStatementExpression(); + copy.setCompoundStatement(statement == null ? null : statement.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTCompoundStatement getCompoundStatement() { return statement; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java index d150e58eb56..ad12bab9f06 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java @@ -27,7 +27,7 @@ public class CPPASTConditionalExpression extends ASTNode implements private IASTExpression condition; private IASTExpression negative; - private IASTExpression postive; + private IASTExpression positive; public CPPASTConditionalExpression() { @@ -39,6 +39,16 @@ public class CPPASTConditionalExpression extends ASTNode implements setNegativeResultExpression(negative); } + + public CPPASTConditionalExpression copy() { + CPPASTConditionalExpression copy = new CPPASTConditionalExpression(); + copy.setLogicalConditionExpression(condition == null ? null : condition.copy()); + copy.setPositiveResultExpression(positive == null ? null : positive.copy()); + copy.setNegativeResultExpression(negative == null ? null : negative.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getLogicalConditionExpression() { return condition; } @@ -53,12 +63,12 @@ public class CPPASTConditionalExpression extends ASTNode implements } public IASTExpression getPositiveResultExpression() { - return postive; + return positive; } public void setPositiveResultExpression(IASTExpression expression) { assertNotFrozen(); - this.postive = expression; + this.positive = expression; if (expression != null) { expression.setParent(this); expression.setPropertyInParent(POSITIVE_RESULT); @@ -89,7 +99,7 @@ public class CPPASTConditionalExpression extends ASTNode implements } if( condition != null ) if( !condition.accept( action ) ) return false; - if( postive != null ) if( !postive.accept( action ) ) return false; + if( positive != null ) if( !positive.accept( action ) ) return false; if( negative != null ) if( !negative.accept( action ) ) return false; if( action.shouldVisitExpressions ){ @@ -109,11 +119,11 @@ public class CPPASTConditionalExpression extends ASTNode implements other.setParent( child.getParent() ); condition = (IASTExpression) other; } - if( child == postive ) + if( child == positive ) { other.setPropertyInParent( child.getPropertyInParent() ); other.setParent( child.getParent() ); - postive = (IASTExpression) other; + positive = (IASTExpression) other; } if( child == negative ) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java index ac2214c28f5..1cae1d16a37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java @@ -37,6 +37,14 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements setInitializerValue(initializerValue); } + public CPPASTConstructorChainInitializer copy() { + CPPASTConstructorChainInitializer copy = new CPPASTConstructorChainInitializer(); + copy.setMemberInitializerId(name == null ? null : name.copy()); + copy.setInitializerValue(value == null ? null : value.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getMemberInitializerId() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java index 4e6f55973e5..ec68d7846ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java @@ -33,6 +33,12 @@ public class CPPASTConstructorInitializer extends ASTNode implements setExpression(exp); } + public CPPASTConstructorInitializer copy() { + CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(exp == null ? null : exp.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getExpression() { return exp; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTContinueStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTContinueStatement.java index 69af6774a15..82f859067b6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTContinueStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTContinueStatement.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CPPASTContinueStatement extends ASTNode implements - IASTContinueStatement { +public class CPPASTContinueStatement extends ASTNode implements IASTContinueStatement { @Override public boolean accept( ASTVisitor action ){ @@ -38,4 +37,10 @@ public class CPPASTContinueStatement extends ASTNode implements } return true; } + + public CPPASTContinueStatement copy() { + CPPASTContinueStatement copy = new CPPASTContinueStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConversionName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConversionName.java index 5829309d946..69b2dd3ad9b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConversionName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConversionName.java @@ -35,6 +35,16 @@ public class CPPASTConversionName extends CPPASTName implements ICPPASTConversio super(name); setTypeId(typeId); } + + @Override + public CPPASTConversionName copy() { + char[] name = toCharArray(); + CPPASTConversionName copy = new CPPASTConversionName(name == null ? null : name.clone()); + copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTTypeId getTypeId() { return typeId; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java index 3a7e60bee16..58f23e33981 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarationStatement.java @@ -33,6 +33,13 @@ public class CPPASTDeclarationStatement extends ASTNode implements setDeclaration(declaration); } + public CPPASTDeclarationStatement copy() { + CPPASTDeclarationStatement copy = new CPPASTDeclarationStatement(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclaration getDeclaration() { return declaration; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java index 6dd63b1d5ab..fd5ab25e68c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java @@ -34,7 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { private IASTInitializer initializer; private IASTName name; - private IASTDeclarator nestedDeclarator; + private IASTDeclarator nested; private IASTPointerOperator[] pointerOps = null; private int pointerOpsPos= -1; @@ -50,6 +50,22 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { setInitializer(initializer); } + + public CPPASTDeclarator copy() { + CPPASTDeclarator copy = new CPPASTDeclarator(); + copyBaseDeclarator(copy); + return copy; + } + + protected void copyBaseDeclarator(CPPASTDeclarator copy) { + copy.setName(name == null ? null : name.copy()); + copy.setInitializer(initializer == null ? null : initializer.copy()); + copy.setNestedDeclarator(nested == null ? null : nested.copy()); + for(IASTPointerOperator pointer : getPointerOperators()) + copy.addPointerOperator(pointer == null ? null : pointer.copy()); + copy.setOffsetAndLength(this); + } + public IASTPointerOperator[] getPointerOperators() { if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY; pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos); @@ -57,7 +73,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { } public IASTDeclarator getNestedDeclarator() { - return nestedDeclarator; + return nested; } public IASTName getName() { @@ -88,7 +104,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { public void setNestedDeclarator(IASTDeclarator nested) { assertNotFrozen(); - this.nestedDeclarator = nested; + this.nested = nested; if (nested != null) { nested.setParent(this); nested.setPropertyInParent(NESTED_DECLARATOR); @@ -119,15 +135,15 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { if (!ptrOps[i].accept(action)) return false; } - if (nestedDeclarator == null && name != null) { + if (nested == null && name != null) { IASTDeclarator outermost= CPPVisitor.findOutermostDeclarator(this); if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) { if (!name.accept(action)) return false; } } - if (nestedDeclarator != null) { - if (!nestedDeclarator.accept(action)) return false; + if (nested != null) { + if (!nested.accept(action)) return false; } if (!postAccept(action)) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java index 5e22642cdc7..194c76d196f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDefaultStatement.java @@ -37,5 +37,11 @@ public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatem } return true; } + + public CPPASTDefaultStatement copy() { + CPPASTDefaultStatement copy = new CPPASTDefaultStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java index 13b2ef5da89..5c4ac063ec0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java @@ -20,15 +20,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * @author jcamelon */ -public class CPPASTDeleteExpression extends ASTNode implements - ICPPASTDeleteExpression { +public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpression { private IASTExpression operand; private boolean isGlobal; private boolean isVectored; - public CPPASTDeleteExpression() { } @@ -36,7 +34,18 @@ public class CPPASTDeleteExpression extends ASTNode implements setOperand(operand); } - + public CPPASTDeleteExpression(CPPASTDeleteExpression from) { + setOperand(from.operand); + } + + public CPPASTDeleteExpression copy() { + CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null : operand.copy()); + copy.isGlobal = isGlobal; + copy.isVectored = isVectored; + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getOperand() { return operand; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java index b3e92296a99..0d70da842f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java @@ -35,6 +35,14 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA setCondition(condition); } + public CPPASTDoStatement copy() { + CPPASTDoStatement copy = new CPPASTDoStatement(); + copy.setBody(body == null ? null : body.copy()); + copy.setCondition(condition == null ? null : condition.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTStatement getBody() { return body; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java index 73c3b6c642b..4bcb661b6ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java @@ -39,6 +39,12 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier setName(name); } + public CPPASTElaboratedTypeSpecifier copy() { + CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy()); + copyBaseDeclSpec(copy); + return copy; + } + public int getKind() { return kind; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java index 052052dd9d8..cb03b30b740 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java @@ -33,6 +33,15 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier setName(name); } + public CPPASTEnumerationSpecifier copy() { + CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(name == null ? null : name.copy()); + for(IASTEnumerator enumerator : getEnumerators()) + copy.addEnumerator(enumerator == null ? null : enumerator.copy()); + copyBaseDeclSpec(copy); + return copy; + } + + public boolean startValueComputation() { if (valuesComputed) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java index 73848a44185..61f6a2245ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator; * C++-specific enumerator. */ public class CPPASTEnumerator extends ASTEnumerator { + public CPPASTEnumerator() { super(); } @@ -26,4 +27,10 @@ public class CPPASTEnumerator extends ASTEnumerator { public CPPASTEnumerator(IASTName name, IASTExpression value) { super(name, value); } + + public CPPASTEnumerator copy() { + CPPASTEnumerator copy = new CPPASTEnumerator(); + copyAbstractEnumerator(copy); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java index d6325985abb..c9620a7dbe0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExplicitTemplateInstantiation.java @@ -33,6 +33,13 @@ public class CPPASTExplicitTemplateInstantiation extends ASTNode implements setDeclaration(declaration); } + public CPPASTExplicitTemplateInstantiation copy() { + CPPASTExplicitTemplateInstantiation copy = new CPPASTExplicitTemplateInstantiation(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclaration getDeclaration() { return declaration; } 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 c296ca18390..c3de2a70b20 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 @@ -26,6 +26,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; public class CPPASTExpressionList extends ASTNode implements IASTExpressionList, IASTAmbiguityParent { + public CPPASTExpressionList copy() { + CPPASTExpressionList copy = new CPPASTExpressionList(); + for(IASTExpression expr : getExpressions()) + copy.addExpression(expr == null ? null : expr.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression [] getExpressions() { if( expressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY; return (IASTExpression[]) ArrayUtil.trim( IASTExpression.class, expressions ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java index 8b5c13bb8a2..315b6159cef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java @@ -33,6 +33,13 @@ public class CPPASTExpressionStatement extends ASTNode implements setExpression(expression); } + public CPPASTExpressionStatement copy() { + CPPASTExpressionStatement copy = new CPPASTExpressionStatement(); + copy.setExpression(expression == null ? null : expression.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getExpression() { return expression; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java index ff8a1548e38..34ea4a14ca3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java @@ -29,12 +29,24 @@ public class CPPASTFieldDeclarator extends CPPASTDeclarator implements public CPPASTFieldDeclarator() { } + + public CPPASTFieldDeclarator(IASTName name) { + super(name); + } public CPPASTFieldDeclarator(IASTName name, IASTExpression bitField) { super(name); setBitFieldSize(bitField); } + @Override + public CPPASTFieldDeclarator copy() { + CPPASTFieldDeclarator copy = new CPPASTFieldDeclarator(); + copyBaseDeclarator(copy); + copy.setBitFieldSize(bitField == null ? null : bitField.copy()); + return copy; + } + public IASTExpression getBitFieldSize() { return bitField; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java index e2fa1a1d8f7..4a17590ab1f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java @@ -47,6 +47,16 @@ public class CPPASTFieldReference extends ASTNode implements setFieldName(name); setFieldOwner(owner); } + + public CPPASTFieldReference copy() { + CPPASTFieldReference copy = new CPPASTFieldReference(); + copy.setFieldName(name == null ? null : name.copy()); + copy.setFieldOwner(owner == null ? null : owner.copy()); + copy.isTemplate = isTemplate; + copy.isDeref = isDeref; + copy.setOffsetAndLength(this); + return copy; + } public boolean isTemplate() { return isTemplate; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java index c684808b98b..1cb23218e91 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTForStatement.java @@ -53,6 +53,17 @@ public class CPPASTForStatement extends ASTNode implements ICPPASTForStatement, setBody(body); } + public CPPASTForStatement copy() { + CPPASTForStatement copy = new CPPASTForStatement(); + copy.setInitializerStatement(init == null ? null : init.copy()); + copy.setConditionDeclaration(condDeclaration == null ? null : condDeclaration.copy()); + copy.setConditionExpression(condition == null ? null : condition.copy()); + copy.setIterationExpression(iterationExpression == null ? null : iterationExpression.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getConditionExpression() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java index d8278eae8af..05798a520e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java @@ -37,6 +37,14 @@ public class CPPASTFunctionCallExpression extends ASTNode implements setParameterExpression(parameter); } + public CPPASTFunctionCallExpression copy() { + CPPASTFunctionCallExpression copy = new CPPASTFunctionCallExpression(); + copy.setFunctionNameExpression(functionName == null ? null : functionName.copy()); + copy.setParameterExpression(parameter == null ? null : parameter.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void setFunctionNameExpression(IASTExpression expression) { assertNotFrozen(); this.functionName = expression; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java index c558e443894..22ac6d7e455 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java @@ -45,6 +45,23 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS public CPPASTFunctionDeclarator(IASTName name) { super(name); } + + @Override + public CPPASTFunctionDeclarator copy() { + CPPASTFunctionDeclarator copy = new CPPASTFunctionDeclarator(); + copyBaseDeclarator(copy); + copy.varArgs = varArgs; + copy.pureVirtual = pureVirtual; + copy.isVolatile = isVolatile; + copy.isConst = isConst; + + for(IASTParameterDeclaration param : getParameters()) + copy.addParameterDeclaration(param == null ? null : param.copy()); + for(IASTTypeId typeId : getExceptionSpecification()) + copy.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy()); + + return copy; + } public IASTParameterDeclaration[] getParameters() { if (parameters == null) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java index cd6c948fa3d..638a0c1ebc1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; +import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** @@ -49,6 +50,25 @@ public class CPPASTFunctionDefinition extends ASTNode implements setDeclarator(declarator); setBody(bodyStatement); } + + public CPPASTFunctionDefinition copy() { + CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + + if(declarator != null) { + IASTDeclarator outer = CVisitor.findOutermostDeclarator(declarator); + outer = outer.copy(); + copy.setDeclarator((IASTFunctionDeclarator)CVisitor.findTypeRelevantDeclarator(outer)); + } + + copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); + + for(ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) + copy.addMemberInitializer(initializer == null ? null : initializer.copy()); + + copy.setOffsetAndLength(this); + return copy; + } public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java index bf9dfe649e8..46fef1fd2a8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock; import org.eclipse.cdt.core.parser.util.ArrayUtil; @@ -31,6 +32,26 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme IASTFunctionDeclarator declarator, IASTStatement bodyStatement) { super(declSpecifier, declarator, bodyStatement); } + + @Override + public CPPASTFunctionWithTryBlock copy() { + IASTDeclSpecifier declSpecifier = getDeclSpecifier(); + IASTFunctionDeclarator declarator = getDeclarator(); + IASTStatement bodyStatement = getBody(); + + CPPASTFunctionWithTryBlock copy = new CPPASTFunctionWithTryBlock(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + copy.setDeclarator(declarator == null ? null : declarator.copy()); + copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); + + for(ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) + copy.addMemberInitializer(initializer == null ? null : initializer.copy()); + for(ICPPASTCatchHandler handler : getCatchHandlers()) + copy.addCatchHandler(handler == null ? null : handler.copy()); + + copy.setOffsetAndLength(this); + return copy; + } public void addCatchHandler(ICPPASTCatchHandler statement) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java index 765a17e3505..87d05d570b4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java @@ -30,6 +30,12 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement { setName(name); } + public CPPASTGotoStatement copy() { + CPPASTGotoStatement copy = new CPPASTGotoStatement(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getName() { return this.name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIdExpression.java index 866ccb29b81..bfa241f8639 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIdExpression.java @@ -36,6 +36,12 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, IAS setName(name); } + public CPPASTIdExpression copy() { + CPPASTIdExpression copy = new CPPASTIdExpression(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getName() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java index 2e6b58df1c3..49c773f9d8a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java @@ -46,7 +46,18 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA setThenClause(thenClause); setElseClause(elseClause); } + + public CPPASTIfStatement copy() { + CPPASTIfStatement copy = new CPPASTIfStatement(); + copy.setConditionDeclaration(condDecl == null ? null : condDecl.copy()); + copy.setConditionExpression(condition == null ? null : condition.copy()); + copy.setThenClause(thenClause == null ? null : thenClause.copy()); + copy.setElseClause(elseClause == null ? null : elseClause.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getConditionExpression() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java index 3fa12395013..3e65fab8672 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java @@ -33,6 +33,12 @@ public class CPPASTInitializerExpression extends ASTNode implements setExpression(exp); } + public CPPASTInitializerExpression copy() { + CPPASTInitializerExpression copy = new CPPASTInitializerExpression(exp == null ? null : exp.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getExpression() { return exp; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java index 2fb99cc0d38..24cead27102 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java @@ -21,6 +21,14 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; */ public class CPPASTInitializerList extends ASTNode implements IASTInitializerList { + public CPPASTInitializerList copy() { + CPPASTInitializerList copy = new CPPASTInitializerList(); + for(IASTInitializer initializer : getInitializers()) + copy.addInitializer(initializer == null ? null : initializer.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTInitializer [] getInitializers() { if( initializers == null ) return IASTInitializer.EMPTY_INITIALIZER_ARRAY; initializers = (IASTInitializer[]) ArrayUtil.removeNullsAfter( IASTInitializer.class, initializers, initializersPos ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java index 99e5acdeaac..f5b9a22b03b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java @@ -35,6 +35,14 @@ public class CPPASTLabelStatement extends ASTNode implements setName(name); setNestedStatement(nestedStatement); } + + public CPPASTLabelStatement copy() { + CPPASTLabelStatement copy = new CPPASTLabelStatement(); + copy.setName(name == null ? null : name.copy()); + copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTName getName() { return name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java index ff98152a9b9..6a9c8b46416 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLinkageSpecification.java @@ -32,6 +32,15 @@ public class CPPASTLinkageSpecification extends ASTNode implements public CPPASTLinkageSpecification(String literal) { this.literal = literal; } + + public CPPASTLinkageSpecification copy() { + CPPASTLinkageSpecification copy = new CPPASTLinkageSpecification(literal); + for(IASTDeclaration declaration : getDeclarations()) + copy.addDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public String getLiteral() { return literal; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java index 078bbdca81f..7842c2ca4f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java @@ -34,6 +34,12 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx this.value = value; } + public CPPASTLiteralExpression copy() { + CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, value == null ? null : value.clone()); + copy.setOffsetAndLength(this); + return copy; + } + public int getKind() { return kind; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java index ca95be277e4..a4c7a6e3f09 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java @@ -47,6 +47,12 @@ public class CPPASTName extends CPPASTNameBase implements IASTCompletionContext name = CharArrayUtils.EMPTY; } + public CPPASTName copy() { + CPPASTName copy = new CPPASTName(name == null ? null : name.clone()); + copy.setOffsetAndLength(this); + return copy; + } + @Override protected IBinding createIntermediateBinding() { return CPPVisitor.createBinding(this); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java index 3ceb2435872..2ac923aafae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java @@ -43,6 +43,13 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements setName(name); } + public CPPASTNamedTypeSpecifier copy() { + CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null : name.copy()); + copyBaseDeclSpec(copy); + copy.typename = typename; + return copy; + } + public boolean isTypename() { return typename; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceAlias.java index c1688acbb64..a83375723e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceAlias.java @@ -33,6 +33,14 @@ public class CPPASTNamespaceAlias extends ASTNode implements ICPPASTNamespaceAli setMappingName(qualifiedName); } + public CPPASTNamespaceAlias copy() { + CPPASTNamespaceAlias copy = new CPPASTNamespaceAlias(); + copy.setAlias(alias == null ? null : alias.copy()); + copy.setMappingName(qualifiedName == null ? null : qualifiedName.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getAlias() { return alias; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java index 4b5ac43ca93..925f9bdb3a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java @@ -39,6 +39,14 @@ public class CPPASTNamespaceDefinition extends ASTNode implements setName(name); } + public CPPASTNamespaceDefinition copy() { + CPPASTNamespaceDefinition copy = new CPPASTNamespaceDefinition(name == null ? null : name.copy()); + for(IASTDeclaration declaration : getDeclarations()) + copy.addDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getName() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java index 632637ead2a..e7d5476443c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java @@ -51,6 +51,25 @@ public class CPPASTNewExpression extends ASTNode implements setNewInitializer(initializer); setTypeId(typeId); } + + public CPPASTNewExpression copy() { + CPPASTNewExpression copy = new CPPASTNewExpression(); + copy.setIsGlobal(global); + copy.setIsNewTypeId(isNewTypeId); + copy.setNewPlacement(placement == null ? null : placement.copy()); + copy.setNewInitializer(initializer == null ? null : initializer.copy()); + copy.setTypeId(typeId == null ? null : typeId.copy()); + + if(arrayExpressions != null) { + copy.arrayExpressions = new IASTExpression[arrayExpressions.length]; + for(int i = 0; i < arrayExpressions.length; i++) { + copy.arrayExpressions[i] = arrayExpressions[i] == null ? null : arrayExpressions[i].copy(); + } + } + + copy.setOffsetAndLength(this); + return copy; + } public boolean isGlobal() { return global; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNullStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNullStatement.java index e2dc0408474..fb8ca54c012 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNullStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNullStatement.java @@ -37,4 +37,10 @@ public class CPPASTNullStatement extends ASTNode implements IASTNullStatement { } return true; } + + public CPPASTNullStatement copy() { + CPPASTNullStatement copy = new CPPASTNullStatement(); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTOperatorName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTOperatorName.java index a69e91f3380..aa0b5757a57 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTOperatorName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTOperatorName.java @@ -27,4 +27,12 @@ public class CPPASTOperatorName extends CPPASTName implements ICPPASTOperatorNam super(name); } + + @Override + public CPPASTOperatorName copy() { + char[] name = toCharArray(); + CPPASTOperatorName copy = new CPPASTOperatorName(name == null ? null : name.clone()); + copy.setOffsetAndLength(this); + return copy; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java index fe1aed9d140..f65910f0a29 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java @@ -35,6 +35,14 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame setDeclSpecifier(declSpec); setDeclarator(declarator); } + + public CPPASTParameterDeclaration copy() { + CPPASTParameterDeclaration copy = new CPPASTParameterDeclaration(); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); + copy.setDeclarator(declarator == null ? null : declarator.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTDeclSpecifier getDeclSpecifier() { return declSpec; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointer.java index ab35f5d1b97..d39e8e99d49 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointer.java @@ -23,6 +23,15 @@ public class CPPASTPointer extends ASTNode implements IASTPointer { private boolean isVolatile; + + public CPPASTPointer copy() { + CPPASTPointer copy = new CPPASTPointer(); + copy.isConst = isConst; + copy.isVolatile = isVolatile; + copy.setOffsetAndLength(this); + return copy; + } + public boolean isConst() { return isConst; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointerToMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointerToMember.java index 0aacdf0ff6a..d090808d87d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointerToMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPointerToMember.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; /** * @author jcamelon */ -public class CPPASTPointerToMember extends CPPASTPointer implements - ICPPASTPointerToMember { +public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPointerToMember { private IASTName n; @@ -29,6 +28,15 @@ public class CPPASTPointerToMember extends CPPASTPointer implements setName(n); } + @Override + public CPPASTPointerToMember copy() { + CPPASTPointerToMember copy = new CPPASTPointerToMember(n == null ? null : n.copy()); + copy.setConst(isConst()); + copy.setVolatile(isVolatile()); + copy.setOffsetAndLength(this); + return copy; + } + public void setName(IASTName name) { assertNotFrozen(); n = name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java index 983e6ef9f81..eb0b39db11e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java @@ -24,6 +24,14 @@ public class CPPASTProblem extends ASTProblem { super(id, arg, isError); } + @Override + public CPPASTProblem copy() { + char[] arg = getArgument(); + CPPASTProblem problem = new CPPASTProblem(getID(), arg == null ? null : arg.clone(), isError()); + problem.setOffsetAndLength(this); + return problem; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitProblems ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java index 25946af1b8c..9390052613f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java @@ -18,8 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration; /** * @author jcamelon */ -public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements - IASTProblemDeclaration { +public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements IASTProblemDeclaration { public CPPASTProblemDeclaration() { super(); @@ -29,6 +28,13 @@ public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements super(problem); } + public CPPASTProblemDeclaration copy() { + CPPASTProblemDeclaration copy = new CPPASTProblemDeclaration(); + copyBaseProblem(copy); + return copy; + } + + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitDeclarations ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java index 30fbb9a2851..774c09744a8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java @@ -19,8 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IType; /** * @author jcamelon */ -public class CPPASTProblemExpression extends CPPASTProblemOwner implements - IASTProblemExpression { +public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTProblemExpression { public CPPASTProblemExpression() { super(); @@ -30,6 +29,12 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements super(problem); } + public CPPASTProblemExpression copy() { + CPPASTProblemExpression copy = new CPPASTProblemExpression(); + copyBaseProblem(copy); + return copy; + } + @Override public boolean accept( ASTVisitor action ){ if( action.shouldVisitExpressions ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java index 86db9592d80..76254c51c96 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java @@ -30,6 +30,11 @@ abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder { public CPPASTProblemOwner(IASTProblem problem) { setProblem(problem); } + + protected void copyBaseProblem(CPPASTProblemOwner copy) { + copy.setProblem(problem == null ? null : problem.copy()); + copy.setOffsetAndLength(this); + } public IASTProblem getProblem() { return problem; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java index d407be59474..718de9bbe44 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java @@ -18,8 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemStatement; /** * @author jcamelon */ -public class CPPASTProblemStatement extends CPPASTProblemOwner implements - IASTProblemStatement { +public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTProblemStatement { public CPPASTProblemStatement() { super(); @@ -28,6 +27,12 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements public CPPASTProblemStatement(IASTProblem problem) { super(problem); } + + public CPPASTProblemStatement copy() { + CPPASTProblemStatement copy = new CPPASTProblemStatement(); + copyBaseProblem(copy); + return copy; + } @Override public boolean accept( ASTVisitor action ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java index 4673091cd0a..b30312328f8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java @@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId; @@ -30,6 +32,21 @@ public class CPPASTProblemTypeId extends CPPASTTypeId implements IASTProblemType setProblem(problem); } + @Override + public CPPASTProblemTypeId copy() { + IASTProblem problem = getProblem(); + IASTDeclSpecifier declSpec = getDeclSpecifier(); + IASTDeclarator absDecl = getAbstractDeclarator(); + + CPPASTProblemTypeId copy = new CPPASTProblemTypeId(); + copy.setProblem(problem == null ? null : problem.copy()); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); + copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy()); + + copy.setOffsetAndLength(this); + return copy; + } + public IASTProblem getProblem() { return problem; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java index de1961402bd..3b3e9c28b00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java @@ -56,6 +56,16 @@ public class CPPASTQualifiedName extends CPPASTNameBase public CPPASTQualifiedName() { } + public CPPASTQualifiedName copy() { + CPPASTQualifiedName copy = new CPPASTQualifiedName(); + for(IASTName name : getNames()) + copy.addName(name == null ? null : name.copy()); + copy.setFullyQualified(isFullyQualified); + copy.setSignature(signature); + copy.setOffsetAndLength(this); + return copy; + } + @Override public final IBinding resolvePreBinding() { // The full qualified name resolves to the same thing as the last name diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java index 49e140785b4..ba04e479e72 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java @@ -17,9 +17,14 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public class CPPASTReferenceOperator extends ASTNode implements - ICPPASTReferenceOperator { +public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReferenceOperator { + public CPPASTReferenceOperator copy() { + CPPASTReferenceOperator copy = new CPPASTReferenceOperator(); + copy.setOffsetAndLength(this); + return copy; + } + @Override public boolean accept( ASTVisitor action ){ return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java index 94938a24e5b..9a1721fe63b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java @@ -31,6 +31,12 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen setReturnValue(retValue); } + public CPPASTReturnStatement copy() { + CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null : retValue.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getReturnValue() { return retValue; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java index 755f7a071c9..0b24a24807f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java @@ -16,8 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; /** * @author jcamelon */ -public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier - implements ICPPASTSimpleDeclSpecifier { +public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier { private int type; private boolean isSigned; @@ -25,7 +24,22 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier private boolean isShort; private boolean isLong; - /** + public CPPASTSimpleDeclSpecifier copy() { + CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier(); + copySimpleDeclSpec(copy); + return copy; + } + + protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other) { + copyBaseDeclSpec(other); + other.type = type; + other.isSigned = isSigned; + other.isUnsigned = isUnsigned; + other.isShort = isShort; + other.isLong = isLong; + } + + /** * @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier */ public int getType() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java index 8af4c58d36b..3fe49635ece 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java @@ -32,6 +32,15 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar setDeclSpecifier(declSpecifier); } + public CPPASTSimpleDeclaration copy() { + CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration(); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + for(IASTDeclarator declarator : getDeclarators()) + copy.addDeclarator(declarator == null ? null : declarator.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java index 1f3fa582f27..97dba4a23c7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java @@ -36,6 +36,14 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements setInitialValue(init); } + public CPPASTSimpleTypeConstructorExpression copy() { + CPPASTSimpleTypeConstructorExpression copy = new CPPASTSimpleTypeConstructorExpression(); + copy.st = st; + copy.setInitialValue(init == null ? null : init.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getSimpleType() { return st; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java index 893d906819f..9eb0d2b2427 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java @@ -36,6 +36,15 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements setName(name); setDefaultType(typeId); } + + public CPPASTSimpleTypeTemplateParameter copy() { + CPPASTSimpleTypeTemplateParameter copy = new CPPASTSimpleTypeTemplateParameter(); + copy.type = type; + copy.setName(name == null ? null : name.copy()); + copy.setDefaultType(typeId == null ? null : typeId.copy()); + copy.setOffsetAndLength(this); + return copy; + } public int getParameterType() { return type; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java index 7e7472d3eea..4911b83d354 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java @@ -44,6 +44,15 @@ public class CPPASTSwitchStatement extends ASTNode implements setControllerExpression(controller); setBody(body); } + + public CPPASTSwitchStatement copy() { + CPPASTSwitchStatement copy = new CPPASTSwitchStatement(); + copy.setControllerDeclaration(decl == null ? null : decl.copy()); + copy.setControllerExpression(controller == null ? null : controller.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getControllerExpression() { return controller; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java index 330b1282e5c..ee76c385100 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java @@ -41,6 +41,16 @@ public class CPPASTTemplateDeclaration extends ASTNode implements setDeclaration(declaration); } + public CPPASTTemplateDeclaration copy() { + CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.exported = exported; + for(ICPPASTTemplateParameter param : getTemplateParameters()) + copy.addTemplateParamter(param == null ? null : param.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public boolean isExported() { return exported; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java index 6a91920732f..50cf5e79f33 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java @@ -37,6 +37,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateId, IASTAmbiguityParent { private IASTName templateName; private IASTNode[] templateArguments = null; + public CPPASTTemplateId() { } @@ -44,6 +45,14 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI setTemplateName(templateName); } + public CPPASTTemplateId copy() { + CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ? null : templateName.copy()); + for(IASTNode arg : getTemplateArguments()) + copy.internalAddTemplateArgument(arg == null ? null : arg.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getTemplateName() { return templateName; } @@ -57,32 +66,26 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI name.setPropertyInParent(TEMPLATE_NAME); } } + + private void internalAddTemplateArgument(IASTNode node) { + assertNotFrozen(); + templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, node); + if (node != null) { + node.setParent(this); + node.setPropertyInParent(TEMPLATE_ID_ARGUMENT); + } + } public void addTemplateArgument(IASTTypeId typeId) { - assertNotFrozen(); - templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, typeId); - if (typeId != null) { - typeId.setParent(this); - typeId.setPropertyInParent(TEMPLATE_ID_ARGUMENT); - } + internalAddTemplateArgument(typeId); } public void addTemplateArgument(IASTExpression expression) { - assertNotFrozen(); - templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, expression); - if (expression != null) { - expression.setParent(this); - expression.setPropertyInParent(TEMPLATE_ID_ARGUMENT); - } + internalAddTemplateArgument(expression); } public void addTemplateArgument(ICPPASTAmbiguousTemplateArgument ata) { - assertNotFrozen(); - templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, ata); - if (ata != null) { - ata.setParent(this); - ata.setPropertyInParent(TEMPLATE_ID_ARGUMENT); - } + internalAddTemplateArgument(ata); } public IASTNode[] getTemplateArguments() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java index 2d85fabcd4c..19b0fb0cd97 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateSpecialization.java @@ -39,6 +39,13 @@ public class CPPASTTemplateSpecialization extends ASTNode implements public CPPASTTemplateSpecialization(IASTDeclaration declaration) { setDeclaration(declaration); } + + public CPPASTTemplateSpecialization copy() { + CPPASTTemplateSpecialization copy = new CPPASTTemplateSpecialization(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTDeclaration getDeclaration() { return declaration; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java index 1e444197234..f33661b4266 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java @@ -36,6 +36,16 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements setName(name); setDefaultValue(defaultValue); } + + public CPPASTTemplatedTypeTemplateParameter copy() { + CPPASTTemplatedTypeTemplateParameter copy = new CPPASTTemplatedTypeTemplateParameter(); + copy.setName(name == null ? null : name.copy()); + copy.setDefaultValue(defaultValue == null ? null : defaultValue.copy()); + for(ICPPASTTemplateParameter param : getTemplateParameters()) + copy.addTemplateParamter(param == null ? null : param.copy()); + copy.setOffsetAndLength(this); + return copy; + } public ICPPASTTemplateParameter[] getTemplateParameters() { if( parameters == null ) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index ac0495bf455..1fbccd5d038 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -49,6 +49,12 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST public CPPASTTranslationUnit() { } + public CPPASTTranslationUnit copy() { + CPPASTTranslationUnit copy = new CPPASTTranslationUnit(); + copyAbstractTU(copy); + return copy; + } + public CPPNamespaceScope getScope() { if (fScope == null) { fScope = new CPPNamespaceScope(this); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java index 77481232d57..6db67c78c60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java @@ -33,6 +33,14 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS setTryBody(tryBody); } + public CPPASTTryBlockStatement copy() { + CPPASTTryBlockStatement copy = new CPPASTTryBlockStatement(tryBody == null ? null : tryBody.copy()); + for(ICPPASTCatchHandler handler : getCatchHandlers()) + copy.addCatchHandler(handler == null ? null : handler.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void addCatchHandler(ICPPASTCatchHandler statement) { assertNotFrozen(); if (statement != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java index 60ec38f2c78..db9a1ffccba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeId.java @@ -32,6 +32,14 @@ public class CPPASTTypeId extends ASTNode implements IASTTypeId { setDeclSpecifier(declSpec); setAbstractDeclarator(absDecl); } + + public CPPASTTypeId copy() { + CPPASTTypeId copy = new CPPASTTypeId(); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); + copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTDeclSpecifier getDeclSpecifier() { return declSpec; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java index fcd39d9c3d6..b85669ffd8f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdExpression.java @@ -33,6 +33,12 @@ public class CPPASTTypeIdExpression extends ASTNode implements ICPPASTTypeIdExpr setTypeId(typeId); } + public CPPASTTypeIdExpression copy() { + CPPASTTypeIdExpression copy = new CPPASTTypeIdExpression(op, typeId == null ? null : typeId.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getOperator() { return op; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java index f6980ff9068..8f3f0a15ccc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java @@ -44,6 +44,16 @@ public class CPPASTTypenameExpression extends ASTNode implements this.isTemplate = isTemplate; } + public CPPASTTypenameExpression copy() { + CPPASTTypenameExpression copy = new CPPASTTypenameExpression(); + copy.setName(name == null ? null : name.copy()); + copy.setInitialValue(init == null ? null : init.copy()); + copy.isTemplate = isTemplate; + copy.setOffsetAndLength(this); + return copy; + } + + public void setIsTemplate(boolean templateTokenConsumed) { assertNotFrozen(); isTemplate = templateTokenConsumed; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java index 821007301b4..c669f45094b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java @@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpression, IASTAmbiguityParent { - private int operator; + private int op; private IASTExpression operand; @@ -33,17 +33,23 @@ public class CPPASTUnaryExpression extends ASTNode implements } public CPPASTUnaryExpression(int operator, IASTExpression operand) { - this.operator = operator; + this.op = operator; setOperand(operand); } + public CPPASTUnaryExpression copy() { + CPPASTUnaryExpression copy = new CPPASTUnaryExpression(op, operand == null ? null : operand.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getOperator() { - return operator; + return op; } public void setOperator(int value) { assertNotFrozen(); - this.operator = value; + this.op = value; } public IASTExpression getOperand() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java index e3bea4858ed..c58a44ff0d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java @@ -40,6 +40,13 @@ public class CPPASTUsingDeclaration extends ASTNode implements setName(name); } + public CPPASTUsingDeclaration copy() { + CPPASTUsingDeclaration copy = new CPPASTUsingDeclaration(name == null ? null : name.copy()); + copy.typeName = typeName; + copy.setOffsetAndLength(this); + return copy; + } + public void setIsTypename(boolean value) { assertNotFrozen(); this.typeName = value; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java index 36ade6c16fb..f229b642242 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java @@ -38,6 +38,12 @@ public class CPPASTUsingDirective extends ASTNode implements setQualifiedName(name); } + public CPPASTUsingDirective copy() { + CPPASTUsingDirective copy = new CPPASTUsingDirective(name == null ? null : name.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTName getQualifiedName() { return name; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTVisibilityLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTVisibilityLabel.java index 33410dba270..8e09b0ec70d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTVisibilityLabel.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTVisibilityLabel.java @@ -29,6 +29,12 @@ public class CPPASTVisibilityLabel extends ASTNode implements ICPPASTVisibilityL this.visibility = visibility; } + public CPPASTVisibilityLabel copy() { + CPPASTVisibilityLabel copy = new CPPASTVisibilityLabel(visibility); + copy.setOffsetAndLength(this); + return copy; + } + public int getVisibility() { return visibility; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java index 76cfc8d1b7a..9ea1db40ef1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTWhileStatement.java @@ -44,6 +44,15 @@ public class CPPASTWhileStatement extends ASTNode implements setBody(body); } + public CPPASTWhileStatement copy() { + CPPASTWhileStatement copy = new CPPASTWhileStatement(); + copy.setConditionDeclaration(condition2 == null ? null : condition2.copy()); + copy.setCondition(condition == null ? null : condition.copy()); + copy.setBody(body == null ? null : body.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getCondition() { return condition; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java index f7568172d68..fc1143acba6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTExplicitTemplateInstantiation.java @@ -30,6 +30,17 @@ public class GPPASTExplicitTemplateInstantiation extends private int mod; + + @Override + public GPPASTExplicitTemplateInstantiation copy() { + GPPASTExplicitTemplateInstantiation copy = new GPPASTExplicitTemplateInstantiation(); + IASTDeclaration declaration = getDeclaration(); + copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.mod = mod; + copy.setOffsetAndLength(this); + return copy; + } + public int getModifier() { return mod; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java index 5e2a132e548..40c6d51f298 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointer.java @@ -19,6 +19,16 @@ public class GPPASTPointer extends CPPASTPointer implements IGPPASTPointer { private boolean isRestrict; + @Override + public GPPASTPointer copy() { + GPPASTPointer copy = new GPPASTPointer(); + copy.setConst(isConst()); + copy.setVolatile(isVolatile()); + copy.setRestrict(isRestrict); + copy.setOffsetAndLength(this); + return copy; + } + public boolean isRestrict() { return isRestrict; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointerToMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointerToMember.java index f251ec625d6..dc3699d5904 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointerToMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTPointerToMember.java @@ -29,6 +29,17 @@ public class GPPASTPointerToMember extends CPPASTPointerToMember implements private boolean isRestrict; + @Override + public GPPASTPointerToMember copy() { + IASTName name = getName(); + GPPASTPointerToMember copy = new GPPASTPointerToMember(name == null ? null : name.copy()); + copy.setConst(isConst()); + copy.setVolatile(isVolatile()); + copy.setRestrict(isRestrict); + copy.setOffsetAndLength(this); + return copy; + } + /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer#isRestrict() */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java index 1ced2ca22c3..49973a871d1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java @@ -33,10 +33,22 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier public GPPASTSimpleDeclSpecifier() { } - + public GPPASTSimpleDeclSpecifier(IASTExpression typeofExpression) { setTypeofExpression(typeofExpression); } + + @Override + public GPPASTSimpleDeclSpecifier copy() { + GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier(); + copySimpleDeclSpec(copy); + copy.setTypeofExpression(typeOfExpression == null ? null : typeOfExpression.copy()); + copy.longLong = longLong; + copy.restrict = restrict; + copy.complex = complex; + copy.imaginary = imaginary; + return copy; + } public boolean isLongLong() { return longLong; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java index b7e8290130d..7cdd2adddfe 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java @@ -95,4 +95,8 @@ public class ASTLiteralNode implements IASTNode { public boolean isFrozen() { return false; } + + public IASTNode copy() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java index 1f9a10c84c0..39f2dd0a956 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java @@ -42,6 +42,14 @@ public class ContainerNode extends ASTNode { } } + public ContainerNode copy() { + ContainerNode copy = new ContainerNode(); + for(IASTNode node : getNodes()) + copy.addNode(node == null ? null : node.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public void addNode(IASTNode node) { nodes.add(node); if(node.getParent() == null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorName.java index f9cb9681f41..d797787abcf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorName.java @@ -74,6 +74,10 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName { public IASTName getLastName() { return this; } + @Override + public IASTName copy() { + throw new UnsupportedOperationException(); + } } class ASTPreprocessorDefinition extends ASTPreprocessorName { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java index 3a3382e75c9..190f77fdfd3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java @@ -78,6 +78,10 @@ abstract class ASTPreprocessorNode extends ASTNode { void findNode(ASTNodeSpecification nodeSpec) { nodeSpec.visit(this); } + + public IASTNode copy() { + throw new UnsupportedOperationException(); + } @Override public IToken getLeadingSyntax() throws UnsupportedOperationException { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java index ef557dd8ce3..a9d8ab539c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java @@ -192,6 +192,10 @@ public class PDOMASTAdapter { public boolean isFrozen() { return fDelegate.isFrozen(); } + + public IASTName copy() { + throw new UnsupportedOperationException(); + } } private static class AnonymousEnumeration implements IEnumeration { diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java index a7b17bfaf5e..19e2eed4876 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPASTAmbiguousDeclarator.java @@ -20,7 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguity; - +/** + * TODO delete this class and use the one from the core instead + * + * @author Mike Kucera + * + */ @SuppressWarnings("restriction") public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDeclarator { @@ -87,4 +92,10 @@ public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTDe public int getRoleForName(IASTName n) { return getDefaultDeclarator().getRoleForName(n); } + + public IASTDeclarator copy() { + throw new UnsupportedOperationException(); + } + + } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTCompositeTypeSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTCompositeTypeSpecifier.java index c6c1976a0a3..7b5b17199a6 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTCompositeTypeSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTCompositeTypeSpecifier.java @@ -15,4 +15,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier; public interface IUPCASTCompositeTypeSpecifier extends IUPCASTDeclSpecifier, ICASTCompositeTypeSpecifier { + + public IUPCASTCompositeTypeSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTDeclSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTDeclSpecifier.java index c49fd6665d5..2395cc9811b 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTDeclSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTDeclSpecifier.java @@ -55,4 +55,7 @@ public interface IUPCASTDeclSpecifier extends ICASTDeclSpecifier { public IASTExpression getBlockSizeExpression(); public void setBlockSizeExpression(IASTExpression expr); + + + public IUPCASTDeclSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTElaboratedTypeSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTElaboratedTypeSpecifier.java index a4fa878a3ad..6ae3954011b 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTElaboratedTypeSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTElaboratedTypeSpecifier.java @@ -15,4 +15,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier; public interface IUPCASTElaboratedTypeSpecifier extends IUPCASTDeclSpecifier, ICASTElaboratedTypeSpecifier { + + public IUPCASTElaboratedTypeSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTEnumerationSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTEnumerationSpecifier.java index 86335227ac0..7fc6312ffcc 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTEnumerationSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTEnumerationSpecifier.java @@ -15,4 +15,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier; public interface IUPCASTEnumerationSpecifier extends IUPCASTDeclSpecifier, ICASTEnumerationSpecifier { + + public IUPCASTEnumerationSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTForallStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTForallStatement.java index 2b10ba6f7b8..aed8adb41a7 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTForallStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTForallStatement.java @@ -44,4 +44,7 @@ public interface IUPCASTForallStatement extends IASTForStatement { public IASTStatement getBody(); public void setBody(IASTStatement statement); + + + public IUPCASTForallStatement copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTKeywordExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTKeywordExpression.java index 5ef9c3da333..e9d531995d0 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTKeywordExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTKeywordExpression.java @@ -25,4 +25,6 @@ public interface IUPCASTKeywordExpression extends IASTExpression { public void setKeywordKind(int kind); + + public IUPCASTKeywordExpression copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTLayoutQualifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTLayoutQualifier.java index 49a61e49f57..03095060038 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTLayoutQualifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTLayoutQualifier.java @@ -30,4 +30,6 @@ public interface IUPCASTLayoutQualifier { public void setBlockSizeExpression(IASTExpression expr); + + public IUPCASTLayoutQualifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSimpleDeclSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSimpleDeclSpecifier.java index c2a347341d0..b627b228dbb 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSimpleDeclSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSimpleDeclSpecifier.java @@ -15,4 +15,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; public interface IUPCASTSimpleDeclSpecifier extends IUPCASTDeclSpecifier, ICASTSimpleDeclSpecifier { + + public IUPCASTSimpleDeclSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSynchronizationStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSynchronizationStatement.java index 2c388c991da..91c7eef058e 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSynchronizationStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTSynchronizationStatement.java @@ -37,4 +37,7 @@ public interface IUPCASTSynchronizationStatement extends IASTStatement { public int getStatementKind(); public void setStatementKind(int kind); + + + public IUPCASTSynchronizationStatement copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypeIdSizeofExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypeIdSizeofExpression.java index 53d71f43c67..0ab17aced8a 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypeIdSizeofExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypeIdSizeofExpression.java @@ -24,4 +24,7 @@ public interface IUPCASTTypeIdSizeofExpression extends IASTTypeIdExpression { public int getUPCSizeofOperator(); public void setUPCSizeofOperator(int upcSizeofOperator); + + + public IUPCASTTypeIdSizeofExpression copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypedefNameSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypedefNameSpecifier.java index 5c571380b00..4ffc33fa1c1 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypedefNameSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTTypedefNameSpecifier.java @@ -14,5 +14,8 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier; public interface IUPCASTTypedefNameSpecifier extends IUPCASTDeclSpecifier, ICASTTypedefNameSpecifier { + + + public IUPCASTTypedefNameSpecifier copy(); } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTUnarySizeofExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTUnarySizeofExpression.java index 32996f1d21d..9a69f9304a8 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTUnarySizeofExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/ast/IUPCASTUnarySizeofExpression.java @@ -25,4 +25,6 @@ public interface IUPCASTUnarySizeofExpression extends IASTUnaryExpression { public void setUPCSizeofOperator(int upcSizeofOperator); + + public IUPCASTUnarySizeofExpression copy(); } \ No newline at end of file diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTCompositeTypeSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTCompositeTypeSpecifier.java index bab284dadd8..43ba0153384 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTCompositeTypeSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTCompositeTypeSpecifier.java @@ -18,9 +18,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTCompositeTypeSpecifier; import org.eclipse.cdt.internal.core.dom.parser.c.CASTCompositeTypeSpecifier; @SuppressWarnings("restriction") -public class UPCASTCompositeTypeSpecifier extends CASTCompositeTypeSpecifier implements - IUPCASTCompositeTypeSpecifier { - +public class UPCASTCompositeTypeSpecifier extends CASTCompositeTypeSpecifier implements IUPCASTCompositeTypeSpecifier { private int referenceType; private int sharedQualifier; @@ -37,6 +35,16 @@ public class UPCASTCompositeTypeSpecifier extends CASTCompositeTypeSpecifier imp super(key, name); setBlockSizeExpression(blockSizeExpression); } + + @Override + public UPCASTCompositeTypeSpecifier copy() { + UPCASTCompositeTypeSpecifier copy = new UPCASTCompositeTypeSpecifier(); + copyCompositeTypeSpecifier(copy); + copy.referenceType = referenceType; + copy.sharedQualifier = sharedQualifier; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + return copy; + } public IASTExpression getBlockSizeExpression() { return blockSizeExpression; diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTElaboratedTypeSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTElaboratedTypeSpecifier.java index 2c1fe06e17d..f4a7501af04 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTElaboratedTypeSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTElaboratedTypeSpecifier.java @@ -36,6 +36,17 @@ public class UPCASTElaboratedTypeSpecifier extends CASTElaboratedTypeSpecifier i setBlockSizeExpression(blockSizeExpression); } + @Override + public UPCASTElaboratedTypeSpecifier copy() { + IASTName name = getName(); + UPCASTElaboratedTypeSpecifier copy = new UPCASTElaboratedTypeSpecifier(getKind(), name == null ? null : name.copy()); + copy.referenceType = referenceType; + copy.sharedQualifier = sharedQualifier; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public IASTExpression getBlockSizeExpression() { return blockSizeExpression; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTEnumerationSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTEnumerationSpecifier.java index 1e6893ac4e6..d0d9c46dd71 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTEnumerationSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTEnumerationSpecifier.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTEnumerationSpecifier; import org.eclipse.cdt.internal.core.dom.parser.c.CASTEnumerationSpecifier; @SuppressWarnings("restriction") -public class UPCASTEnumerationSpecifier extends CASTEnumerationSpecifier - implements IUPCASTEnumerationSpecifier { +public class UPCASTEnumerationSpecifier extends CASTEnumerationSpecifier implements IUPCASTEnumerationSpecifier { private int referenceType; private int sharedQualifier; @@ -37,6 +36,16 @@ public class UPCASTEnumerationSpecifier extends CASTEnumerationSpecifier setBlockSizeExpression(blockSizeExpression); } + @Override + public UPCASTEnumerationSpecifier copy() { + UPCASTEnumerationSpecifier copy = new UPCASTEnumerationSpecifier(); + copyEnumerationSpecifier(copy); + copy.referenceType = referenceType; + copy.sharedQualifier = sharedQualifier; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + return copy; + } + public IASTExpression getBlockSizeExpression() { return blockSizeExpression; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java index 55e29f94039..5a5d96a3f4a 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java @@ -32,6 +32,15 @@ public class UPCASTForallStatement extends CASTForStatement implements IUPCASTFo setAffinityExpression(affinity); } + @Override + public UPCASTForallStatement copy() { + UPCASTForallStatement copy = new UPCASTForallStatement(); + copyForStatement(copy); + copy.setAffinityExpression(affinity == null ? null : affinity.copy()); + return copy; + } + + public boolean isAffinityContinue() { return affinityContinue; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTKeywordExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTKeywordExpression.java index 6d8eba73ce8..5787c4e3e49 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTKeywordExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTKeywordExpression.java @@ -29,6 +29,12 @@ public class UPCASTKeywordExpression extends ASTNode implements IUPCASTKeywordEx public UPCASTKeywordExpression(int keywordKind) { this.keywordKind = keywordKind; } + + public UPCASTKeywordExpression copy() { + UPCASTKeywordExpression copy = new UPCASTKeywordExpression(keywordKind); + copy.setOffsetAndLength(this); + return copy; + } public int getKeywordKind() { return keywordKind; diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTLayoutQualifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTLayoutQualifier.java index 66b955eb09d..926d93e7e31 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTLayoutQualifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTLayoutQualifier.java @@ -12,14 +12,24 @@ package org.eclipse.cdt.internal.core.dom.parser.upc.ast; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.upc.ast.IUPCASTLayoutQualifier; +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -public class UPCASTLayoutQualifier implements IUPCASTLayoutQualifier { +@SuppressWarnings("restriction") +public class UPCASTLayoutQualifier extends ASTNode implements IUPCASTLayoutQualifier { private boolean isPure; private boolean isIndefinite; private IASTExpression blockSizeExpression; + public UPCASTLayoutQualifier copy() { + UPCASTLayoutQualifier copy = new UPCASTLayoutQualifier(); + copy.isPure = isPure; + copy.isIndefinite = isIndefinite; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getBlockSizeExpression() { return blockSizeExpression; diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSimpleDeclSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSimpleDeclSpecifier.java index cd9e135027d..863d96bafb6 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSimpleDeclSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSimpleDeclSpecifier.java @@ -31,6 +31,16 @@ public class UPCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier setBlockSizeExpression(blockSizeExpression); } + @Override + public UPCASTSimpleDeclSpecifier copy() { + UPCASTSimpleDeclSpecifier copy = new UPCASTSimpleDeclSpecifier(); + copySimpleDeclSpec(copy); + copy.referenceType = referenceType; + copy.sharedQualifier = sharedQualifier; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + return copy; + } + public IASTExpression getBlockSizeExpression() { return blockSizeExpression; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java index 9a898c5edb9..5a896422302 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java @@ -29,6 +29,14 @@ public class UPCASTSynchronizationStatement extends ASTNode implements IUPCASTSy setBarrierExpression(barrierExpression); this.statmentKind = statmentKind; } + + public UPCASTSynchronizationStatement copy() { + UPCASTSynchronizationStatement copy = new UPCASTSynchronizationStatement(); + copy.statmentKind = statmentKind; + copy.setBarrierExpression(barrierExpression == null ? null : barrierExpression.copy()); + copy.setOffsetAndLength(this); + return copy; + } public IASTExpression getBarrierExpression() { return barrierExpression; diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypeIdSizeofExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypeIdSizeofExpression.java index 1efcafc9a32..b374c2a1c51 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypeIdSizeofExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypeIdSizeofExpression.java @@ -21,6 +21,7 @@ public class UPCASTTypeIdSizeofExpression extends CASTTypeIdExpression implement private int upcSizeofOperator; public UPCASTTypeIdSizeofExpression() { + this(null); } public UPCASTTypeIdSizeofExpression(IASTTypeId typeId) { @@ -32,6 +33,16 @@ public class UPCASTTypeIdSizeofExpression extends CASTTypeIdExpression implement this.upcSizeofOperator = upcSizeofOperator; } + @Override + public UPCASTTypeIdSizeofExpression copy() { + UPCASTTypeIdSizeofExpression copy = new UPCASTTypeIdSizeofExpression(); + copy.setUPCSizeofOperator(upcSizeofOperator); + IASTTypeId typeId = getTypeId(); + copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setOffsetAndLength(this); + return copy; + } + public int getUPCSizeofOperator() { return upcSizeofOperator; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypedefNameSpecifier.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypedefNameSpecifier.java index b244e14176f..17a954af432 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypedefNameSpecifier.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTTypedefNameSpecifier.java @@ -17,9 +17,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTTypedefNameSpecifier; import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypedefNameSpecifier; @SuppressWarnings("restriction") -public class UPCASTTypedefNameSpecifier extends CASTTypedefNameSpecifier - implements IUPCASTTypedefNameSpecifier { - +public class UPCASTTypedefNameSpecifier extends CASTTypedefNameSpecifier implements IUPCASTTypedefNameSpecifier { private int referenceType; private int sharedQualifier; @@ -28,8 +26,6 @@ public class UPCASTTypedefNameSpecifier extends CASTTypedefNameSpecifier public UPCASTTypedefNameSpecifier() { } - - public UPCASTTypedefNameSpecifier(IASTName name) { super(name); @@ -40,6 +36,17 @@ public class UPCASTTypedefNameSpecifier extends CASTTypedefNameSpecifier setBlockSizeExpression(blockSizeExpression); } + @Override + public UPCASTTypedefNameSpecifier copy() { + IASTName name = getName(); + UPCASTTypedefNameSpecifier copy = new UPCASTTypedefNameSpecifier(name == null ? null : name.copy()); + copyBaseDeclSpec(copy); + copy.referenceType = referenceType; + copy.sharedQualifier = sharedQualifier; + copy.setBlockSizeExpression(blockSizeExpression == null ? null : blockSizeExpression.copy()); + return copy; + } + public IASTExpression getBlockSizeExpression() { return blockSizeExpression; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTUnarySizeofExpression.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTUnarySizeofExpression.java index 5844a586edd..b6ba057c9e5 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTUnarySizeofExpression.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTUnarySizeofExpression.java @@ -22,6 +22,7 @@ public class UPCASTUnarySizeofExpression extends CASTUnaryExpression implements public UPCASTUnarySizeofExpression() { + this(null); } public UPCASTUnarySizeofExpression(IASTExpression operand) { @@ -32,6 +33,16 @@ public class UPCASTUnarySizeofExpression extends CASTUnaryExpression implements super(IASTUnaryExpression.op_sizeof, operand); this.upcSizeofOperator = upcSizeofOperator; } + + @Override + public UPCASTUnarySizeofExpression copy() { + UPCASTUnarySizeofExpression copy = new UPCASTUnarySizeofExpression(); + copy.setUPCSizeofOperator(upcSizeofOperator); + IASTExpression operand = getOperand(); + copy.setOperand(operand == null ? null : operand.copy()); + copy.setOffsetAndLength(this); + return copy; + } public int getUPCSizeofOperator() { return upcSizeofOperator;