DelegateMethodCreator d= new DelegateMethodCreator(); d.setDeclaration(declaration); d.setDeclareDeprecated(fDelegateDeprecation); d.setSourceRewrite(fSource); d.setCopy(false); d.setNewLocation(getDestinationBinding()); d.prepareDelegate(); d.createEdit();
DelegateMethodCreator creator= new DelegateMethodCreator(); creator.setDeclaration(declaration); creator.setDeclareDeprecated(fDelegateDeprecation); creator.setSourceRewrite(fSource); creator.setCopy(false); creator.setNewLocation(getDestinationBinding()); creator.prepareDelegate(); creator.createEdit(); Change change= creator.createChange(); if (change != null) fDelegateChanges.add(change);
	private RefactoringStatus moveMembers(BodyDeclaration[] members, String[] sources) throws CoreException {		RefactoringStatus result= new RefactoringStatus();		AbstractTypeDeclaration destination= (AbstractTypeDeclaration)		ASTNodes.getParent(			NodeFinder.perform(fTarget.getRoot(), fDestinationType.getNameRange()),			AbstractTypeDeclaration.class);		ListRewrite containerRewrite= fTarget.getASTRewrite().getListRewrite(destination, destination.getBodyDeclarationsProperty());				TextEditGroup delete= fSource.createGroupDescription(RefactoringCoreMessages.MoveMembersRefactoring_deleteMembers); 		TextEditGroup add= fTarget.createGroupDescription(RefactoringCoreMessages.MoveMembersRefactoring_addMembers); 		for (int i= 0; i < members.length; i++) {			BodyDeclaration declaration= members[i];			ASTNode removeImportsOf= null;			boolean addedDelegate= false;						if (fDelegateUpdating) {				if (declaration instanceof MethodDeclaration) {					DelegateMethodCreator d= new DelegateMethodCreator();					d.setDeclaration(declaration);					d.setDeclareDeprecated(fDelegateDeprecation);					d.setSourceRewrite(fSource);					d.setCopy(false);					d.setNewLocation(getDestinationBinding());					d.prepareDelegate();					d.createEdit();					removeImportsOf= ((MethodDeclaration) declaration).getBody();					addedDelegate= true;				}				if (declaration instanceof FieldDeclaration) {					// Note: this FieldDeclaration only has one fragment (@see #getASTMembers(RefactoringStatus))					final VariableDeclarationFragment frag= (VariableDeclarationFragment) ((FieldDeclaration) declaration).fragments().get(0);										if (!Modifier.isFinal(declaration.getModifiers())) {						// Don't create a delegate for non-final fields						result.addInfo(Messages.format(RefactoringCoreMessages.DelegateCreator_cannot_create_field_delegate_not_final, frag.getName()), null);					} else if (frag.getInitializer() == null) {						// Don't create a delegate without an initializer.						result.addInfo(Messages.format(RefactoringCoreMessages.DelegateCreator_cannot_create_field_delegate_no_initializer, frag.getName()), null);					} else {						DelegateFieldCreator d= new DelegateFieldCreator();						d.setDeclaration(declaration);						d.setDeclareDeprecated(fDelegateDeprecation);						d.setSourceRewrite(fSource);						d.setCopy(false);						d.setNewLocation(getDestinationBinding());						d.prepareDelegate();						d.createEdit();						removeImportsOf= frag.getInitializer();						addedDelegate= true;					}				}				if (declaration instanceof AbstractTypeDeclaration) {					result.addInfo(Messages.format(RefactoringCoreMessages.DelegateCreator_cannot_create_delegate_for_type, ((AbstractTypeDeclaration) declaration).getName().getIdentifier()),							null);				}			} 						if (!addedDelegate) {				fSource.getASTRewrite().remove(declaration, delete);				removeImportsOf= declaration;			}			if (removeImportsOf != null && fSource != fTarget)				fSource.getImportRemover().registerRemovedNode(removeImportsOf);						ASTNode node= fTarget.getASTRewrite().createStringPlaceholder(sources[i], declaration.getNodeType());			List container= containerRewrite.getRewrittenList();			int insertionIndex= ASTNodes.getInsertionIndex((BodyDeclaration) node, container);			containerRewrite.insertAt(node, insertionIndex, add);		}		return result;	}