SingleVariableDeclaration newNode= ast.newSingleVariableDeclaration(); newNode.setType(imports.addImport(desc.type, ast));
rewrite.replace(decl.getType(), newType, null); rewrite.replace(decl.getName(), newName, null);
	private void modifyParameters(ASTRewrite rewrite, MethodDeclaration methodDecl, boolean isInDifferentCU) throws CoreException {		AST ast= methodDecl.getAST();		ArrayList usedNames= new ArrayList();		boolean hasCreatedVariables= false;		IVariableBinding[] declaredFields= fSenderBinding.getDeclaringClass().getDeclaredFields();		for (int i= 0; i < declaredFields.length; i++) { // avoid to take parameter names that are equal to field names			usedNames.add(declaredFields[i].getName());		}		ImportRewrite imports= getImportRewrite();		ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);		List parameters= methodDecl.parameters(); // old parameters		int k= 0; // index over the oldParameters		for (int i= 0; i < fParameterChanges.length; i++) {			ChangeDescription curr= fParameterChanges[i];			if (curr == null) {				SingleVariableDeclaration oldParam= (SingleVariableDeclaration) parameters.get(k);				usedNames.add(oldParam.getName().getIdentifier());				k++;			} else if (curr instanceof InsertDescription) {				InsertDescription desc= (InsertDescription) curr;				SingleVariableDeclaration newNode= ast.newSingleVariableDeclaration();				newNode.setType(imports.addImport(desc.type, ast));				// remember to set name later				desc.resultingNode= newNode;				hasCreatedVariables= true;				listRewrite.insertAt(newNode, i, null);				Javadoc javadoc= methodDecl.getJavadoc();				if (javadoc != null) {					TagElement newTagElement= ast.newTagElement();					newTagElement.setTagName(TagElement.TAG_PARAM);					SimpleName arg= ast.newSimpleName("x"); //$NON-NLS-1$					newTagElement.fragments().add(arg);					insertTabStop(rewrite, newTagElement.fragments(), "param_tagcomment" + i); //$NON-NLS-1$					insertParamTag(rewrite.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY), parameters, k, newTagElement);					desc.resultingTagArg= arg; // set the name later				} else {					desc.resultingTagArg= null;				}			} else if (curr instanceof RemoveDescription) {				SingleVariableDeclaration decl= (SingleVariableDeclaration) parameters.get(k);				listRewrite.remove(decl, null);				k++;				TagElement tagNode= findParamTag(methodDecl, decl);				if (tagNode != null) {					rewrite.remove(tagNode, null);				}			} else if (curr instanceof EditDescription) {				EditDescription desc= (EditDescription) curr;				SingleVariableDeclaration decl= (SingleVariableDeclaration) parameters.get(k);				SingleVariableDeclaration newNode= ast.newSingleVariableDeclaration();				newNode.setType(imports.addImport(desc.type, ast));				// remember to set name later				desc.resultingNode= newNode;				hasCreatedVariables= true;				rewrite.replace(decl, newNode, null);				k++;				TagElement tagNode= findParamTag(methodDecl, decl);				if (tagNode != null) {					List fragments= tagNode.fragments();					if (!fragments.isEmpty()) {						SimpleName arg= ast.newSimpleName("x"); //$NON-NLS-1$						rewrite.replace((ASTNode) fragments.get(0), arg, null);						desc.resultingTagArg= arg;					}				}			} else if (curr instanceof SwapDescription) {				SingleVariableDeclaration decl1= (SingleVariableDeclaration) parameters.get(k);				SingleVariableDeclaration decl2= (SingleVariableDeclaration) parameters.get(((SwapDescription) curr).index);				rewrite.replace(decl1, rewrite.createCopyTarget(decl2), null);				rewrite.replace(decl2, rewrite.createCopyTarget(decl1), null);				usedNames.add(decl1.getName().getIdentifier());				k++;				TagElement tagNode1= findParamTag(methodDecl, decl1);				TagElement tagNode2= findParamTag(methodDecl, decl2);				if (tagNode1 != null && tagNode2 != null) {					rewrite.replace(tagNode1, rewrite.createCopyTarget(tagNode2), null);					rewrite.replace(tagNode2, rewrite.createCopyTarget(tagNode1), null);				}			}		}		if (!hasCreatedVariables) {			return;		}		if (methodDecl.getBody() != null) {			// avoid take a name of a local variable inside			CompilationUnit root= (CompilationUnit) methodDecl.getRoot();			IBinding[] bindings= (new ScopeAnalyzer(root)).getDeclarationsAfter(methodDecl.getBody().getStartPosition(), ScopeAnalyzer.VARIABLES);			for (int i= 0; i < bindings.length; i++) {				usedNames.add(bindings[i].getName());			}		}		fixupNames(rewrite, usedNames, methodDecl, isInDifferentCU);	}