td.bodyDeclarations().add(md); Block block = ast.newBlock(); md.setBody(block);
public Block createCollapsePlaceholder() { Block placeHolder= this.ast.newBlock(); if (this.collapsedNodes == null) { this.collapsedNodes= new HashSet(); } this.collapsedNodes.add(placeHolder); return placeHolder; }
public Block createCollapsePlaceholder() { Block placeHolder= this.ast.newBlock(); if (this.collapsedNodes == null) { this.collapsedNodes= new HashSet(); } this.collapsedNodes.add(placeHolder); return placeHolder; }
public Block createCollapsePlaceholder() { Block placeHolder= this.ast.newBlock(); if (this.collapsedNodes == null) { this.collapsedNodes= new HashSet(); } this.collapsedNodes.add(placeHolder); return placeHolder; }
public Block createCollapsePlaceholder() { Block placeHolder= this.ast.newBlock(); if (this.collapsedNodes == null) { this.collapsedNodes= new HashSet(); } this.collapsedNodes.add(placeHolder); return placeHolder; }
public Block createCollapsePlaceholder() { Block placeHolder= this.ast.newBlock(); if (this.collapsedNodes == null) { this.collapsedNodes= new HashSet(); } this.collapsedNodes.add(placeHolder); return placeHolder; }
ReplaceStatement(Statement origStmt, ASTRewrite rewrite, TextEditGroup group) { // did not have a block, create one now to hold new statements: super(origStmt, rewrite.getAST().newBlock(), group); this.rewrite = rewrite; } @Override
private Statement getThenStatement(Statement statement) { if (fUseBlocksForThen && !(statement instanceof Block)) { Block block= fAst.newBlock(); block.statements().add(statement); return block; } return statement; }
private Statement getThenStatement(Statement statement) { if (fUseBlocksForThen && !(statement instanceof Block)) { Block block= fAst.newBlock(); block.statements().add(statement); return block; } return statement; }
/** * Create a block builder for the method body. * * @return builder */ public BlockBuilder createBlock() { Block block = m_ast.newBlock(); m_method.setBody(block); return new BlockBuilder(m_source, block); } }
private static Block getBlockBodyForLambda(Expression bodyExpr, ITypeBinding returnTypeBinding, AST ast) { Statement statementInBlockBody; if (ast.resolveWellKnownType("void").isEqualTo(returnTypeBinding)) { //$NON-NLS-1$ ExpressionStatement expressionStatement = ast.newExpressionStatement(bodyExpr); statementInBlockBody = expressionStatement; } else { ReturnStatement returnStatement = ast.newReturnStatement(); returnStatement.setExpression(bodyExpr); statementInBlockBody = returnStatement; } Block blockBody = ast.newBlock(); blockBody.statements().add(statementInBlockBody); return blockBody; }
private void removeStatement(ASTRewrite rewrite, ASTNode statementNode, TextEditGroup group) { if (ASTNodes.isControlStatementBody(statementNode.getLocationInParent())) { rewrite.replace(statementNode, rewrite.getAST().newBlock(), group); } else { rewrite.remove(statementNode, group); } }
private void removeStatement(ASTRewrite rewrite, ASTNode statementNode, TextEditGroup group) { if (ASTNodes.isControlStatementBody(statementNode.getLocationInParent())) { rewrite.replace(statementNode, rewrite.getAST().newBlock(), group); } else { rewrite.remove(statementNode, group); } }
@SuppressWarnings("unchecked") private void generateConstructorDefault(Classifier clazz, AST ast, TypeDeclaration td) { MethodDeclaration constructor = ast.newMethodDeclaration(); constructor.setConstructor(true); constructor.setName(ast.newSimpleName(clazz.getName())); constructor.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); Block block = ast.newBlock(); constructor.setBody(block); td.bodyDeclarations().add(constructor); }
private void removeStatement(ASTRewrite rewrite, ASTNode statementNode, TextEditGroup group) { if (ASTNodes.isControlStatementBody(statementNode.getLocationInParent())) { rewrite.replace(statementNode, rewrite.getAST().newBlock(), group); } else { rewrite.remove(statementNode, group); } }
private CAstEntity createDefaultConstructor(ITypeBinding classBinding, WalkContext oldContext, ArrayList<ASTNode> inits, ASTNode positioningNode) { MethodDeclaration fakeCtor = ast.newMethodDeclaration(); fakeCtor.setConstructor(true); // fakeCtor.setName(ast.newSimpleName(className)); will crash on anonymous types... fakeCtor.setSourceRange(positioningNode.getStartPosition(), positioningNode.getLength()); fakeCtor.setBody(ast.newBlock()); return visit(fakeCtor, classBinding, oldContext, inits); }
private void addFieldInitializationToConstructor(ASTRewrite rewrite, MethodDeclaration constructor) { if (constructor.getBody() == null) constructor.setBody(getAST().newBlock()); Statement newStatement= createNewAssignmentStatement(rewrite); rewrite.getListRewrite(constructor.getBody(), Block.STATEMENTS_PROPERTY).insertLast(newStatement, null); }
private void addFieldInitializationToConstructor(ASTRewrite rewrite, MethodDeclaration constructor) { if (constructor.getBody() == null) constructor.setBody(getAST().newBlock()); Statement newStatement= createNewAssignmentStatement(rewrite); rewrite.getListRewrite(constructor.getBody(), Block.STATEMENTS_PROPERTY).insertLast(newStatement, null); }
private void addFieldInitializationToConstructor(ASTRewrite rewrite, MethodDeclaration constructor) throws JavaModelException { if (constructor.getBody() == null) constructor.setBody(getAST().newBlock()); ExpressionStatement newStatement= createExpressionStatementThatInitializesField(rewrite); rewrite.getListRewrite(constructor.getBody(), Block.STATEMENTS_PROPERTY).insertLast(newStatement, null); }
protected ASTNode createBody(BodyDeclaration bd) throws JavaModelException { MethodDeclaration methodDeclaration= (MethodDeclaration) bd; final MethodInvocation invocation= getAst().newMethodInvocation(); invocation.setName(getAst().newSimpleName(getNewElementName())); invocation.setExpression(createSimpleTargetAccessExpression(methodDeclaration)); fNeededInsertion= createArgumentList(methodDeclaration, invocation.arguments(), new VisibilityAdjustingArgumentFactory(getAst(), fRewrites, fAdjustments)); final Block block= getAst().newBlock(); block.statements().add(createMethodInvocation(methodDeclaration, invocation)); if (!fSourceRewrite.getCu().equals(fTargetType.getCompilationUnit())) fSourceRewrite.getImportRemover().registerRemovedNode(methodDeclaration.getBody()); return block; }