use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameModifications method rename.
public void rename(IPackageFragment rootPackage, RenameArguments args, boolean renameSubPackages) throws CoreException {
add(rootPackage, args, null);
IPackageFragment[] allSubPackages = null;
if (renameSubPackages) {
allSubPackages = getSubpackages(rootPackage);
for (int i = 0; i < allSubPackages.length; i++) {
IPackageFragment pack = allSubPackages[i];
RenameArguments subArgs = new RenameArguments(getNewPackageName(rootPackage, args.getNewName(), pack.getElementName()), args.getUpdateReferences());
add(pack, subArgs, null);
}
}
IContainer container = (IContainer) rootPackage.getResource();
if (container == null)
return;
IContainer target = (IContainer) ((IPackageFragmentRoot) rootPackage.getParent()).getPackageFragment(args.getNewName()).getResource();
if ((!rootPackage.hasSubpackages() || renameSubPackages) && canMove(container, target)) {
createIncludingParents(target.getParent());
if (container.getParent().equals(target.getParent())) {
getResourceModifications().addRename(container, new RenameArguments(target.getName(), args.getUpdateReferences()));
} else {
// moves and deletes.
try {
getResourceModifications().ignoreForDelta();
addAllResourceModifications(rootPackage, args, renameSubPackages, allSubPackages);
} finally {
getResourceModifications().trackForDelta();
}
getResourceModifications().addDelta(new ResourceModifications.MoveDescription(container, target.getFullPath()));
}
} else {
addAllResourceModifications(rootPackage, args, renameSubPackages, allSubPackages);
}
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class ResourceModifications method addRename.
/**
* Adds the given resource to the list of renamed
* resources.
*
* @param rename the resource to be renamed
* @param arguments the arguments of the rename
*/
public void addRename(IResource rename, RenameArguments arguments) {
Assert.isNotNull(rename);
Assert.isNotNull(arguments);
if (fRename == null) {
fRename = new ArrayList<IResource>(2);
fRenameArguments = new ArrayList<RenameArguments>(2);
}
fRename.add(rename);
fRenameArguments.add(arguments);
if (fIgnoreCount == 0) {
IPath newPath = rename.getFullPath().removeLastSegments(1).append(arguments.getNewName());
internalAdd(new MoveDescription(rename, newPath));
}
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameLocalVariableProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
result.rename(fLocalVariable, new RenameArguments(getNewElementName(), getUpdateReferences()));
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameResourceProcessor method checkFinalConditions.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
//$NON-NLS-1$
pm.beginTask("", 1);
try {
fRenameArguments = new RenameArguments(getNewResourceName(), isUpdateReferences());
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
ResourceModifications.buildMoveDelta(deltaFactory, fResource, fRenameArguments);
return new RefactoringStatus();
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class ResourceModifications method getParticipants.
public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
List result = new ArrayList(5);
if (fDelete != null) {
DeleteArguments arguments = new DeleteArguments();
for (Iterator iter = fDelete.iterator(); iter.hasNext(); ) {
DeleteParticipant[] deletes = ParticipantManager.loadDeleteParticipants(status, processor, iter.next(), arguments, natures, shared);
result.addAll(Arrays.asList(deletes));
}
}
if (fCreate != null) {
CreateArguments arguments = new CreateArguments();
for (Iterator iter = fCreate.iterator(); iter.hasNext(); ) {
CreateParticipant[] creates = ParticipantManager.loadCreateParticipants(status, processor, iter.next(), arguments, natures, shared);
result.addAll(Arrays.asList(creates));
}
}
if (fMove != null) {
for (int i = 0; i < fMove.size(); i++) {
Object element = fMove.get(i);
MoveArguments arguments = (MoveArguments) fMoveArguments.get(i);
MoveParticipant[] moves = ParticipantManager.loadMoveParticipants(status, processor, element, arguments, natures, shared);
result.addAll(Arrays.asList(moves));
}
}
if (fCopy != null) {
for (int i = 0; i < fCopy.size(); i++) {
Object element = fCopy.get(i);
CopyArguments arguments = (CopyArguments) fCopyArguments.get(i);
CopyParticipant[] copies = ParticipantManager.loadCopyParticipants(status, processor, element, arguments, natures, shared);
result.addAll(Arrays.asList(copies));
}
}
if (fRename != null) {
for (int i = 0; i < fRename.size(); i++) {
Object resource = fRename.get(i);
RenameArguments arguments = (RenameArguments) fRenameArguments.get(i);
RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource, arguments, natures, shared);
result.addAll(Arrays.asList(renames));
}
}
return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
}
Aggregations