ASTNode clone0(AST target) { ForStatement result = new ForStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.initializers().addAll(ASTNode.copySubtrees(target, initializers())); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); result.updaters().addAll(ASTNode.copySubtrees(target, updaters())); result.setBody( (Statement) ASTNode.copySubtree(target, getBody())); return result; }
private void copyPackageDeclarationToDestination(IPackageDeclaration declaration, ASTRewrite targetRewrite, CompilationUnit sourceCuNode, CompilationUnit destinationCuNode) throws JavaModelException { if (destinationCuNode.getPackage() != null) { return; } PackageDeclaration sourceNode= ASTNodeSearchUtil.getPackageDeclarationNode(declaration, sourceCuNode); PackageDeclaration copiedNode= (PackageDeclaration) ASTNode.copySubtree(targetRewrite.getAST(), sourceNode); targetRewrite.set(destinationCuNode, CompilationUnit.PACKAGE_PROPERTY, copiedNode, null); }
ASTNode clone0(AST target) { EnumConstantDeclaration result = new EnumConstantDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); result.setName((SimpleName) getName().clone(target)); result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); result.setAnonymousClassDeclaration( (AnonymousClassDeclaration) ASTNode.copySubtree(target, getAnonymousClassDeclaration())); return result; }
@Override ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
@Override ASTNode clone0(AST target) { LambdaExpression result = new LambdaExpression(target); result.setSourceRange(getStartPosition(), getLength()); result.setParentheses(hasParentheses()); result.parameters().addAll(ASTNode.copySubtrees(target, parameters())); result.setBody(ASTNode.copySubtree(target, getBody())); return result; }
@Override ASTNode clone0(AST target) { SuperFieldAccess result = new SuperFieldAccess(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) ASTNode.copySubtree(target, getName())); result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); return result; }
@Override ASTNode clone0(AST target) { ExpressionMethodReference result = new ExpressionMethodReference(target); result.setSourceRange(getStartPosition(), getLength()); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); result.setName((SimpleName) getName().clone(target)); return result; }
public TypeImpl(final O origin, final Type<O> parent, final String type) { init(origin); this.parent = parent; String stub = "public class Stub { private " + type + " getType(){return null;} }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<MethodSource<JavaClassSource>> methods = temp.getMethods(); MethodDeclaration newMethod = (MethodDeclaration) methods.get(0).getInternal(); org.eclipse.jdt.core.dom.Type subtree = (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(cu.getAST(), newMethod.getReturnType2()); this.type = subtree; }
@Override ASTNode clone0(AST target) { ArrayCreation result = new ArrayCreation(target); result.setSourceRange(getStartPosition(), getLength()); result.setType((ArrayType) getType().clone(target)); result.dimensions().addAll(ASTNode.copySubtrees(target, dimensions())); result.setInitializer( (ArrayInitializer) ASTNode.copySubtree(target, getInitializer())); return result; }
@Override ASTNode clone0(AST target) { AssertStatement result = new AssertStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); result.setMessage( (Expression) ASTNode.copySubtree(target, getMessage())); return result; }
@Override ASTNode clone0(AST target) { PackageDeclaration result = new PackageDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); result.annotations().addAll(ASTNode.copySubtrees(target, annotations())); } result.setName((Name) getName().clone(target)); return result; }
@Override ASTNode clone0(AST target) { ThisExpression result = new ThisExpression(target); result.setSourceRange(getStartPosition(), getLength()); result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); return result; }
ASTNode clone0(AST target) { ExpressionMethodReference result = new ExpressionMethodReference(target); result.setSourceRange(getStartPosition(), getLength()); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); result.setName((SimpleName) getName().clone(target)); return result; }
@Override ASTNode clone0(AST target) { ContinueStatement result = new ContinueStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setLabel((SimpleName) ASTNode.copySubtree(target, getLabel())); return result; }
private VariableDeclarationStatement createDeclaration(IVariableBinding binding, Expression intilizer) { VariableDeclaration original = ASTNodes.findVariableDeclaration(binding, fAnalyzer.getEnclosingBodyDeclaration()); VariableDeclarationFragment fragment = fAST.newVariableDeclarationFragment(); fragment.setName((SimpleName) ASTNode.copySubtree(fAST, original.getName())); fragment.setInitializer(intilizer); VariableDeclarationStatement result = fAST.newVariableDeclarationStatement(fragment); result.modifiers().addAll(ASTNode.copySubtrees(fAST, ASTNodes.getModifiers(original))); result.setType(ASTNodeFactory.newType(fAST, original, fImportRewriter, new ContextSensitiveImportRewriteContext(original, fImportRewriter))); return result; }
@Override ASTNode clone0(AST target) { ReturnStatement result = new ReturnStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); return result; }
private void copyImportToDestination(IImportDeclaration declaration, ASTRewrite targetRewrite, CompilationUnit sourceCuNode, CompilationUnit destinationCuNode) throws JavaModelException { ImportDeclaration sourceNode= ASTNodeSearchUtil.getImportDeclarationNode(declaration, sourceCuNode); ImportDeclaration copiedNode= (ImportDeclaration) ASTNode.copySubtree(targetRewrite.getAST(), sourceNode); ListRewrite listRewrite= targetRewrite.getListRewrite(destinationCuNode, CompilationUnit.IMPORTS_PROPERTY); if (getJavaElementDestination() instanceof IImportDeclaration) { ImportDeclaration destinationNode= ASTNodeSearchUtil.getImportDeclarationNode((IImportDeclaration) getJavaElementDestination(), destinationCuNode); insertRelative(copiedNode, destinationNode, listRewrite); } else { //dropped on container, we could be better here listRewrite.insertLast(copiedNode, null); } }
@Override ASTNode clone0(AST target) { EnhancedForStatement result = new EnhancedForStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setParameter((SingleVariableDeclaration) getParameter().clone(target)); result.setExpression((Expression) getExpression().clone(target)); result.setBody( (Statement) ASTNode.copySubtree(target, getBody())); return result; }
@Override ASTNode clone0(AST target) { IfStatement result = new IfStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setExpression((Expression) getExpression().clone(target)); result.setThenStatement( (Statement) getThenStatement().clone(target)); result.setElseStatement( (Statement) ASTNode.copySubtree(target, getElseStatement())); return result; }
ASTNode clone0(AST target) { IfStatement result = new IfStatement(target); result.setSourceRange(getStartPosition(), getLength()); result.copyLeadingComment(this); result.setExpression((Expression) getExpression().clone(target)); result.setThenStatement( (Statement) getThenStatement().clone(target)); result.setElseStatement( (Statement) ASTNode.copySubtree(target, getElseStatement())); return result; }