diff options
author | Emanuel Graf | 2011-03-07 07:26:26 +0000 |
---|---|---|
committer | Emanuel Graf | 2011-03-07 07:26:26 +0000 |
commit | 654e12094a5b0b77e8877550922343dc5def49c9 (patch) | |
tree | 84adebc25b342e27628c8ee9460f03dfe917e3c2 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom | |
parent | c2b14277a39ee7364881508795d12abcc1bbeb9e (diff) | |
download | org.eclipse.cdt-654e12094a5b0b77e8877550922343dc5def49c9.tar.gz org.eclipse.cdt-654e12094a5b0b77e8877550922343dc5def49c9.tar.xz org.eclipse.cdt-654e12094a5b0b77e8877550922343dc5def49c9.zip |
Bug 337937: CopyLocation for copied AST-Node
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337937
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom')
179 files changed, 1833 insertions, 578 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java index f49f59b8eaa..721950391e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,6 +44,10 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod throw new UnsupportedOperationException(); } + public final IASTExpression copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public final void addExpression(IASTExpression e) { throw new UnsupportedOperationException(); } 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 8ebef4fc505..dcc060262b2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -53,6 +53,10 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu throw new UnsupportedOperationException(); } + public final IASTExpression copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public void addExpression(IASTExpression e) { throw new UnsupportedOperationException(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java new file mode 100644 index 00000000000..0d72769cb64 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Institute for Software (IFS)- initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IASTCopyLocation; +import org.eclipse.cdt.core.dom.ast.IASTFileLocation; +import org.eclipse.cdt.core.dom.ast.IASTNode; + +/** + * @author Emanuel Graf IFS + * + */ +public class ASTCopyLocation implements IASTCopyLocation { + + private IASTNode originalNode; + + + + public ASTCopyLocation(IASTNode originalNode) { + this.originalNode = originalNode; + } + + public int getNodeOffset() { + return 0; + } + + public int getNodeLength() { + return 0; + } + + public IASTFileLocation asFileLocation() { + return null; + } + + public IASTNode getOriginalNode() { + return originalNode; + } + +} 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 a576299d9a7..a1b601b2878 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,11 +12,11 @@ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; /** * Base class for c- and c++ enumerators. @@ -35,9 +35,9 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I setValue(value); } - protected void copyAbstractEnumerator(ASTEnumerator copy) { - copy.setName(name == null ? null : name.copy()); - copy.setValue(value == null ? null : value.copy()); + protected void copyAbstractEnumerator(ASTEnumerator copy, CopyStyle style) { + copy.setName(name == null ? null : name.copy(style)); + copy.setValue(value == null ? null : value.copy(style)); copy.setOffsetAndLength(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index 74c5369d96d..c0fecc0a4fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog; import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; import org.eclipse.cdt.internal.core.parser.scanner.Lexer; -import org.eclipse.cdt.internal.core.parser.scanner.Token; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; +import org.eclipse.cdt.internal.core.parser.scanner.Token; /** * Base class for all non-preprocessor nodes in the AST. @@ -341,4 +341,9 @@ public abstract class ASTNode implements IASTNode { } return null; } + + protected void setCopyLocation(IASTNode originalNode) { + locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)}; + } + } 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 ecc0f263630..660b320d26c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,11 +51,18 @@ public class ASTProblem extends ASTNode implements IASTProblem { } public ASTProblem copy() { + return copy(CopyStyle.withoutLocations); + } + + public ASTProblem copy(CopyStyle style) { ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError); problem.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + problem.setCopyLocation(this); + } return problem; } - + public int getID() { return id; } 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 d77e8da2e07..fbf4c29b2b1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -406,7 +406,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat */ public abstract void resolveAmbiguities(); - protected void copyAbstractTU(ASTTranslationUnit copy) { + protected void copyAbstractTU(ASTTranslationUnit copy, CopyStyle style) { copy.setIndex(fIndex); copy.setIsHeaderUnit(fIsHeader); copy.setASTNodeFactory(fNodeFactory); @@ -414,7 +414,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat copy.setIsForContentAssist(fForContentAssist); for (IASTDeclaration declaration : getDeclarations()) - copy.addDeclaration(declaration == null ? null : declaration.copy()); + copy.addDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java index 2041d33ab61..fcdac6f06b7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,10 +32,13 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements setInitializer(i); } - protected void initializeCopy(ASTTypeIdInitializerExpression copy) { - copy.setTypeId(typeId == null ? null : typeId.copy()); - copy.setInitializer(initializer == null ? null : initializer.copy()); + protected void initializeCopy(ASTTypeIdInitializerExpression copy, CopyStyle style) { + copy.setTypeId(typeId == null ? null : typeId.copy(style)); + copy.setInitializer(initializer == null ? null : initializer.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } } public IASTTypeId getTypeId() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index bba0e40222a..8b28d716893 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1168,6 +1168,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { throw new UnsupportedOperationException(); } + public IASTExpression copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public IType getExpressionType() { throw new UnsupportedOperationException(); } 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 5024bdd2094..8a7bcfc5dd1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,4 +26,9 @@ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifi * @since 5.1 */ public IASTInternalEnumerationSpecifier copy(); + + /** + * @since 5.3 + */ + public IASTInternalEnumerationSpecifier copy(CopyStyle style); } 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 4201b859b18..ad142186219 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,12 +30,19 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration { } public CASTASMDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTASMDeclaration copy(CopyStyle style) { CASTASMDeclaration copy = new CASTASMDeclaration(); copy.assembly = assembly == null ? null : assembly.clone(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public String getAssembly() { if( assembly == null ) return ""; //$NON-NLS-1$ return new String( assembly ); 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 63de5712bea..5bccbb1cd58 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -113,4 +113,8 @@ public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmb public IASTDeclarator copy() { throw new UnsupportedOperationException(); } + + public IASTDeclarator copy(CopyStyle style) { + 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 ec8a2491b0d..7e4b98eadbd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,4 +51,7 @@ public class CASTAmbiguousExpression extends ASTAmbiguousNode implements IASTAmb throw new UnsupportedOperationException(); } + public IASTExpression copy(CopyStyle style) { + 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 870e1097c4e..9c457577c21 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -88,4 +88,7 @@ public class CASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implemen throw new UnsupportedOperationException(); } + public IASTParameterDeclaration copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java index 27057b59b06..27e7424a91c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,6 +60,10 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements throw new UnsupportedOperationException(); } + public IASTSimpleDeclaration copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public void addDeclarator(IASTDeclarator declarator) { fSimpleDecl.addDeclarator(declarator); } 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 a524f13f910..0a62bc6d06b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,5 +62,8 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi throw new UnsupportedOperationException(); } + public IASTStatement copy(CopyStyle style) { + 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 c5cce07557d..3efa82c283c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,10 +39,18 @@ public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDecl @Override public CASTArrayDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CASTArrayDeclarator copy(CopyStyle style) { CASTArrayDeclarator copy = new CASTArrayDeclarator(); - copyBaseDeclarator(copy); + copyBaseDeclarator(copy, style); for(IASTArrayModifier modifier : getArrayModifiers()) copy.addArrayModifier(modifier == null ? null : modifier.copy()); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 1a86046514c..384181d0d6c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,8 +36,15 @@ public class CASTArrayDesignator extends ASTNode implements } public CASTArrayDesignator copy() { - CASTArrayDesignator copy = new CASTArrayDesignator(exp == null ? null : exp.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTArrayDesignator copy(CopyStyle style) { + CASTArrayDesignator copy = new CASTArrayDesignator(exp == null ? null : exp.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 9cf39e3bae6..71879af4e2f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,13 +38,20 @@ public class CASTArrayModifier extends ASTNode implements ICASTArrayModifier, IA } public CASTArrayModifier copy() { - CASTArrayModifier copy = new CASTArrayModifier(exp == null ? null : exp.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTArrayModifier copy(CopyStyle style) { + CASTArrayModifier copy = new CASTArrayModifier(exp == null ? null : exp.copy(style)); copy.setOffsetAndLength(this); copy.isVolatile = isVolatile; copy.isRestrict = isRestrict; copy.isStatic = isStatic; copy.isConst = isConst; copy.isVarSized = isVarSized; + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 6df3fb1806a..84cf3d16635 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,10 +36,17 @@ public class CASTArrayRangeDesignator extends ASTNode implements } public CASTArrayRangeDesignator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTArrayRangeDesignator copy(CopyStyle style) { CASTArrayRangeDesignator copy = new CASTArrayRangeDesignator(); - copy.setRangeFloor(floor == null ? null : floor.copy()); - copy.setRangeCeiling(ceiling == null ? null : ceiling.copy()); + copy.setRangeFloor(floor == null ? null : floor.copy(style)); + copy.setRangeCeiling(ceiling == null ? null : ceiling.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 9939349053a..adbeef10a4b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,13 +41,20 @@ public class CASTArraySubscriptExpression extends ASTNode implements } public CASTArraySubscriptExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTArraySubscriptExpression copy(CopyStyle style) { CASTArraySubscriptExpression copy = new CASTArraySubscriptExpression(); - copy.setArrayExpression(array == null ? null : array.copy()); - copy.setSubscriptExpression(subscript == null ? null : subscript.copy()); + copy.setArrayExpression(array == null ? null : array.copy(style)); + copy.setSubscriptExpression(subscript == null ? null : subscript.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java index 6fb31b32818..dd4519af63c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,11 +45,18 @@ public class CASTBinaryExpression extends ASTNode implements } public CASTBinaryExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTBinaryExpression copy(CopyStyle style) { CASTBinaryExpression copy = new CASTBinaryExpression(); copy.op = op; - copy.setOperand1(operand1 == null ? null : operand1.copy()); - copy.setOperand2(operand2 == null ? null : operand2.copy()); + copy.setOperand1(operand1 == null ? null : operand1.copy(style)); + copy.setOperand2(operand2 == null ? null : operand2.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 6e677e60cdb..d3a88bab4c4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,8 +42,15 @@ public class CASTBreakStatement extends ASTNode implements IASTBreakStatement { } public CASTBreakStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTBreakStatement copy(CopyStyle style) { CASTBreakStatement copy = new CASTBreakStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 c0cd0b572f0..98ed38a8545 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,8 +34,15 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS } public CASTCaseStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTCaseStatement copy(CopyStyle style) { CASTCaseStatement copy = new CASTCaseStatement(expression == null ? null : expression.copy()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 fcdc01835a4..69b7e6e32b7 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,11 +40,18 @@ public class CASTCastExpression extends ASTNode implements IASTCastExpression, I } public CASTCastExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTCastExpression copy(CopyStyle style) { CASTCastExpression copy = new CASTCastExpression(); - copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setTypeId(typeId == null ? null : typeId.copy(style)); IASTExpression operand = getOperand(); - copy.setOperand(operand == null ? null : operand.copy()); + copy.setOperand(operand == null ? null : operand.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 2c9e70a1a5e..158a3edfe78 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,17 +44,24 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements } public CASTCompositeTypeSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTCompositeTypeSpecifier copy(CopyStyle style) { CASTCompositeTypeSpecifier copy = new CASTCompositeTypeSpecifier(); - copyCompositeTypeSpecifier(copy); + copyCompositeTypeSpecifier(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - - protected void copyCompositeTypeSpecifier(CASTCompositeTypeSpecifier copy) { + + protected void copyCompositeTypeSpecifier(CASTCompositeTypeSpecifier copy, CopyStyle style) { copyBaseDeclSpec(copy); copy.setKey(fKey); - copy.setName(fName == null ? null : fName.copy()); + copy.setName(fName == null ? null : fName.copy(style)); for(IASTDeclaration member : getMembers()) - copy.addMemberDeclaration(member == null ? null : member.copy()); + copy.addMemberDeclaration(member == null ? null : member.copy(style)); } public int getKey() { 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 8bcff86ccfb..446625861d9 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,13 +29,20 @@ public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatem private IScope scope = null; public CASTCompoundStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTCompoundStatement copy(CopyStyle style) { CASTCompoundStatement copy = new CASTCompoundStatement(); for (IASTStatement statement : getStatements()) - copy.addStatement(statement == null ? null : statement.copy()); + copy.addStatement(statement == null ? null : statement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 0b14d22960c..43008679d9c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,9 +37,16 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC } public CASTCompoundStatementExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTCompoundStatementExpression copy(CopyStyle style) { CASTCompoundStatementExpression copy = new CASTCompoundStatementExpression(); - copy.setCompoundStatement(statement == null ? null : statement.copy()); + copy.setCompoundStatement(statement == null ? null : statement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 46e03e13739..69774aed6f8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,11 +42,18 @@ public class CASTConditionalExpression extends ASTNode implements } public CASTConditionalExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTConditionalExpression copy(CopyStyle style) { 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.setLogicalConditionExpression(condition == null ? null : condition.copy(style)); + copy.setPositiveResultExpression(positive == null ? null : positive.copy(style)); + copy.setNegativeResultExpression(negative == null ? null : negative.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 017cd079e58..0edff204ad1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,8 +40,15 @@ public class CASTContinueStatement extends ASTNode implements IASTContinueStatem } public CASTContinueStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTContinueStatement copy(CopyStyle style) { CASTContinueStatement copy = new CASTContinueStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 ee1942a5596..2c1055f195c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,12 +36,19 @@ public class CASTDeclarationStatement extends ASTNode implements IASTDeclaration public CASTDeclarationStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTDeclarationStatement copy(CopyStyle style) { CASTDeclarationStatement copy = new CASTDeclarationStatement(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 8e85922cdb8..ed669b53a32 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,17 +52,24 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig } public CASTDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTDeclarator copy(CopyStyle style) { CASTDeclarator copy = new CASTDeclarator(); - copyBaseDeclarator(copy); + copyBaseDeclarator(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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()); + protected void copyBaseDeclarator(CASTDeclarator copy, CopyStyle style) { + copy.setName(name == null ? null : name.copy(style)); + copy.setInitializer(initializer == null ? null : initializer.copy(style)); + copy.setNestedDeclarator(nestedDeclarator == null ? null : nestedDeclarator.copy(style)); for(IASTPointerOperator pointer : getPointerOperators()) - copy.addPointerOperator(pointer == null ? null : pointer.copy()); + copy.addPointerOperator(pointer == null ? null : pointer.copy(style)); copy.setOffsetAndLength(this); } 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 d8655f2fa44..c8f11013496 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,8 +40,15 @@ public class CASTDefaultStatement extends ASTNode implements IASTDefaultStatemen } public CASTDefaultStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTDefaultStatement copy(CopyStyle style) { CASTDefaultStatement copy = new CASTDefaultStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 14a62cfdb37..6ac163ae905 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,13 +41,21 @@ public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignate } public CASTDesignatedInitializer copy() { - CASTDesignatedInitializer copy = new CASTDesignatedInitializer(rhs == null ? null : rhs.copy()); - for(ICASTDesignator designator : getDesignators()) - copy.addDesignator(designator == null ? null : designator.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTDesignatedInitializer copy(CopyStyle style) { + CASTDesignatedInitializer copy = new CASTDesignatedInitializer(rhs == null ? null + : rhs.copy(style)); + for (ICASTDesignator designator : getDesignators()) + copy.addDesignator(designator == null ? null : designator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 f67975a1e74..cf9a4b921fd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,13 +37,20 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb } public CASTDoStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTDoStatement copy(CopyStyle style) { CASTDoStatement copy = new CASTDoStatement(); - copy.setBody(body == null ? null : body.copy()); - copy.setCondition(condition == null ? null : condition.copy()); + copy.setBody(body == null ? null : body.copy(style)); + copy.setCondition(condition == null ? null : condition.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 85735f522ca..49a78944aec 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,11 +44,19 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement } public CASTElaboratedTypeSpecifier copy() { - CASTElaboratedTypeSpecifier copy = new CASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTElaboratedTypeSpecifier copy(CopyStyle style) { + CASTElaboratedTypeSpecifier copy = new CASTElaboratedTypeSpecifier(kind, name == null + ? null : name.copy(style)); copyBaseDeclSpec(copy); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerationSpecifier.java index bdf034e6679..f608ab7fedf 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,16 +36,23 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier } public CASTEnumerationSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTEnumerationSpecifier copy(CopyStyle style) { CASTEnumerationSpecifier copy = new CASTEnumerationSpecifier(); - copyEnumerationSpecifier(copy); + copyEnumerationSpecifier(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - - protected void copyEnumerationSpecifier(CASTEnumerationSpecifier copy) { + + protected void copyEnumerationSpecifier(CASTEnumerationSpecifier copy, CopyStyle style) { copyBaseDeclSpec(copy); - copy.setName(name == null ? null : name.copy()); + copy.setName(name == null ? null : name.copy(style)); for(IASTEnumerator enumerator : getEnumerators()) - copy.addEnumerator(enumerator == null ? null : enumerator.copy()); + copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); } 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 9ec6dbbd240..ae177dd50df 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,8 +28,15 @@ public class CASTEnumerator extends ASTEnumerator { } public CASTEnumerator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTEnumerator copy(CopyStyle style) { CASTEnumerator copy = new CASTEnumerator(); - copyAbstractEnumerator(copy); + copyAbstractEnumerator(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java index 41ec7663860..3adfd1895f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,9 +26,16 @@ public class CASTEqualsInitializer extends ASTEqualsInitializer { } public CASTEqualsInitializer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTEqualsInitializer copy(CopyStyle style) { IASTInitializerClause arg = getInitializerClause(); - CASTEqualsInitializer copy = new CASTEqualsInitializer(arg == null ? null : arg.copy()); + CASTEqualsInitializer copy = new CASTEqualsInitializer(arg == null ? null : arg.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 3216f5cd223..f9ae206921a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,10 +30,17 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList, IASTAmbiguityParent { public CASTExpressionList copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTExpressionList copy(CopyStyle style) { CASTExpressionList copy = new CASTExpressionList(); for(IASTExpression expr : getExpressions()) - copy.addExpression(expr == null ? null : expr.copy()); + copy.addExpression(expr == null ? null : expr.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 82f50113bea..7518341f860 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,9 +35,16 @@ public class CASTExpressionStatement extends ASTNode implements } public CASTExpressionStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTExpressionStatement copy(CopyStyle style) { CASTExpressionStatement copy = new CASTExpressionStatement(); - copy.setExpression(expression == null ? null : expression.copy()); + copy.setExpression(expression == null ? null : expression.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 e7bc7f185a6..cca54bc845a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,12 +33,20 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl @Override public CASTFieldDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CASTFieldDeclarator copy(CopyStyle style) { CASTFieldDeclarator copy = new CASTFieldDeclarator(); - copyBaseDeclarator(copy); - copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy()); + copyBaseDeclarator(copy, style); + copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy(style)); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 2cf4a58a08b..2e74509505f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,8 +33,15 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator } public CASTFieldDesignator copy() { - CASTFieldDesignator copy = new CASTFieldDesignator(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTFieldDesignator copy(CopyStyle style) { + CASTFieldDesignator copy = new CASTFieldDesignator(name == null ? null : name.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 9b4139e4828..93f6f5d5dc5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,11 +52,18 @@ public class CASTFieldReference extends ASTNode implements IASTFieldReference, I } public CASTFieldReference copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTFieldReference copy(CopyStyle style) { CASTFieldReference copy = new CASTFieldReference(); - copy.setFieldOwner(owner == null ? null : owner.copy()); - copy.setFieldName(name == null ? null : name.copy()); + copy.setFieldOwner(owner == null ? null : owner.copy(style)); + copy.setFieldName(name == null ? null : name.copy(style)); copy.ptr = ptr; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 30e23d5925e..12ffbeda5ad 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,16 +44,24 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA } public CASTForStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTForStatement copy(CopyStyle style) { CASTForStatement copy = new CASTForStatement(); - copyForStatement(copy); + copyForStatement(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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()); + protected void copyForStatement(CASTForStatement copy, CopyStyle style) { + copy.setInitializerStatement(init == null ? null : init.copy(style)); + copy.setConditionExpression(condition == null ? null : condition.copy(style)); + copy.setIterationExpression(iterationExpression == null ? null : iterationExpression + .copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); } 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 1861552ecf0..efd9268ac22 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,20 +46,27 @@ public class CASTFunctionCallExpression extends ASTNode implements } public CASTFunctionCallExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTFunctionCallExpression copy(CopyStyle style) { IASTInitializerClause[] args = null; if (fArguments.length > 0) { - args= new IASTInitializerClause[fArguments.length]; - for (int i=0; i<fArguments.length; i++) { - args[i]= fArguments[i].copy(); + args = new IASTInitializerClause[fArguments.length]; + for (int i = 0; i < fArguments.length; i++) { + args[i] = fArguments[i].copy(style); } } CASTFunctionCallExpression copy = new CASTFunctionCallExpression(null, args); - copy.setFunctionNameExpression(functionName == null ? null : functionName.copy()); + copy.setFunctionNameExpression(functionName == null ? null : functionName.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 dabfdacfd5a..5248612a2a9 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,13 +42,21 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda @Override public CASTFunctionDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CASTFunctionDeclarator copy(CopyStyle style) { CASTFunctionDeclarator copy = new CASTFunctionDeclarator(); - copyBaseDeclarator(copy); + copyBaseDeclarator(copy, style); copy.varArgs = varArgs; for(IASTParameterDeclaration param : getParameters()) - copy.addParameterDeclaration(param == null ? null : param.copy()); + copy.addParameterDeclaration(param == null ? null : param.copy(style)); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 6f9fe0b28f0..3cda61a2d81 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,17 +44,25 @@ public class CASTFunctionDefinition extends ASTNode implements IASTFunctionDefin } public CASTFunctionDefinition copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTFunctionDefinition copy(CopyStyle style) { CASTFunctionDefinition copy = new CASTFunctionDefinition(); - copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); if (declarator != null) { IASTDeclarator outer = CVisitor.findOutermostDeclarator(declarator); - outer = outer.copy(); + outer = outer.copy(style); copy.setDeclarator((IASTFunctionDeclarator) CVisitor.findTypeRelevantDeclarator(outer)); } - copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); + copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } + return copy; } 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 acf082c7de6..b8434f3a55c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,15 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement { } public CASTGotoStatement copy() { - CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTGotoStatement copy(CopyStyle style) { + CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 79f8c46e953..6f2d3ae1acd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,11 +47,18 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC } public CASTIdExpression copy() { - CASTIdExpression copy = new CASTIdExpression(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTIdExpression copy(CopyStyle style) { + CASTIdExpression copy = new CASTIdExpression(name == null ? null : name.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 0b10a7ad6ff..3f036955cad 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,11 +46,18 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb } public CASTIfStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTIfStatement copy(CopyStyle style) { 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.setConditionExpression(condition == null ? null : condition.copy(style)); + copy.setThenClause(thenClause == null ? null : thenClause.copy(style)); + copy.setElseClause(elseClause == null ? null : elseClause.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 5828125664c..b023dd83275 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,10 +27,18 @@ public class CASTInitializerExpression extends CASTEqualsInitializer implements @Override public CASTInitializerExpression copy() { - CASTInitializerExpression copy= new CASTInitializerExpression(); - IASTInitializerClause init= getInitializerClause(); - copy.setInitializerClause(init == null ? null : init.copy()); + return copy(CopyStyle.withoutLocations); + } + + @Override + public CASTInitializerExpression copy(CopyStyle style) { + CASTInitializerExpression copy = new CASTInitializerExpression(); + IASTInitializerClause init = getInitializerClause(); + copy.setInitializerClause(init == null ? null : init.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } 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 4acd1b729cb..bf7404a3598 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,15 +33,21 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList, private int actualSize; public CASTInitializerList copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTInitializerList copy(CopyStyle style) { CASTInitializerList copy = new CASTInitializerList(); - for(IASTInitializerClause initializer : getClauses()) - copy.addClause(initializer == null ? null : initializer.copy()); + for (IASTInitializerClause initializer : getClauses()) + copy.addClause(initializer == null ? null : initializer.copy(style)); copy.setOffsetAndLength(this); - copy.actualSize= getSize(); + copy.actualSize = getSize(); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - public int getSize() { return actualSize; } 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 e3c0f08ade4..db49f4ce404 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,27 +40,34 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn @Override public CASTKnRFunctionDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CASTKnRFunctionDeclarator copy(CopyStyle style) { CASTKnRFunctionDeclarator copy = new CASTKnRFunctionDeclarator(); - copyBaseDeclarator(copy); - + copyBaseDeclarator(copy, style); + copy.parameterNames = new IASTName[parameterNames.length]; - for(int i = 0; i < parameterNames.length; i++) { - if(parameterNames[i] != null) { - copy.parameterNames[i] = parameterNames[i].copy(); + for (int i = 0; i < parameterNames.length; i++) { + if (parameterNames[i] != null) { + copy.parameterNames[i] = parameterNames[i].copy(style); 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(); + for (int i = 0; i < parameterDeclarations.length; i++) { + if (parameterDeclarations[i] != null) { + copy.parameterDeclarations[i] = parameterDeclarations[i].copy(style); copy.parameterDeclarations[i].setParent(copy); copy.parameterDeclarations[i].setPropertyInParent(FUNCTION_PARAMETER); } } - + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 423d7be59c8..4743fe80c28 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 @@ -37,10 +37,17 @@ public class CASTLabelStatement extends ASTNode implements IASTLabelStatement, I } public CASTLabelStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTLabelStatement copy(CopyStyle style) { CASTLabelStatement copy = new CASTLabelStatement(); - copy.setName(name == null ? null : name.copy()); - copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy()); + copy.setName(name == null ? null : name.copy(style)); + copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 2a742c04c26..a410c76a0d4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,8 +39,15 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress } public CASTLiteralExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTLiteralExpression copy(CopyStyle style) { CASTLiteralExpression copy = new CASTLiteralExpression(kind, value == null ? null : value.clone()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 ea060c36936..6af97c235c8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,11 +49,18 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext } public CASTName copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTName copy(CopyStyle style) { CASTName copy = new CASTName(name == null ? null : name.clone()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 caa43d98709..e220493a4b2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,8 +40,15 @@ public class CASTNullStatement extends ASTNode implements IASTNullStatement { } public CASTNullStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTNullStatement copy(CopyStyle style) { CASTNullStatement copy = new CASTNullStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 8dc941de1b6..7d5778013fd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,10 +37,17 @@ public class CASTParameterDeclaration extends ASTNode implements IASTParameterDe } public CASTParameterDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTParameterDeclaration copy(CopyStyle style) { CASTParameterDeclaration copy = new CASTParameterDeclaration(); - copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); - copy.setDeclarator(declarator == null ? null : declarator.copy()); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style)); + copy.setDeclarator(declarator == null ? null : declarator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 dc8a6ae3a4e..40d3e3b8b20 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,11 +22,18 @@ public class CASTPointer extends ASTNode implements ICASTPointer { private boolean isConst; public CASTPointer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTPointer copy(CopyStyle style) { CASTPointer copy = new CASTPointer(); copy.isRestrict = isRestrict; copy.isVolatile = isVolatile; copy.isConst = isConst; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 5c2ff538de3..06f3a4f97ee 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,15 @@ public class CASTProblemDeclaration extends CASTProblemOwner implements } public CASTProblemDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTProblemDeclaration copy(CopyStyle style) { CASTProblemDeclaration copy = new CASTProblemDeclaration(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 49b06b33d7e..0accd8ef4b4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,8 +30,15 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl } public CASTProblemExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTProblemExpression copy(CopyStyle style) { CASTProblemExpression copy = new CASTProblemExpression(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 f3ca375da7c..e965035a503 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,8 +30,8 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder { setProblem(problem); } - protected void copyBaseProblem(CASTProblemOwner copy) { - copy.setProblem(problem == null ? null : problem.copy()); + protected void copyBaseProblem(CASTProblemOwner copy, CopyStyle style) { + copy.setProblem(problem == null ? null : problem.copy(style)); copy.setOffsetAndLength(this); } 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 39f8af954ca..57e30e100a1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,15 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble } public CASTProblemStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTProblemStatement copy(CopyStyle style) { CASTProblemStatement copy = new CASTProblemStatement(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 7e8520d217d..8aa50c8cd9d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,8 +33,16 @@ public class CASTReturnStatement extends ASTNode implements } public CASTReturnStatement copy() { - CASTReturnStatement copy = new CASTReturnStatement(retValue == null ? null : retValue.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTReturnStatement copy(CopyStyle style) { + CASTReturnStatement copy = new CASTReturnStatement(retValue == null ? null + : retValue.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 8f221c8464b..eb449a9b22d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,12 +33,19 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC private IASTExpression fDeclTypeExpression; public CASTSimpleDeclSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTSimpleDeclSpecifier copy(CopyStyle style) { CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy); + copySimpleDeclSpec(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - - protected void copySimpleDeclSpec(CASTSimpleDeclSpecifier copy) { + + protected void copySimpleDeclSpec(CASTSimpleDeclSpecifier copy, CopyStyle style) { copyBaseDeclSpec(copy); copy.simpleType = simpleType; copy.isSigned = isSigned; @@ -49,7 +56,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC copy.complex = complex; copy.imaginary = imaginary; if (fDeclTypeExpression != null) - copy.setDeclTypeExpression(fDeclTypeExpression.copy()); + copy.setDeclTypeExpression(fDeclTypeExpression.copy(style)); } public int getType() { 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 5c33c6e04db..d2858934b81 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,13 +35,20 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat } public CASTSimpleDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTSimpleDeclaration copy(CopyStyle style) { CASTSimpleDeclaration copy = new CASTSimpleDeclaration(); - copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); for(IASTDeclarator declarator : getDeclarators()) - copy.addDeclarator(declarator == null ? null : declarator.copy()); + copy.addDeclarator(declarator == null ? null : declarator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 b4a0223742f..1b64b469161 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,10 +37,17 @@ public class CASTSwitchStatement extends ASTNode implements } public CASTSwitchStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTSwitchStatement copy(CopyStyle style) { CASTSwitchStatement copy = new CASTSwitchStatement(); - copy.setControllerExpression(controller == null ? null : controller.copy()); - copy.setBody(body == null ? null : body.copy()); + copy.setControllerExpression(controller == null ? null : controller.copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 022bb811452..743c942ee2d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,11 +39,18 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig } public CASTTranslationUnit copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTTranslationUnit copy(CopyStyle style) { CASTTranslationUnit copy = new CASTTranslationUnit(); - copyAbstractTU(copy); + copyAbstractTU(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 8cf11a0e6ca..0bf0ded885d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,10 +34,17 @@ public class CASTTypeId extends ASTNode implements IASTTypeId { } public CASTTypeId copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTTypeId copy(CopyStyle style) { CASTTypeId copy = new CASTTypeId(); - copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); - copy.setAbstractDeclarator(declarator == null ? null : declarator.copy()); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); + copy.setAbstractDeclarator(declarator == null ? null : declarator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 03ffa41d0b5..f732e93a0e1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,8 +35,16 @@ public class CASTTypeIdExpression extends ASTNode implements IASTTypeIdExpressio } public CASTTypeIdExpression copy() { - CASTTypeIdExpression copy = new CASTTypeIdExpression(op, typeId == null ? null : typeId.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTTypeIdExpression copy(CopyStyle style) { + CASTTypeIdExpression copy = new CASTTypeIdExpression(op, typeId == null ? null + : typeId.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 b8e8249a1ee..02d99fe3d6f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,8 +33,12 @@ public class CASTTypeIdInitializerExpression extends ASTTypeIdInitializerExpress } public CASTTypeIdInitializerExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTTypeIdInitializerExpression copy(CopyStyle style) { CASTTypeIdInitializerExpression copy = new CASTTypeIdInitializerExpression(); - initializeCopy(copy); + initializeCopy(copy, style); return copy; } 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 014f699613b..9a72ff0ef4d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,11 +37,19 @@ public class CASTTypedefNameSpecifier extends CASTBaseDeclSpecifier implements } public CASTTypedefNameSpecifier copy() { - CASTTypedefNameSpecifier copy = new CASTTypedefNameSpecifier(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTTypedefNameSpecifier copy(CopyStyle style) { + CASTTypedefNameSpecifier copy = new CASTTypedefNameSpecifier(name == null ? null + : name.copy(style)); copyBaseDeclSpec(copy); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java index 7c492ec19f3..7ddb5d5447d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,11 +40,19 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression, } public CASTUnaryExpression copy() { - CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null : operand.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CASTUnaryExpression copy(CopyStyle style) { + CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null + : operand.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 e58325544d8..95d7732e478 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,13 +37,20 @@ public class CASTWhileStatement extends ASTNode implements IASTWhileStatement, I } public CASTWhileStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CASTWhileStatement copy(CopyStyle style) { CASTWhileStatement copy = new CASTWhileStatement(); - copy.setCondition(condition == null ? null : condition.copy()); - copy.setBody(body == null ? null : body.copy()); + copy.setCondition(condition == null ? null : condition.copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 be7031e023e..f7c3f785e58 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,16 @@ public class GCCASTSimpleDeclSpecifier extends CASTSimpleDeclSpecifier implement @Override public GCCASTSimpleDeclSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public GCCASTSimpleDeclSpecifier copy(CopyStyle style) { GCCASTSimpleDeclSpecifier copy = new GCCASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy); + copySimpleDeclSpec(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 183dcf28b69..ea800d4ad32 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,12 +28,19 @@ public class CPPASTASMDeclaration extends ASTNode implements IASTASMDeclaration } public CPPASTASMDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTASMDeclaration copy(CopyStyle style) { CPPASTASMDeclaration copy = new CPPASTASMDeclaration(); copy.assembly = assembly.clone(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTAmbiguousCondition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java index 688159d2224..10d411031b4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,4 +52,8 @@ public class CPPASTAmbiguousCondition extends ASTAmbiguousNode implements IASTAm public IASTExpression copy() { throw new UnsupportedOperationException(); } + + public IASTExpression copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } } 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 64e6b882300..7b2be658f5f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -66,6 +66,10 @@ public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTA public IASTDeclarator copy() { throw new UnsupportedOperationException(); } + + public IASTDeclarator copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } public void addDeclarator(IASTDeclarator d) { assertNotFrozen(); 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 6457d1ab91a..9081750edc5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,6 +33,10 @@ public class CPPASTAmbiguousExpression extends ASTAmbiguousNode implements throw new UnsupportedOperationException(); } + public IASTExpression copy(CopyStyle style) { + 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/CPPASTAmbiguousParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java index 09d2ae08efd..f58d3afbb9b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -109,6 +109,11 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem return null; } + public ICPPASTParameterDeclaration copy(CopyStyle style) { + Assert.isLegal(false); + return null; + } + public boolean isParameterPack() { Assert.isLegal(false); return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java index 57e19cef7bb..a546fb979d2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 IBM Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,6 +62,10 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement throw new UnsupportedOperationException(); } + public IASTSimpleDeclaration copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public void addDeclarator(IASTDeclarator declarator) { fSimpleDecl.addDeclarator(declarator); } 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 c21dea58066..3e42da6fbdd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,6 +43,10 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements throw new UnsupportedOperationException(); } + public IASTStatement copy(CopyStyle style) { + 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 7984a68f3b9..480e4f2282c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Symbian Software Systems and others. + * Copyright (c) 2008, 2011 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -85,19 +85,23 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements public IASTNode copy() { - + return copy(CopyStyle.withoutLocations); + } + + public IASTNode copy(CopyStyle style) { + int sizeOfNodes = fNodes.size(); IASTNode[] copyNodes = new IASTNode[sizeOfNodes]; int arrayIndex = 0; for(IASTNode node : fNodes) { if(node!=null){ - copyNodes[arrayIndex]=node.copy(); + copyNodes[arrayIndex] = node.copy(style); }else{ copyNodes[arrayIndex]=null; } arrayIndex++; } - + ICPPASTAmbiguousTemplateArgument ambiguityNode = new CPPASTAmbiguousTemplateArgument(copyNodes); return ambiguityNode; } 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 9539f783f77..3406fc1f42e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,13 +41,22 @@ public class CPPASTArrayDeclarator extends CPPASTDeclarator implements ICPPASTAr @Override public CPPASTArrayDeclarator copy() { - CPPASTArrayDeclarator copy = new CPPASTArrayDeclarator(); - copyBaseDeclarator(copy); - for(IASTArrayModifier modifier : getArrayModifiers()) - copy.addArrayModifier(modifier == null ? null : modifier.copy()); - return copy; + return copy(CopyStyle.withoutLocations); } + + @Override + public CPPASTArrayDeclarator copy(CopyStyle style) { + CPPASTArrayDeclarator copy = new CPPASTArrayDeclarator(); + copyBaseDeclarator(copy, style); + for (IASTArrayModifier modifier : getArrayModifiers()) + copy.addArrayModifier(modifier == null ? null : modifier.copy(style)); + + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } + 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/cpp/CPPASTArrayModifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArrayModifier.java index ccd7d51ed4b..2daa77ea6f6 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,11 +37,18 @@ public class CPPASTArrayModifier extends ASTNode implements IASTArrayModifier, I } public CPPASTArrayModifier copy() { - CPPASTArrayModifier copy = new CPPASTArrayModifier(exp == null ? null : exp.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTArrayModifier copy(CopyStyle style) { + CPPASTArrayModifier copy = new CPPASTArrayModifier(exp == null ? null : exp.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 708363ffd31..de4787694e8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -54,13 +54,19 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr } public CPPASTArraySubscriptExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTArraySubscriptExpression copy(CopyStyle style) { CPPASTArraySubscriptExpression copy = new CPPASTArraySubscriptExpression(); - copy.setArrayExpression(arrayExpression == null ? null : arrayExpression.copy()); - copy.setArgument(subscriptExp == null ? null : subscriptExp.copy()); + copy.setArrayExpression(arrayExpression == null ? null : arrayExpression.copy(style)); + copy.setArgument(subscriptExp == null ? null : subscriptExp.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java index 3e00dccd55c..bcd6f147c78 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,11 +49,18 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier } public CPPASTBaseSpecifier copy() { - CPPASTBaseSpecifier copy = new CPPASTBaseSpecifier(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTBaseSpecifier copy(CopyStyle style) { + CPPASTBaseSpecifier copy = new CPPASTBaseSpecifier(name == null ? null : name.copy(style)); copy.isVirtual = isVirtual; copy.visibility = visibility; copy.fIsPackExpansion= fIsPackExpansion; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 db989a8de0c..9663c2c9c3b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; @@ -57,14 +60,21 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr } public CPPASTBinaryExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTBinaryExpression copy(CopyStyle style) { CPPASTBinaryExpression copy = new CPPASTBinaryExpression(); copy.op = op; - copy.setOperand1(operand1 == null ? null : operand1.copy()); - copy.setInitOperand2(operand2 == null ? null : operand2.copy()); + copy.setOperand1(operand1 == null ? null : operand1.copy(style)); + copy.setInitOperand2(operand2 == null ? null : operand2.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 133c0bcf14d..adb97f5e7de 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,8 +40,15 @@ public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement } public CPPASTBreakStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTBreakStatement copy(CopyStyle style) { CPPASTBreakStatement copy = new CPPASTBreakStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java index 5907c783c61..c747442d292 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,12 +27,19 @@ public class CPPASTCapture extends ASTNode implements ICPPASTCapture { } public CPPASTCapture copy() { - final CPPASTCapture result= new CPPASTCapture(); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCapture copy(CopyStyle style) { + final CPPASTCapture result = new CPPASTCapture(); if (fIdentifier != null) - result.setIdentifier(fIdentifier.copy()); - result.fByReference= fByReference; - result.fPackExpansion= fPackExpansion; + result.setIdentifier(fIdentifier.copy(style)); + result.fByReference = fByReference; + result.fPackExpansion = fPackExpansion; result.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + result.setCopyLocation(this); + } return result; } 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 8f24687dc8f..dd1aa171540 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,8 +32,16 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I } public CPPASTCaseStatement copy() { - CPPASTCaseStatement copy = new CPPASTCaseStatement(expression == null ? null : expression.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCaseStatement copy(CopyStyle style) { + CPPASTCaseStatement copy = new CPPASTCaseStatement(expression == null ? null + : expression.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 f9d00d65129..dd0ec944973 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,12 +45,19 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi } public CPPASTCastExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCastExpression copy(CopyStyle style) { CPPASTCastExpression copy = new CPPASTCastExpression(); copy.setOperator(getOperator()); - copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setTypeId(typeId == null ? null : typeId.copy(style)); IASTExpression operand = getOperand(); - copy.setOperand(operand == null ? null : operand.copy()); + copy.setOperand(operand == null ? null : operand.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 4f608de62fe..965e07a3012 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,11 +39,18 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, } public CPPASTCatchHandler copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCatchHandler copy(CopyStyle style) { CPPASTCatchHandler copy = new CPPASTCatchHandler(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); - copy.setCatchBody(body == null ? null : body.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); + copy.setCatchBody(body == null ? null : body.copy(style)); copy.setIsCatchAll(isCatchAll); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 d5bcc184885..6209de3ac31 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,15 +47,24 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier } public CPPASTCompositeTypeSpecifier copy() { - CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCompositeTypeSpecifier copy(CopyStyle style) { + CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(fKey, fName == null + ? null : fName.copy(style)); copyBaseDeclSpec(copy); - for(IASTDeclaration member : getMembers()) - copy.addMemberDeclaration(member == null ? null : member.copy()); - for(ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) - copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy()); + for (IASTDeclaration member : getMembers()) + copy.addMemberDeclaration(member == null ? null : member.copy(style)); + for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) + copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style)); + + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public ICPPASTBaseSpecifier[] getBaseSpecifiers() { if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY; baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos ); 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 ea424aff157..0ffd9be7e1f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,10 +31,17 @@ public class CPPASTCompoundStatement extends ASTNode implements public CPPASTCompoundStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCompoundStatement copy(CopyStyle style) { CPPASTCompoundStatement copy = new CPPASTCompoundStatement(); - for(IASTStatement statement : getStatements()) - copy.addStatement(statement == null ? null : statement.copy()); + for (IASTStatement statement : getStatements()) + copy.addStatement(statement == null ? null : statement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 275edbe68ed..18d9622561b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,12 +40,19 @@ public class CPPASTCompoundStatementExpression extends ASTNode implements IGNUAS } public CPPASTCompoundStatementExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTCompoundStatementExpression copy(CopyStyle style) { CPPASTCompoundStatementExpression copy = new CPPASTCompoundStatementExpression(); - copy.setCompoundStatement(statement == null ? null : statement.copy()); + copy.setCompoundStatement(statement == null ? null : statement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 25096c9127b..febc7371a14 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,10 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -64,14 +67,21 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio public CPPASTConditionalExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTConditionalExpression copy(CopyStyle style) { CPPASTConditionalExpression copy = new CPPASTConditionalExpression(); - copy.setLogicalConditionExpression(fCondition == null ? null : fCondition.copy()); - copy.setPositiveResultExpression(fPositive == null ? null : fPositive.copy()); - copy.setNegativeResultExpression(fNegative == null ? null : fNegative.copy()); + copy.setLogicalConditionExpression(fCondition == null ? null : fCondition.copy(style)); + copy.setPositiveResultExpression(fPositive == null ? null : fPositive.copy(style)); + copy.setNegativeResultExpression(fNegative == null ? null : fNegative.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public IASTExpression getLogicalConditionExpression() { return fCondition; } 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 379a0013a63..64b49e12d20 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -59,11 +59,18 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements } public CPPASTConstructorChainInitializer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTConstructorChainInitializer copy(CopyStyle style) { CPPASTConstructorChainInitializer copy = new CPPASTConstructorChainInitializer(); - copy.setMemberInitializerId(name == null ? null : name.copy()); - copy.setInitializer(initializer == null ? null : initializer.copy()); + copy.setMemberInitializerId(name == null ? null : name.copy(style)); + copy.setInitializer(initializer == null ? null : initializer.copy(style)); copy.setOffsetAndLength(this); - copy.fIsPackExpansion= fIsPackExpansion; + copy.fIsPackExpansion = fIsPackExpansion; + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 cb599cea2b1..2328a97b62a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,15 +37,22 @@ public class CPPASTConstructorInitializer extends ASTNode implements ICPPASTCons } public CPPASTConstructorInitializer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTConstructorInitializer copy(CopyStyle style) { IASTInitializerClause[] args = null; if (fArguments != null) { - args= new IASTInitializerClause[fArguments.length]; - for (int i= 0; i < fArguments.length; i++) { - args[i]= fArguments[i].copy(); + args = new IASTInitializerClause[fArguments.length]; + for (int i = 0; i < fArguments.length; i++) { + args[i] = fArguments[i].copy(style); } } CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(args); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 82f859067b6..3a657c61047 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,8 +39,15 @@ public class CPPASTContinueStatement extends ASTNode implements IASTContinueStat } public CPPASTContinueStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTContinueStatement copy(CopyStyle style) { CPPASTContinueStatement copy = new CPPASTContinueStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 a831cd310e1..a87f638d44e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,12 +37,18 @@ public class CPPASTConversionName extends CPPASTNameBase implements ICPPASTConve } public CPPASTConversionName copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTConversionName copy(CopyStyle style) { CPPASTConversionName copy = new CPPASTConversionName(); - copy.setTypeId(typeId == null ? null : typeId.copy()); + copy.setTypeId(typeId == null ? null : typeId.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 58f23e33981..29941d0599a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,12 +34,19 @@ public class CPPASTDeclarationStatement extends ASTNode implements } public CPPASTDeclarationStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTDeclarationStatement copy(CopyStyle style) { CPPASTDeclarationStatement copy = new CPPASTDeclarationStatement(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 3c44dc15df0..46f458c35de 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,18 +62,25 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST } public CPPASTDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTDeclarator copy(CopyStyle style) { CPPASTDeclarator copy = new CPPASTDeclarator(); - copyBaseDeclarator(copy); + copyBaseDeclarator(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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()); + protected void copyBaseDeclarator(CPPASTDeclarator copy, CopyStyle style) { + copy.setName(name == null ? null : name.copy(style)); + copy.setInitializer(initializer == null ? null : initializer.copy(style)); + copy.setNestedDeclarator(nested == null ? null : nested.copy(style)); copy.isPackExpansion= isPackExpansion; for (IASTPointerOperator pointer : getPointerOperators()) - copy.addPointerOperator(pointer == null ? null : pointer.copy()); + copy.addPointerOperator(pointer == null ? null : pointer.copy(style)); copy.setOffsetAndLength(this); } 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 194c76d196f..70246ad58b7 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,9 +39,15 @@ public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatem } public CPPASTDefaultStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTDefaultStatement copy(CopyStyle style) { CPPASTDefaultStatement copy = new CPPASTDefaultStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 f40039879f2..d3919e89cd2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitName; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; - import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; @@ -46,13 +45,21 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr } public CPPASTDeleteExpression copy() { - CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null : operand.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTDeleteExpression copy(CopyStyle style) { + CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null + : operand.copy(style)); copy.isGlobal = isGlobal; copy.isVectored = isVectored; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 0d70da842f3..fb39ce06645 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,13 +36,20 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA } public CPPASTDoStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTDoStatement copy(CopyStyle style) { CPPASTDoStatement copy = new CPPASTDoStatement(); - copy.setBody(body == null ? null : body.copy()); - copy.setCondition(condition == null ? null : condition.copy()); + copy.setBody(body == null ? null : body.copy(style)); + copy.setCondition(condition == null ? null : condition.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 4bcb661b6ee..c914b5cae9e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,11 +40,19 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier } public CPPASTElaboratedTypeSpecifier copy() { - CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) { + CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null + ? null : name.copy(style)); copyBaseDeclSpec(copy); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java index 37bfb093d72..feab85df793 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,17 +46,22 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier } public CPPASTEnumerationSpecifier copy() { - CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, - fName == null ? null : fName.copy(), - fBaseType == null ? null : fBaseType.copy()); - copy.fIsOpaque= fIsOpaque; + return copy(CopyStyle.withoutLocations); + } + + public CPPASTEnumerationSpecifier copy(CopyStyle style) { + CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, fName == null + ? null : fName.copy(style), fBaseType == null ? null : fBaseType.copy(style)); + copy.fIsOpaque = fIsOpaque; for (IASTEnumerator enumerator : getEnumerators()) - copy.addEnumerator(enumerator == null ? null : enumerator.copy()); + copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); copyBaseDeclSpec(copy); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - public boolean startValueComputation() { if (fValuesComputed) 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 61f6a2245ea..0a0cda93d37 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,15 @@ public class CPPASTEnumerator extends ASTEnumerator { } public CPPASTEnumerator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTEnumerator copy(CopyStyle style) { CPPASTEnumerator copy = new CPPASTEnumerator(); - copyAbstractEnumerator(copy); + copyAbstractEnumerator(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java index 30ccf032322..7c14d0e8f7a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,9 +26,17 @@ public class CPPASTEqualsInitializer extends ASTEqualsInitializer { } public CPPASTEqualsInitializer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTEqualsInitializer copy(CopyStyle style) { IASTInitializerClause arg = getInitializerClause(); - CPPASTEqualsInitializer copy = new CPPASTEqualsInitializer(arg == null ? null : arg.copy()); + CPPASTEqualsInitializer copy = new CPPASTEqualsInitializer(arg == null ? null + : arg.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 dc303ac3a19..1042f1c79f4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,13 +36,20 @@ public class CPPASTExplicitTemplateInstantiation extends ASTNode implements } public CPPASTExplicitTemplateInstantiation copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTExplicitTemplateInstantiation copy(CopyStyle style) { CPPASTExplicitTemplateInstantiation copy = new CPPASTExplicitTemplateInstantiation(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setModifier(modifier); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 86450ab7e5d..07a6f167683 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,12 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeOrFunctionSet; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCat; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTVisitor; @@ -48,10 +53,17 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi private ICPPFunction[] overloads = null; public CPPASTExpressionList copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTExpressionList copy(CopyStyle style) { CPPASTExpressionList copy = new CPPASTExpressionList(); for(IASTExpression expr : getExpressions()) - copy.addExpression(expr == null ? null : expr.copy()); + copy.addExpression(expr == null ? null : expr.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 26244df1747..33089f6f1cc 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,9 +33,16 @@ public class CPPASTExpressionStatement extends ASTNode implements } public CPPASTExpressionStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTExpressionStatement copy(CopyStyle style) { CPPASTExpressionStatement copy = new CPPASTExpressionStatement(); - copy.setExpression(expression == null ? null : expression.copy()); + copy.setExpression(expression == null ? null : expression.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 b4a0ca750dc..f8735fea823 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,9 +40,17 @@ public class CPPASTFieldDeclarator extends CPPASTDeclarator implements @Override public CPPASTFieldDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTFieldDeclarator copy(CopyStyle style) { CPPASTFieldDeclarator copy = new CPPASTFieldDeclarator(); - copyBaseDeclarator(copy); - copy.setBitFieldSize(bitField == null ? null : bitField.copy()); + copyBaseDeclarator(copy, style); + copy.setBitFieldSize(bitField == null ? null : bitField.copy(style)); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 2202a950138..ebd4f0a2461 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,10 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; import java.util.ArrayList; import java.util.List; @@ -69,12 +72,19 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen } public CPPASTFieldReference copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTFieldReference copy(CopyStyle style) { CPPASTFieldReference copy = new CPPASTFieldReference(); - copy.setFieldName(name == null ? null : name.copy()); - copy.setFieldOwner(owner == null ? null : owner.copy()); + copy.setFieldName(name == null ? null : name.copy(style)); + copy.setFieldOwner(owner == null ? null : owner.copy(style)); copy.isTemplate = isTemplate; copy.isDeref = isDeref; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 4808608262f..20425af2a60 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -56,16 +56,24 @@ public class CPPASTForStatement extends ASTNode implements ICPPASTForStatement, } public CPPASTForStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTForStatement copy(CopyStyle style) { 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.setInitializerStatement(init == null ? null : init.copy(style)); + copy.setConditionDeclaration(condDeclaration == null ? null : condDeclaration.copy(style)); + copy.setConditionExpression(condition == null ? null : condition.copy(style)); + copy.setIterationExpression(iterationExpression == null ? null : iterationExpression + .copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 9bd73c413bb..5f484e3700a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; @@ -66,17 +70,24 @@ public class CPPASTFunctionCallExpression extends ASTNode implements } public CPPASTFunctionCallExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTFunctionCallExpression copy(CopyStyle style) { IASTInitializerClause[] args = null; if (fArguments.length > 0) { args= new IASTInitializerClause[fArguments.length]; for (int i = 0; i < fArguments.length; i++) { - args[i]= fArguments[i].copy(); + args[i] = fArguments[i].copy(style); } } CPPASTFunctionCallExpression copy = new CPPASTFunctionCallExpression(null, args); - copy.setFunctionNameExpression(functionName == null ? null : functionName.copy()); + copy.setFunctionNameExpression(functionName == null ? null : functionName.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 3a78876b859..dd68669d0dc 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,20 +51,28 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS @Override public CPPASTFunctionDeclarator copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTFunctionDeclarator copy(CopyStyle style) { CPPASTFunctionDeclarator copy = new CPPASTFunctionDeclarator(); - copyBaseDeclarator(copy); + copyBaseDeclarator(copy, style); copy.varArgs = varArgs; copy.pureVirtual = pureVirtual; copy.isVolatile = isVolatile; copy.isConst = isConst; - copy.isMutable= isMutable; - - for(IASTParameterDeclaration param : getParameters()) - copy.addParameterDeclaration(param == null ? null : param.copy()); - for(IASTTypeId typeId : getExceptionSpecification()) - copy.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy()); + copy.isMutable = isMutable; + + for (IASTParameterDeclaration param : getParameters()) + copy.addParameterDeclaration(param == null ? null : param.copy(style)); + for (IASTTypeId typeId : getExceptionSpecification()) + copy.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(style)); if (trailingReturnType != null) { - copy.setTrailingReturnType(trailingReturnType.copy()); + copy.setTrailingReturnType(trailingReturnType.copy(style)); + } + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); } return copy; } 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 c97f0d506dc..dab0f96ed7b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,23 +51,31 @@ public class CPPASTFunctionDefinition extends ASTNode } public CPPASTFunctionDefinition copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTFunctionDefinition copy(CopyStyle style) { CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition(); - copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); - + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); + if (declarator != null) { IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator); - outer = outer.copy(); - copy.setDeclarator((IASTFunctionDeclarator)ASTQueries.findTypeRelevantDeclarator(outer)); - } - - copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); - + outer = outer.copy(style); + copy.setDeclarator((IASTFunctionDeclarator) ASTQueries + .findTypeRelevantDeclarator(outer)); + } + + copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); + for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) - copy.addMemberInitializer(initializer == null ? null : initializer.copy()); - - copy.fDefaulted= fDefaulted; - copy.fDeleted= fDeleted; + copy.addMemberInitializer(initializer == null ? null : initializer.copy(style)); + + copy.fDefaulted = fDefaulted; + copy.fDeleted = fDeleted; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 46fef1fd2a8..9300b41cf31 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,21 +35,29 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme @Override public CPPASTFunctionWithTryBlock copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTFunctionWithTryBlock copy(CopyStyle style) { IASTDeclSpecifier declSpecifier = getDeclSpecifier(); - IASTFunctionDeclarator declarator = getDeclarator(); - IASTStatement bodyStatement = getBody(); - + 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.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); + copy.setDeclarator(declarator == null ? null : declarator.copy(style)); + copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); + + for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) + copy.addMemberInitializer(initializer == null ? null : initializer.copy(style)); + for (ICPPASTCatchHandler handler : getCatchHandlers()) + copy.addCatchHandler(handler == null ? null : handler.copy(style)); + copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 87d05d570b4..c94ba46e218 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,11 +31,18 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement { } public CPPASTGotoStatement copy() { - CPPASTGotoStatement copy = new CPPASTGotoStatement(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTGotoStatement copy(CopyStyle style) { + CPPASTGotoStatement copy = new CPPASTGotoStatement(name == null ? null : name.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 7cfa6145335..d4245b9903c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -64,8 +64,15 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP } public CPPASTIdExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTIdExpression copy(CopyStyle style) { CPPASTIdExpression copy = new CPPASTIdExpression(name == null ? null : name.copy()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 c7940c8138b..bc4a0e3adb6 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,15 +50,21 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA } public CPPASTIfStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTIfStatement copy(CopyStyle style) { 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.setConditionDeclaration(condDecl == null ? null : condDecl.copy(style)); + copy.setConditionExpression(condition == null ? null : condition.copy(style)); + copy.setThenClause(thenClause == null ? null : thenClause.copy(style)); + copy.setElseClause(elseClause == null ? null : elseClause.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTImplicitName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTImplicitName.java index c3b5d23df4e..691e88ba554 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTImplicitName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTImplicitName.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,6 +43,11 @@ public class CPPASTImplicitName extends CPPASTName implements IASTImplicitName { throw new UnsupportedOperationException(); } + @Override + public CPPASTImplicitName copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public boolean isAlternate() { return alternate; } 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 716501b041a..04c94361966 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,10 +27,18 @@ public class CPPASTInitializerExpression extends CPPASTEqualsInitializer impleme @Override public CPPASTInitializerExpression copy() { - CPPASTInitializerExpression copy= new CPPASTInitializerExpression(); - IASTInitializerClause init= getInitializerClause(); - copy.setInitializerClause(init == null ? null : init.copy()); + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTInitializerExpression copy(CopyStyle style) { + CPPASTInitializerExpression copy = new CPPASTInitializerExpression(); + IASTInitializerClause init = getInitializerClause(); + copy.setInitializerClause(init == null ? null : init.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } 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 39d86f66c81..52b420d917d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,15 +33,22 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer private boolean fIsPackExpansion; public CPPASTInitializerList copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTInitializerList copy(CopyStyle style) { CPPASTInitializerList copy = new CPPASTInitializerList(); for (IASTInitializerClause initializer : getClauses()) - copy.addClause(initializer == null ? null : initializer.copy()); + copy.addClause(initializer == null ? null : initializer.copy(style)); copy.setOffsetAndLength(this); copy.actualSize = getSize(); copy.fIsPackExpansion = fIsPackExpansion; + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public int getSize() { return actualSize; } 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 f5b9a22b03b..8a520b62496 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,10 +37,17 @@ public class CPPASTLabelStatement extends ASTNode implements } public CPPASTLabelStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTLabelStatement copy(CopyStyle style) { CPPASTLabelStatement copy = new CPPASTLabelStatement(); - copy.setName(name == null ? null : name.copy()); - copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy()); + copy.setName(name == null ? null : name.copy(style)); + copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java index 8146049ed45..5da8b25b7b5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLambdaExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; - import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; @@ -45,23 +44,30 @@ public class CPPASTLambdaExpression extends ASTNode implements ICPPASTLambdaExpr * @see org.eclipse.cdt.core.dom.ast.IASTExpression#copy() */ public CPPASTLambdaExpression copy() { - CPPASTLambdaExpression result= new CPPASTLambdaExpression(); - result.fCaptureDefault= fCaptureDefault; + return copy(CopyStyle.withoutLocations); + } + + public CPPASTLambdaExpression copy(CopyStyle style) { + CPPASTLambdaExpression result = new CPPASTLambdaExpression(); + result.fCaptureDefault = fCaptureDefault; if (fCaptures != null) { for (ICPPASTCapture capture : fCaptures) { if (capture != null) { - result.addCapture(capture.copy()); + result.addCapture(capture.copy(style)); } } } if (fDeclarator != null) { - result.setDeclarator(fDeclarator.copy()); + result.setDeclarator(fDeclarator.copy(style)); } if (fBody != null) { - result.setBody(fBody.copy()); + result.setBody(fBody.copy(style)); } - + result.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + result.setCopyLocation(this); + } return result; } 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 4a7bab61d52..6ec8a895c92 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,13 +38,19 @@ public class CPPASTLinkageSpecification extends ASTNode implements } public CPPASTLinkageSpecification copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTLinkageSpecification copy(CopyStyle style) { CPPASTLinkageSpecification copy = new CPPASTLinkageSpecification(fLiteral); - for(IASTDeclaration declaration : getDeclarations()) - copy.addDeclaration(declaration == null ? null : declaration.copy()); + for (IASTDeclaration declaration : getDeclarations()) + copy.addDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - public String getLiteral() { return fLiteral; 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 bcc05fa633f..c496bb8a71a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,11 +45,19 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx } public CPPASTLiteralExpression copy() { - CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, value == null ? null : value.clone()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTLiteralExpression copy(CopyStyle style) { + CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, value == null ? null + : value.clone()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 75474bfcb35..9a4d26cb47e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,8 +46,15 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte } public CPPASTName copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTName copy(CopyStyle style) { CPPASTName copy = new CPPASTName(name == null ? null : name.clone()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 d7714baec74..deeaa049047 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,9 +41,17 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements } public CPPASTNamedTypeSpecifier copy() { - CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTNamedTypeSpecifier copy(CopyStyle style) { + CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null + : name.copy(style)); copyBaseDeclSpec(copy); copy.typename = typename; + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 a83375723e7..f4d3511452f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,10 +34,17 @@ public class CPPASTNamespaceAlias extends ASTNode implements ICPPASTNamespaceAli } public CPPASTNamespaceAlias copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTNamespaceAlias copy(CopyStyle style) { CPPASTNamespaceAlias copy = new CPPASTNamespaceAlias(); - copy.setAlias(alias == null ? null : alias.copy()); - copy.setMappingName(qualifiedName == null ? null : qualifiedName.copy()); + copy.setAlias(alias == null ? null : alias.copy(style)); + copy.setMappingName(qualifiedName == null ? null : qualifiedName.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 a59343dc62e..af185a8ea65 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,14 +43,22 @@ public class CPPASTNamespaceDefinition extends ASTNode implements } public CPPASTNamespaceDefinition copy() { - CPPASTNamespaceDefinition copy = new CPPASTNamespaceDefinition(fName == null ? null : fName.copy()); - copy.fIsInline= fIsInline; - for(IASTDeclaration declaration : getDeclarations()) - copy.addDeclaration(declaration == null ? null : declaration.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTNamespaceDefinition copy(CopyStyle style) { + CPPASTNamespaceDefinition copy = new CPPASTNamespaceDefinition(fName == null ? null + : fName.copy(style)); + copy.fIsInline = fIsInline; + for (IASTDeclaration declaration : getDeclarations()) + copy.addDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public IASTName getName() { return fName; } 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 6002248ed02..2e143721520 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,19 +60,26 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression } public CPPASTNewExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTNewExpression copy(CopyStyle style) { CPPASTNewExpression copy = new CPPASTNewExpression(); copy.setIsGlobal(isGlobal); copy.setIsNewTypeId(isNewTypeId); if (placement != null) { IASTInitializerClause[] plcmt = new IASTInitializerClause[placement.length]; - for (int i= 0; i < placement.length; i++) { - plcmt[i]= placement[i].copy(); + for (int i = 0; i < placement.length; i++) { + plcmt[i] = placement[i].copy(style); } copy.setPlacementArguments(plcmt); } - copy.setTypeId(typeId == null ? null : typeId.copy()); - copy.setInitializer(initializer == null ? null : initializer.copy()); + copy.setTypeId(typeId == null ? null : typeId.copy(style)); + copy.setInitializer(initializer == null ? null : initializer.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 fb8ca54c012..d22cb9f72cb 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,8 +39,15 @@ public class CPPASTNullStatement extends ASTNode implements IASTNullStatement { } public CPPASTNullStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTNullStatement copy(CopyStyle style) { CPPASTNullStatement copy = new CPPASTNullStatement(); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 aa0b5757a57..0c59adb83fd 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,9 +30,17 @@ public class CPPASTOperatorName extends CPPASTName implements ICPPASTOperatorNam @Override public CPPASTOperatorName copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTOperatorName copy(CopyStyle style) { char[] name = toCharArray(); CPPASTOperatorName copy = new CPPASTOperatorName(name == null ? null : name.clone()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java index cadd07aec6c..3907dd7ccd4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,8 +46,15 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac } public CPPASTPackExpansionExpression copy() { - CPPASTPackExpansionExpression copy = new CPPASTPackExpansionExpression(fPattern.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTPackExpansionExpression copy(CopyStyle style) { + CPPASTPackExpansionExpression copy = new CPPASTPackExpansionExpression(fPattern.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 a1fb49a3ae8..7fa03b047a4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,10 +42,17 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame } public CPPASTParameterDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTParameterDeclaration copy(CopyStyle style) { CPPASTParameterDeclaration copy = new CPPASTParameterDeclaration(); - copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy()); - copy.setDeclarator(fDeclarator == null ? null : fDeclarator.copy()); + copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy(style)); + copy.setDeclarator(fDeclarator == null ? null : fDeclarator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 7b3ed009b83..ffd5f7d806e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,14 +28,21 @@ public class CPPASTPointer extends ASTNode implements IASTPointer { } public CPPASTPointer copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTPointer copy(CopyStyle style) { CPPASTPointer copy = new CPPASTPointer(); copy.isConst = isConst; copy.isVolatile = isVolatile; copy.isRestrict = isRestrict; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 8b4b82e0258..adbd9bc2d7e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,14 +28,22 @@ public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPoint @Override public CPPASTPointerToMember copy() { - CPPASTPointerToMember copy = new CPPASTPointerToMember(n == null ? null : n.copy()); + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTPointerToMember copy(CopyStyle style) { + CPPASTPointerToMember copy = new CPPASTPointerToMember(n == null ? null : n.copy(style)); copy.setConst(isConst()); copy.setVolatile(isVolatile()); copy.setRestrict(isRestrict()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 eb0b39db11e..7852ed3aec5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,9 +26,17 @@ public class CPPASTProblem extends ASTProblem { @Override public CPPASTProblem copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTProblem copy(CopyStyle style) { char[] arg = getArgument(); CPPASTProblem problem = new CPPASTProblem(getID(), arg == null ? null : arg.clone(), isError()); problem.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + problem.setCopyLocation(this); + } return problem; } 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 9390052613f..827d0254a6f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,12 +29,18 @@ public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements IAST } public CPPASTProblemDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTProblemDeclaration copy(CopyStyle style) { CPPASTProblemDeclaration copy = new CPPASTProblemDeclaration(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 441beb859f0..ed15e0d26aa 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,11 +29,18 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTP } public CPPASTProblemExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTProblemExpression copy(CopyStyle style) { CPPASTProblemExpression copy = new CPPASTProblemExpression(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 76254c51c96..40ceefd5ee1 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,8 +31,8 @@ abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder { setProblem(problem); } - protected void copyBaseProblem(CPPASTProblemOwner copy) { - copy.setProblem(problem == null ? null : problem.copy()); + protected void copyBaseProblem(CPPASTProblemOwner copy, CopyStyle style) { + copy.setProblem(problem == null ? null : problem.copy(style)); copy.setOffsetAndLength(this); } 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 718de9bbe44..aa3f432a038 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,15 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTPr } public CPPASTProblemStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTProblemStatement copy(CopyStyle style) { CPPASTProblemStatement copy = new CPPASTProblemStatement(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 4b03a299175..1d4f2dd61b3 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,11 +29,18 @@ public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProbl } public CPPASTProblemTypeId copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTProblemTypeId copy(CopyStyle style) { CPPASTProblemTypeId copy = new CPPASTProblemTypeId(); - copyBaseProblem(copy); + copyBaseProblem(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + @Override public final boolean accept (ASTVisitor action) { if (action.shouldVisitTypeIds) { 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 01c44a1b427..b47c9ed587d 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 @@ -64,14 +64,21 @@ public class CPPASTQualifiedName extends CPPASTNameBase } public CPPASTQualifiedName copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTQualifiedName copy(CopyStyle style) { CPPASTQualifiedName copy = new CPPASTQualifiedName(); - for(IASTName name : getNames()) - copy.addName(name == null ? null : name.copy()); + for (IASTName name : getNames()) + copy.addName(name == null ? null : name.copy(style)); copy.setFullyQualified(isFullyQualified); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTRangeBasedForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java index cbfc8850406..49c84b0bbfa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,14 +33,21 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang } public CPPASTRangeBasedForStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTRangeBasedForStatement copy(CopyStyle style) { CPPASTRangeBasedForStatement copy = new CPPASTRangeBasedForStatement(); - copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy()); - copy.setInitializerClause(fInitClause == null ? null : fInitClause.copy()); - copy.setBody(fBody == null ? null : fBody.copy()); + copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy(style)); + copy.setInitializerClause(fInitClause == null ? null : fInitClause.copy(style)); + copy.setBody(fBody == null ? null : fBody.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public IASTDeclaration getDeclaration() { return fDeclaration; } 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 3eb09471a76..3820b979e29 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,11 +31,18 @@ public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReference } public CPPASTReferenceOperator copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTReferenceOperator copy(CopyStyle style) { CPPASTReferenceOperator copy = new CPPASTReferenceOperator(fIsRValue); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + @Override public boolean accept(ASTVisitor action) { if (action.shouldVisitPointerOperators) { 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 36bea044360..2e959841e14 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,11 +31,19 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen } public CPPASTReturnStatement copy() { - CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null : retValue.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTReturnStatement copy(CopyStyle style) { + CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null + : retValue.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public IASTInitializerClause getReturnArgument() { 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 33586a33689..3ceeed83ac9 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,12 +31,19 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement private IASTExpression fDeclTypeExpression; public CPPASTSimpleDeclSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTSimpleDeclSpecifier copy(CopyStyle style) { CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy); + copySimpleDeclSpec(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - - protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other) { + + protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other, CopyStyle style) { copyBaseDeclSpec(other); other.type = type; other.isSigned = isSigned; @@ -47,7 +54,7 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement other.isComplex= isComplex; other.isImaginary= isImaginary; if (fDeclTypeExpression != null) { - other.setDeclTypeExpression(fDeclTypeExpression.copy()); + other.setDeclTypeExpression(fDeclTypeExpression.copy(style)); } } 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 d8eab881ccb..0c267bf370b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,14 +33,21 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar } public CPPASTSimpleDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTSimpleDeclaration copy(CopyStyle style) { CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration(); - copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); + copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); for (IASTDeclarator declarator : getDeclarators()) - copy.addDeclarator(declarator == null ? null : declarator.copy()); + copy.addDeclarator(declarator == null ? null : declarator.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 6d0750e5ab3..7b900ae9bea 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; - import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; @@ -42,13 +41,20 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements } public CPPASTSimpleTypeConstructorExpression copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTSimpleTypeConstructorExpression copy(CopyStyle style) { CPPASTSimpleTypeConstructorExpression copy = new CPPASTSimpleTypeConstructorExpression(); - copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy()); - copy.setInitializer(fInitializer == null ? null : fInitializer.copy()); + copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy(style)); + copy.setInitializer(fInitializer == null ? null : fInitializer.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public ICPPASTDeclSpecifier getDeclSpecifier() { return fDeclSpec; } 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 2b8499140da..f500530f862 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,16 +37,22 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements ICPPAS } public CPPASTSimpleTypeTemplateParameter copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTSimpleTypeTemplateParameter copy(CopyStyle style) { CPPASTSimpleTypeTemplateParameter copy = new CPPASTSimpleTypeTemplateParameter(); copy.fUsesKeywordClass = fUsesKeywordClass; - copy.fIsParameterPack= fIsParameterPack; - copy.setName(fName == null ? null : fName.copy()); - copy.setDefaultType(fTypeId == null ? null : fTypeId.copy()); + copy.fIsParameterPack = fIsParameterPack; + copy.setName(fName == null ? null : fName.copy(style)); + copy.setDefaultType(fTypeId == null ? null : fTypeId.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - public boolean isParameterPack() { return fIsParameterPack; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTStaticAssertionDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTStaticAssertionDeclaration.java index a49bacda4ef..6f2a8d8f461 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTStaticAssertionDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTStaticAssertionDeclaration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,13 +46,21 @@ public class CPPASTStaticAssertionDeclaration extends ASTNode implements ICPPAST public CPPASTStaticAssertionDeclaration copy() { - final IASTExpression condCopy = fCondition == null ? null : fCondition.copy(); - final ICPPASTLiteralExpression msgCopy = fMessage == null ? null : fMessage.copy(); - CPPASTStaticAssertionDeclaration copy = new CPPASTStaticAssertionDeclaration(condCopy, msgCopy); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTStaticAssertionDeclaration copy(CopyStyle style) { + final IASTExpression condCopy = fCondition == null ? null : fCondition.copy(style); + final ICPPASTLiteralExpression msgCopy = fMessage == null ? null : fMessage.copy(style); + CPPASTStaticAssertionDeclaration copy = new CPPASTStaticAssertionDeclaration(condCopy, + msgCopy); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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/CPPASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java index 3bbc43e61d3..df3cb525348 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,11 +47,20 @@ public class CPPASTSwitchStatement extends ASTNode implements } public CPPASTSwitchStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTSwitchStatement copy(CopyStyle style) { CPPASTSwitchStatement copy = new CPPASTSwitchStatement(); - copy.setControllerDeclaration(controllerDeclaration == null ? null : controllerDeclaration.copy()); - copy.setControllerExpression(controllerExpression == null ? null : controllerExpression.copy()); - copy.setBody(body == null ? null : body.copy()); + copy.setControllerDeclaration(controllerDeclaration == null ? null : controllerDeclaration + .copy(style)); + copy.setControllerExpression(controllerExpression == null ? null : controllerExpression + .copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 a6ac9a21bdf..11915db84f6 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,15 +43,22 @@ public class CPPASTTemplateDeclaration extends ASTNode implements } public CPPASTTemplateDeclaration copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTemplateDeclaration copy(CopyStyle style) { CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.exported = exported; - for (ICPPASTTemplateParameter param : getTemplateParameters()) - copy.addTemplateParameter(param == null ? null : param.copy()); + for (ICPPASTTemplateParameter param : getTemplateParameters()) + copy.addTemplateParameter(param == null ? null : param.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 39a045765fa..a6b05cc27ef 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,13 +47,21 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI } public CPPASTTemplateId copy() { - CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ? null : templateName.copy()); - for(IASTNode arg : getTemplateArguments()) - copy.internalAddTemplateArgument(arg == null ? null : arg.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTemplateId copy(CopyStyle style) { + CPPASTTemplateId copy = new CPPASTTemplateId(templateName == null ? null + : templateName.copy(style)); + for (IASTNode arg : getTemplateArguments()) + copy.internalAddTemplateArgument(arg == null ? null : arg.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public char[] getSimpleID() { return templateName.getSimpleID(); } 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 ee767bca20f..84501177ac4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,9 +41,16 @@ public class CPPASTTemplateSpecialization extends ASTNode implements } public CPPASTTemplateSpecialization copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTemplateSpecialization copy(CopyStyle style) { CPPASTTemplateSpecialization copy = new CPPASTTemplateSpecialization(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 61108f715b3..d68d7a8cfe5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,13 +41,20 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements } public CPPASTTemplatedTypeTemplateParameter copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTemplatedTypeTemplateParameter copy(CopyStyle style) { CPPASTTemplatedTypeTemplateParameter copy = new CPPASTTemplatedTypeTemplateParameter(); - copy.setName(fName == null ? null : fName.copy()); - copy.setDefaultValue(fDefaultValue == null ? null : fDefaultValue.copy()); - copy.fIsParameterPack= fIsParameterPack; - for(ICPPASTTemplateParameter param : getTemplateParameters()) - copy.addTemplateParameter(param == null ? null : param.copy()); + copy.setName(fName == null ? null : fName.copy(style)); + copy.setDefaultValue(fDefaultValue == null ? null : fDefaultValue.copy(style)); + copy.fIsParameterPack = fIsParameterPack; + for (ICPPASTTemplateParameter param : getTemplateParameters()) + copy.addTemplateParameter(param == null ? null : param.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 3476a861bce..dca3ec00c5e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,11 +46,18 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST } public CPPASTTranslationUnit copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTranslationUnit copy(CopyStyle style) { CPPASTTranslationUnit copy = new CPPASTTranslationUnit(); - copyAbstractTU(copy); + copyAbstractTU(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } 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 6db67c78c60..b51237f549c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,13 +34,21 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS } public CPPASTTryBlockStatement copy() { - CPPASTTryBlockStatement copy = new CPPASTTryBlockStatement(tryBody == null ? null : tryBody.copy()); - for(ICPPASTCatchHandler handler : getCatchHandlers()) - copy.addCatchHandler(handler == null ? null : handler.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTryBlockStatement copy(CopyStyle style) { + CPPASTTryBlockStatement copy = new CPPASTTryBlockStatement(tryBody == null ? null + : tryBody.copy(style)); + for (ICPPASTCatchHandler handler : getCatchHandlers()) + copy.addCatchHandler(handler == null ? null : handler.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 9bd8015d4da..df257e248c2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,11 +36,18 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId { } public CPPASTTypeId copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTypeId copy(CopyStyle style) { CPPASTTypeId copy = new CPPASTTypeId(); - copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); - copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy()); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style)); + copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy(style)); copy.setOffsetAndLength(this); - copy.isPackExpansion= isPackExpansion; + copy.isPackExpansion = isPackExpansion; + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } 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 664461a36a8..051ceebb50b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,11 +35,19 @@ public class CPPASTTypeIdExpression extends ASTNode implements ICPPASTTypeIdExpr } public CPPASTTypeIdExpression copy() { - CPPASTTypeIdExpression copy = new CPPASTTypeIdExpression(op, typeId == null ? null : typeId.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTTypeIdExpression copy(CopyStyle style) { + CPPASTTypeIdExpression copy = new CPPASTTypeIdExpression(op, typeId == null ? null + : typeId.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTTypeIdInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdInitializerExpression.java index a68ba91ef0b..e54ddbc4b10 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypeIdInitializerExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,11 +32,15 @@ public class CPPASTTypeIdInitializerExpression extends ASTTypeIdInitializerExpre } public IASTTypeIdInitializerExpression copy() { - CPPASTTypeIdInitializerExpression expr= new CPPASTTypeIdInitializerExpression(); - initializeCopy(expr); - return expr; + return copy(CopyStyle.withoutLocations); } + public IASTTypeIdInitializerExpression copy(CopyStyle style) { + CPPASTTypeIdInitializerExpression expr = new CPPASTTypeIdInitializerExpression(); + initializeCopy(expr, style); + return expr; + } + public IType getExpressionType() { final IASTTypeId typeId = getTypeId(); return prvalueType(CPPVisitor.createType(typeId.getAbstractDeclarator())); 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 39030d0c3b0..4046ed7eb19 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,16 +32,24 @@ public class CPPASTTypenameExpression extends CPPASTSimpleTypeConstructorExpress @Override public CPPASTTypenameExpression copy() { - super.copy(); + return copy(CopyStyle.withoutLocations); + } + + @Override + public CPPASTTypenameExpression copy(CopyStyle style) { + super.copy(style); CPPASTTypenameExpression copy = new CPPASTTypenameExpression(); ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); IASTInitializer init = getInitializer(); - copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy()); - copy.setInitializer(init == null ? null : init.copy()); + copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style)); + copy.setInitializer(init == null ? null : init.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public void setName(IASTName name) { CPPASTNamedTypeSpecifier spec= new CPPASTNamedTypeSpecifier(name); spec.setOffsetAndLength(this); 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 1a70e2925c6..84bec4e2177 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying masterials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; @@ -70,11 +73,19 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres } public CPPASTUnaryExpression copy() { - CPPASTUnaryExpression copy = new CPPASTUnaryExpression(op, operand == null ? null : operand.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTUnaryExpression copy(CopyStyle style) { + CPPASTUnaryExpression copy = new CPPASTUnaryExpression(op, operand == null ? null + : operand.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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/CPPASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java index ec1a638d73e..8a81878f2b4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,12 +39,20 @@ public class CPPASTUsingDeclaration extends ASTNode } public CPPASTUsingDeclaration copy() { - CPPASTUsingDeclaration copy = new CPPASTUsingDeclaration(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTUsingDeclaration copy(CopyStyle style) { + CPPASTUsingDeclaration copy = new CPPASTUsingDeclaration(name == null ? null + : name.copy(style)); copy.typeName = typeName; copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 3335e94cfe7..0ef0d20e50d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -37,11 +37,18 @@ public class CPPASTUsingDirective extends ASTNode implements } public CPPASTUsingDirective copy() { - CPPASTUsingDirective copy = new CPPASTUsingDirective(name == null ? null : name.copy()); + return copy(CopyStyle.withoutLocations); + } + + public CPPASTUsingDirective copy(CopyStyle style) { + CPPASTUsingDirective copy = new CPPASTUsingDirective(name == null ? null : name.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 8e09b0ec70d..de7af9f7dbe 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,11 +30,18 @@ public class CPPASTVisibilityLabel extends ASTNode implements ICPPASTVisibilityL } public CPPASTVisibilityLabel copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTVisibilityLabel copy(CopyStyle style) { CPPASTVisibilityLabel copy = new CPPASTVisibilityLabel(visibility); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 adf4de84109..b28b6fc5169 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,14 +45,21 @@ public class CPPASTWhileStatement extends ASTNode } public CPPASTWhileStatement copy() { + return copy(CopyStyle.withoutLocations); + } + + public CPPASTWhileStatement copy(CopyStyle style) { 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.setConditionDeclaration(condition2 == null ? null : condition2.copy(style)); + copy.setCondition(condition == null ? null : condition.copy(style)); + copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(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 306defd63b3..b448edc6823 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,11 +31,19 @@ public class GPPASTExplicitTemplateInstantiation extends @Override public GPPASTExplicitTemplateInstantiation copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public GPPASTExplicitTemplateInstantiation copy(CopyStyle style) { GPPASTExplicitTemplateInstantiation copy = new GPPASTExplicitTemplateInstantiation(); IASTDeclaration declaration = getDeclaration(); - copy.setDeclaration(declaration == null ? null : declaration.copy()); + copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setModifier(getModifier()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } 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 5da19619047..cedafe070b5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,11 +20,19 @@ public class GPPASTPointer extends CPPASTPointer implements IGPPASTPointer { @Override public GPPASTPointer copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public GPPASTPointer copy(CopyStyle style) { GPPASTPointer copy = new GPPASTPointer(); copy.setConst(isConst()); copy.setVolatile(isVolatile()); copy.setRestrict(isRestrict()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } 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 c5abacbf81a..3996c644e1d 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,12 +30,21 @@ public class GPPASTPointerToMember extends CPPASTPointerToMember implements @Override public GPPASTPointerToMember copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public GPPASTPointerToMember copy(CopyStyle style) { IASTName name = getName(); - GPPASTPointerToMember copy = new GPPASTPointerToMember(name == null ? null : name.copy()); + GPPASTPointerToMember copy = new GPPASTPointerToMember(name == null ? null + : name.copy(style)); copy.setConst(isConst()); copy.setVolatile(isVolatile()); copy.setRestrict(isRestrict()); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } } 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 5e458cdfe8e..d37ea4bc93e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,12 +31,19 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier impleme @Override public GPPASTSimpleDeclSpecifier copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public GPPASTSimpleDeclSpecifier copy(CopyStyle style) { GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy); + copySimpleDeclSpec(copy, style); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - public void setTypeofExpression(IASTExpression typeofExpression) { setDeclTypeExpression(typeofExpression); } 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 8da53a7b733..638108f78a5 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -104,6 +104,10 @@ public class ASTLiteralNode implements IASTNode { throw new UnsupportedOperationException(); } + public IASTNode copy(CopyStyle style) { + throw new UnsupportedOperationException(); + } + public boolean isActive() { return true; } 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 39f2dd0a956..a9cfdeee41b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,13 +43,20 @@ public class ContainerNode extends ASTNode { } public ContainerNode copy() { + return copy(CopyStyle.withoutLocations); + } + + public ContainerNode copy(CopyStyle style) { ContainerNode copy = new ContainerNode(); - for(IASTNode node : getNodes()) - copy.addNode(node == null ? null : node.copy()); + for (IASTNode node : getNodes()) + copy.addNode(node == null ? null : node.copy(style)); copy.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + copy.setCopyLocation(this); + } return copy; } - + public void addNode(IASTNode node) { nodes.add(node); if(node.getParent() == null) { |