Java Code Examples for org.eclipse.ltk.core.refactoring.participants.RenameArguments#getUpdateReferences()
The following examples show how to use
org.eclipse.ltk.core.refactoring.participants.RenameArguments#getUpdateReferences() .
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: RenameModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 2
Source File: RenameModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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 { // This is a little tricky. The problem is that the refactoring participants // don't support a generic move like the resource API does. So for the delta // we generate one move, however for the participants we have to generate single // 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); } }
Example 3
Source File: RenameModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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 4
Source File: RenameModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 { // This is a little tricky. The problem is that the refactoring participants // don't support a generic move like the resource API does. So for the delta // we generate one move, however for the participants we have to generate single // 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); } }