/** * If the given <code>node</code> has already been rewritten, undo that rewrite and return the * replacement version of the node. Otherwise, return the result of * {@link ASTRewrite#createCopyTarget(ASTNode)}. * * @param rewrite ASTRewrite for the given node * @param node the node to get the replacement or to create a copy placeholder for * @param group the edit group which collects the corresponding text edits, or <code>null</code> * if ungrouped * @return the replacement node if the given <code>node</code> has already been rewritten or the * new copy placeholder node */ public static ASTNode getCopyOrReplacement(ASTRewrite rewrite, ASTNode node, TextEditGroup group) { ASTNode rewrittenNode= (ASTNode) rewrite.get(node.getParent(), node.getLocationInParent()); if (rewrittenNode != node) { // Undo previous rewrite to avoid the problem that the same node would be inserted in two places: rewrite.replace(rewrittenNode, node, group); return rewrittenNode; } return rewrite.createCopyTarget(node); }
ctorCall= (ClassInstanceCreation)ctorCallParentListRewrite.getRewrittenList().get(index); } else { ctorCall= (ClassInstanceCreation)unitRewriter.get(ctorCallParent, ctorCallLocation);
VariableDeclarationFragment fragment= (VariableDeclarationFragment) iter.next(); Expression initializer= fragment.getInitializer(); Expression replacement= (Expression) astRewrite.get(fragment, VariableDeclarationFragment.INITIALIZER_PROPERTY); if (replacement == initializer) { replacement= (Expression) astRewrite.createMoveTarget(initializer);
Type oldType = (Type) rewrite.get(varDecl, VariableDeclarationStatement.TYPE_PROPERTY); rewrite.set(varDecl, VariableDeclarationStatement.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null); Type oldType = (Type) rewrite.get(varDecl, VariableDeclarationExpression.TYPE_PROPERTY); rewrite.set(varDecl, VariableDeclarationExpression.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null); Type oldType = (Type) rewrite.get(variableDeclaration, SingleVariableDeclaration.TYPE_PROPERTY); rewrite.set(variableDeclaration, SingleVariableDeclaration.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, SingleVariableDeclaration.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null);
ctorCall= (ClassInstanceCreation)ctorCallParentListRewrite.getRewrittenList().get(index); } else { ctorCall= (ClassInstanceCreation)unitRewriter.get(ctorCallParent, ctorCallLocation);
if (enclosingLambda != null && selectedNode.getLocationInParent() == LambdaExpression.BODY_PROPERTY && enclosingLambda.resolveMethodBinding() != null) { QuickAssistProcessor.changeLambdaBodyToBlock(enclosingLambda, getAST(), fRewriter); Block blockBody = (Block) fRewriter.get(enclosingLambda, LambdaExpression.BODY_PROPERTY); ASTNode statementInBlock = (ASTNode) blockBody.statements().get(0); fRewriter.replace(statementInBlock, replacementNode, null);
VariableDeclarationFragment fragment= iter.next(); Expression initializer= fragment.getInitializer(); Expression replacement= (Expression) astRewrite.get(fragment, VariableDeclarationFragment.INITIALIZER_PROPERTY); if (replacement == initializer) { replacement= (Expression) astRewrite.createMoveTarget(initializer);
/** * If the given <code>node</code> has already been rewritten, undo that rewrite and return the * replacement version of the node. Otherwise, return the result of * {@link ASTRewrite#createCopyTarget(ASTNode)}. * * @param rewrite ASTRewrite for the given node * @param node the node to get the replacement or to create a copy placeholder for * @param group the edit group which collects the corresponding text edits, or <code>null</code> * if ungrouped * @return the replacement node if the given <code>node</code> has already been rewritten or the * new copy placeholder node */ public static ASTNode getCopyOrReplacement(ASTRewrite rewrite, ASTNode node, TextEditGroup group) { ASTNode rewrittenNode= (ASTNode) rewrite.get(node.getParent(), node.getLocationInParent()); if (rewrittenNode != node) { // Undo previous rewrite to avoid the problem that the same node would be inserted in two places: rewrite.replace(rewrittenNode, node, group); return rewrittenNode; } return rewrite.createCopyTarget(node); }
if(annotatableType.isSimpleType()) { annotatableType = (AnnotatableType) astRewrite.get(annotatableType.getParent(), annotatableType.getLocationInParent());
if (enclosingLambda != null && selectedNode.getLocationInParent() == LambdaExpression.BODY_PROPERTY && enclosingLambda.resolveMethodBinding() != null) { QuickAssistProcessor.changeLambdaBodyToBlock(enclosingLambda, getAST(), fRewriter); Block blockBody= (Block) fRewriter.get(enclosingLambda, LambdaExpression.BODY_PROPERTY); ASTNode statementInBlock= (ASTNode) blockBody.statements().get(0); fRewriter.replace(statementInBlock, replacementNode, null);
VariableDeclarationFragment fragment= iter.next(); Expression initializer= fragment.getInitializer(); Expression replacement= (Expression) astRewrite.get(fragment, VariableDeclarationFragment.INITIALIZER_PROPERTY); if (replacement == initializer) { replacement= (Expression) astRewrite.createMoveTarget(initializer);
ASTNode nodeValue = (ASTNode)rewriter.get(node, property);
if (enclosingLambda != null && selectedNode.getLocationInParent() == LambdaExpression.BODY_PROPERTY && enclosingLambda.resolveMethodBinding() != null) { QuickAssistProcessor.changeLambdaBodyToBlock(enclosingLambda, getAST(), fRewriter); Block blockBody= (Block) fRewriter.get(enclosingLambda, LambdaExpression.BODY_PROPERTY); ASTNode statementInBlock= (ASTNode) blockBody.statements().get(0); fRewriter.replace(statementInBlock, replacementNode, null);
ASTNode nodeValue = (ASTNode)rewriter.get(node, property);
Type oldType= (Type) rewrite.get(varDecl, VariableDeclarationStatement.TYPE_PROPERTY); rewrite.set(varDecl, VariableDeclarationStatement.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null); Type oldType= (Type) rewrite.get(varDecl, VariableDeclarationExpression.TYPE_PROPERTY); rewrite.set(varDecl, VariableDeclarationExpression.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null); Type oldType= (Type) rewrite.get(variableDeclaration, SingleVariableDeclaration.TYPE_PROPERTY); rewrite.set(variableDeclaration, SingleVariableDeclaration.TYPE_PROPERTY, type, null); DimensionRewrite.removeAllChildren(declNode, SingleVariableDeclaration.EXTRA_DIMENSIONS2_PROPERTY, rewrite, null);