org.eclipse.ltk.core.refactoring.participants.MoveArguments Java Examples

The following examples show how to use org.eclipse.ltk.core.refactoring.participants.MoveArguments. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected RefactoringModifications getModifications() throws CoreException {
	if (fModifications != null)
		return fModifications;

	fModifications= new MoveModifications();
	boolean updateReferences= getUpdateReferences();
	IPackageFragment[] packages= getPackages();
	IPackageFragmentRoot javaDestination= getDestinationAsPackageFragmentRoot();
	for (int i= 0; i < packages.length; i++) {
		if (javaDestination == null) {
			fModifications.move(packages[i].getResource(), new MoveArguments(getResourceDestination(), updateReferences));
		} else {
			fModifications.move(packages[i], new MoveArguments(javaDestination, updateReferences));
		}
	}
	return fModifications;
}
 
Example #2
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public void move(IPackageFragmentRoot sourceFolder, MoveArguments arguments) {
	add(sourceFolder, arguments, null);
	IResource sourceResource= sourceFolder.getResource();
	if (sourceResource != null) {
		getResourceModifications().addMove(sourceResource,
			new MoveArguments(getResourceDestination(arguments), arguments.getUpdateReferences()));
		IFile classpath= getClasspathFile(sourceResource);
		if (classpath != null) {
			getResourceModifications().addChanged(classpath);
		}
		classpath= getClasspathFile(getResourceDestination(arguments));
		if (classpath != null) {
			getResourceModifications().addChanged(classpath);
		}
	}
}
 
Example #3
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public void move(ICompilationUnit unit, MoveArguments args) throws CoreException {
	add(unit, args, null);
	IType[] types= unit.getTypes();
	for (int tt= 0; tt < types.length; tt++) {
		add(types[tt], args, null);
	}
	IResource resourceDestination= getResourceDestination(args);
	if (resourceDestination != null && unit.getResource() != null) {
		IResource parent= resourceDestination;
		while (!parent.exists()) {
			getResourceModifications().addCreate(parent);
			parent= parent.getParent();
		}

		getResourceModifications().addMove(unit.getResource(), new MoveArguments(resourceDestination, args.getUpdateReferences()));
	}
}
 
Example #4
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void move(ICompilationUnit unit, MoveArguments args) throws CoreException {
	add(unit, args, null);
	IType[] types= unit.getTypes();
	for (int tt= 0; tt < types.length; tt++) {
		add(types[tt], args, null);
	}
	IResource resourceDestination= getResourceDestination(args);
	if (resourceDestination != null && unit.getResource() != null) {
		IResource parent= resourceDestination;
		while (!parent.exists()) {
			getResourceModifications().addCreate(parent);
			parent= parent.getParent();
		}

		getResourceModifications().addMove(unit.getResource(), new MoveArguments(resourceDestination, args.getUpdateReferences()));
	}
}
 
Example #5
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void move(IPackageFragmentRoot sourceFolder, MoveArguments arguments) {
	add(sourceFolder, arguments, null);
	IResource sourceResource= sourceFolder.getResource();
	if (sourceResource != null) {
		getResourceModifications().addMove(sourceResource,
			new MoveArguments(getResourceDestination(arguments), arguments.getUpdateReferences()));
		IFile classpath= getClasspathFile(sourceResource);
		if (classpath != null) {
			getResourceModifications().addChanged(classpath);
		}
		classpath= getClasspathFile(getResourceDestination(arguments));
		if (classpath != null) {
			getResourceModifications().addChanged(classpath);
		}
	}
}
 
Example #6
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected RefactoringModifications getModifications() throws CoreException {
	if (fModifications != null) {
		return fModifications;
	}

	fModifications= new MoveModifications();
	boolean updateReferences= getUpdateReferences();
	IPackageFragment[] packages= getPackages();
	IPackageFragmentRoot javaDestination= getDestinationAsPackageFragmentRoot();
	for (int i= 0; i < packages.length; i++) {
		if (javaDestination == null) {
			fModifications.move(packages[i].getResource(), new MoveArguments(getResourceDestination(), updateReferences));
		} else {
			fModifications.move(packages[i], new MoveArguments(javaDestination, updateReferences));
		}
	}
	return fModifications;
}
 
Example #7
Source File: RenameModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IFolder addResourceModifications(IPackageFragment rootPackage, RenameArguments args, IPackageFragment pack, boolean renameSubPackages) throws CoreException {
	IContainer container= (IContainer)pack.getResource();
	if (container == null)
		return null;
	IFolder target= computeTargetFolder(rootPackage, args, pack);
	createIncludingParents(target);
	MoveArguments arguments= new MoveArguments(target, args.getUpdateReferences());
	IResource[] resourcesToMove= collectResourcesOfInterest(pack);
	Set<IResource> allMembers= new HashSet<IResource>(Arrays.asList(container.members()));
	for (int i= 0; i < resourcesToMove.length; i++) {
		IResource toMove= resourcesToMove[i];
		getResourceModifications().addMove(toMove, arguments);
		allMembers.remove(toMove);
	}
	for (Iterator<IResource> iter= allMembers.iterator(); iter.hasNext();) {
		IResource element= iter.next();
		if (element instanceof IFile) {
			getResourceModifications().addDelete(element);
			iter.remove();
		}
	}
	if (! renameSubPackages && allMembers.isEmpty()) {
		getResourceModifications().addDelete(container);
	}
	return target;
}
 
Example #8
Source File: MoveStaticMembersProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
	List<MoveParticipant> result= new ArrayList<MoveParticipant>();
	MoveArguments args= new MoveArguments(fDestinationType, true);
	String[] natures= JavaProcessors.computeAffectedNaturs(fMembersToMove);
	for (int i= 0; i < fMembersToMove.length; i++) {
		IMember member= fMembersToMove[i];
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(
			status, this, member, args, natures, sharedParticipants)));
	}
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #9
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected RefactoringModifications getModifications() throws CoreException {
	if (fModifications != null)
		return fModifications;

	fModifications= new MoveModifications();
	IPackageFragment pack= getDestinationAsPackageFragment();
	IContainer container= getDestinationAsContainer();
	Object unitDestination= null;
	if (pack != null)
		unitDestination= pack;
	else
		unitDestination= container;

	boolean updateReferenes= getUpdateReferences();
	if (unitDestination != null) {
		ICompilationUnit[] units= getCus();
		for (int i= 0; i < units.length; i++) {
			fModifications.move(units[i], new MoveArguments(unitDestination, updateReferenes));
		}
	}
	if (container != null) {
		IFile[] files= getFiles();
		for (int i= 0; i < files.length; i++) {
			fModifications.move(files[i], new MoveArguments(container, updateReferenes));
		}
		IFolder[] folders= getFolders();
		for (int i= 0; i < folders.length; i++) {
			fModifications.move(folders[i], new MoveArguments(container, updateReferenes));
		}
	}
	return fModifications;
}
 
Example #10
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>();
	for (int i= 0; i < fMoves.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status,
			owner, fMoves.get(i),
			(MoveArguments) fMoveArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #11
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fMoves.size(); i++) {
		Object element= fMoves.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (MoveArguments) fMoveArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #12
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the given resource to the list of resources
 * to be moved.
 *
 * @param move the resource to be moved
 * @param arguments the move arguments
 */
public void addMove(IResource move, MoveArguments arguments) {
	if (fMove == null) {
		fMove= new ArrayList<IResource>(2);
		fMoveArguments= new ArrayList<MoveArguments>(2);
	}
	fMove.add(move);
	fMoveArguments.add(arguments);
	if (fIgnoreCount == 0) {
		IPath destination= ((IResource)arguments.getDestination()).getFullPath().append(move.getName());
		internalAdd(new MoveDescription(move, destination));
	}
}
 
Example #13
Source File: XtextMoveResourceParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addElement(Object element, RefactoringArguments arguments) {
	if (arguments instanceof MoveArguments) {
		if (element instanceof IResource) {
			Object destination = ((MoveArguments) arguments).getDestination();
			if (destination instanceof IFolder || destination instanceof IProject) {
				IFile destinationFile = ((IContainer) destination).getFile(new Path(((IResource) element).getName()));
				processor.addChangedResource(((IResource) element), ((IResource) element).getFullPath(), destinationFile.getFullPath());
			}
		}
	}
}
 
Example #14
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected RefactoringModifications getModifications() throws CoreException {
	if (fModifications != null) {
		return fModifications;
	}

	fModifications= new MoveModifications();
	IPackageFragment pack= getDestinationAsPackageFragment();
	IContainer container= getDestinationAsContainer();
	Object unitDestination= null;
	if (pack != null) {
		unitDestination= pack;
	} else {
		unitDestination= container;
	}

	boolean updateReferenes= getUpdateReferences();
	if (unitDestination != null) {
		ICompilationUnit[] units= getCus();
		for (int i= 0; i < units.length; i++) {
			fModifications.move(units[i], new MoveArguments(unitDestination, updateReferenes));
		}
	}
	if (container != null) {
		IFile[] files= getFiles();
		for (int i= 0; i < files.length; i++) {
			fModifications.move(files[i], new MoveArguments(container, updateReferenes));
		}
		IFolder[] folders= getFolders();
		for (int i= 0; i < folders.length; i++) {
			fModifications.move(folders[i], new MoveArguments(container, updateReferenes));
		}
	}
	return fModifications;
}
 
Example #15
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<>();
	for (int i= 0; i < fMoves.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status,
			owner, fMoves.get(i),
			(MoveArguments) fMoveArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #16
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fMoves.size(); i++) {
		Object element= fMoves.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (MoveArguments) fMoveArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #17
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Adds the given resource to the list of resources
 * to be moved.
 *
 * @param move the resource to be moved
 * @param arguments the move arguments
 */
public void addMove(IResource move, MoveArguments arguments) {
	if (fMove == null) {
		fMove= new ArrayList<>(2);
		fMoveArguments= new ArrayList<>(2);
	}
	fMove.add(move);
	fMoveArguments.add(arguments);
	if (fIgnoreCount == 0) {
		IPath destination= ((IResource)arguments.getDestination()).getFullPath().append(move.getName());
		internalAdd(new MoveDescription(move, destination));
	}
}
 
Example #18
Source File: RenameModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private IFolder addResourceModifications(IPackageFragment rootPackage, RenameArguments args, IPackageFragment pack, boolean renameSubPackages) throws CoreException {
	IContainer container= (IContainer)pack.getResource();
	if (container == null) {
		return null;
	}
	IFolder target= computeTargetFolder(rootPackage, args, pack);
	createIncludingParents(target);
	MoveArguments arguments= new MoveArguments(target, args.getUpdateReferences());
	IResource[] resourcesToMove= collectResourcesOfInterest(pack);
	Set<IResource> allMembers= new HashSet<>(Arrays.asList(container.members()));
	for (int i= 0; i < resourcesToMove.length; i++) {
		IResource toMove= resourcesToMove[i];
		getResourceModifications().addMove(toMove, arguments);
		allMembers.remove(toMove);
	}
	for (Iterator<IResource> iter= allMembers.iterator(); iter.hasNext();) {
		IResource element= iter.next();
		if (element instanceof IFile) {
			getResourceModifications().addDelete(element);
			iter.remove();
		}
	}
	if (! renameSubPackages && allMembers.isEmpty()) {
		getResourceModifications().addDelete(container);
	}
	return target;
}
 
Example #19
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
	IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
	new MoveDescription(resource, destination).buildDelta(builder);
}
 
Example #20
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void move(IResource resource, MoveArguments args) {
	add(resource, args, null);
}
 
Example #21
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public void move(IResource resource, MoveArguments args) {
	add(resource, args, null);
}
 
Example #22
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
	IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
	new MoveDescription(resource, destination).buildDelta(builder);
}