VariableDeclarationStatement newVarDec= ast.newVariableDeclarationStatement(newFrag); newVarDec.setType(newType); newVarDec.setModifiers(statement.getModifiers()); rewrite.markAsReplaced(assignParent, newVarDec);
int statementParent= assignParent.getParent().getNodeType(); if (statementParent == ASTNode.IF_STATEMENT || statementParent == ASTNode.WHILE_STATEMENT || statementParent == ASTNode.DO_STATEMENT || statementParent == ASTNode.FOR_STATEMENT) {  Block block= ast.newBlock(); rewrite.markAsReplaced(assignParent, block); } else { rewrite.markAsRemoved(assignParent); }
	private boolean getJoinVariableProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) throws CoreException {		ASTNode parent= node.getParent();		if (!(parent instanceof VariableDeclarationFragment)) {			return false;		}		VariableDeclarationFragment fragment= (VariableDeclarationFragment) parent;				IVariableBinding binding= fragment.resolveBinding();		if (fragment.getInitializer() != null || binding == null || binding.isField()) {			return false;		}				if (!(fragment.getParent() instanceof VariableDeclarationStatement)) {			return false;		}		VariableDeclarationStatement statement= (VariableDeclarationStatement) fragment.getParent();				SimpleName[] names= LinkedNodeFinder.perform(statement.getParent(), binding);		if (names.length <= 1 && names[0] != fragment.getName()) {			return false;		}				SimpleName firstAccess= names[1];		if (!(firstAccess.getParent() instanceof Assignment)) { 			return false;		}		Assignment assignment= (Assignment) firstAccess.getParent();		if (assignment.getLeftHandSide() != firstAccess) {			return false;		}				ASTNode assignParent= assignment.getParent();		if (!(assignParent instanceof ExpressionStatement || assignParent instanceof ForStatement && ((ForStatement) assignParent).initializers().contains(assignment))) {			return false;		}						if (resultingCollections == null) {			return true;		}		ASTRewrite rewrite= new ASTRewrite(statement.getParent());		AST ast= statement.getAST();				String label= CorrectionMessages.getString("QuickAssistProcessor.joindeclaration.description"); //$NON-NLS-1$		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);		LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);		Expression placeholder= (Expression) rewrite.createMove(assignment.getRightHandSide());				VariableDeclarationFragment newFrag= ast.newVariableDeclarationFragment();		newFrag.setName(ast.newSimpleName(fragment.getName().getIdentifier()));		newFrag.setExtraDimensions(fragment.getExtraDimensions());		newFrag.setInitializer(placeholder);				Type newType= (Type) ASTNode.copySubtree(ast, statement.getType());				if (assignParent instanceof ExpressionStatement) {			VariableDeclarationStatement newVarDec= ast.newVariableDeclarationStatement(newFrag);			newVarDec.setType(newType);			newVarDec.setModifiers(statement.getModifiers());			rewrite.markAsReplaced(assignParent, newVarDec);		} else {			VariableDeclarationExpression newVarDec= ast.newVariableDeclarationExpression(newFrag);			newVarDec.setType(newType);			newVarDec.setModifiers(statement.getModifiers());			rewrite.markAsReplaced(assignment, newVarDec);		}				rewrite.markAsRemoved(statement);				proposal.markAsSelection(rewrite, newFrag.getName());				proposal.ensureNoModifications();		resultingCollections.add(proposal);		return true;			}