Search in sources :

Example 31 with RenameArguments

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();
    }
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Example 32 with RenameArguments

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()]);
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RefactoringParticipant(org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant) ArrayList(java.util.ArrayList) MoveParticipant(org.eclipse.ltk.core.refactoring.participants.MoveParticipant) DeleteParticipant(org.eclipse.ltk.core.refactoring.participants.DeleteParticipant) CreateArguments(org.eclipse.ltk.core.refactoring.participants.CreateArguments) DeleteArguments(org.eclipse.ltk.core.refactoring.participants.DeleteArguments) CopyArguments(org.eclipse.ltk.core.refactoring.participants.CopyArguments) CreateParticipant(org.eclipse.ltk.core.refactoring.participants.CreateParticipant) CopyParticipant(org.eclipse.ltk.core.refactoring.participants.CopyParticipant) MoveArguments(org.eclipse.ltk.core.refactoring.participants.MoveArguments) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) RenameParticipant(org.eclipse.ltk.core.refactoring.participants.RenameParticipant)

Example 33 with RenameArguments

use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.

the class RenamePackageProcessor method computeRenameModifications.

@Override
protected RenameModifications computeRenameModifications() throws CoreException {
    RenameModifications result = new RenameModifications();
    result.rename(fPackage, new RenameArguments(getNewElementName(), getUpdateReferences()), fRenameSubpackages);
    return result;
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments)

Example 34 with RenameArguments

use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.

the class RenameTypeParameterProcessor method computeRenameModifications.

@Override
protected RenameModifications computeRenameModifications() throws CoreException {
    RenameModifications result = new RenameModifications();
    result.rename(fTypeParameter, new RenameArguments(getNewElementName(), getUpdateReferences()));
    return result;
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments)

Example 35 with RenameArguments

use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project bndtools by bndtools.

the class PkgRenameParticipant method initialize.

@Override
protected boolean initialize(Object element) {
    IPackageFragment pkgFragment = (IPackageFragment) element;
    RenameArguments args = getArguments();
    pkgFragments.put(pkgFragment, args);
    StringBuilder sb = new StringBuilder(256);
    sb.append("Bndtools: rename package '");
    sb.append(pkgFragment.getElementName());
    sb.append("' ");
    if (((RenamePackageProcessor) this.getProcessor()).getRenameSubpackages())
        sb.append("and subpackages ");
    sb.append("to '");
    sb.append(args.getNewName());
    sb.append("'");
    changeTitle = sb.toString();
    return true;
}
Also used : IPackageFragment(org.eclipse.jdt.core.IPackageFragment) RenamePackageProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenamePackageProcessor) RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments)

Aggregations

RenameArguments (org.eclipse.ltk.core.refactoring.participants.RenameArguments)36 Test (org.junit.Test)15 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)13 ArrayList (java.util.ArrayList)12 List (java.util.List)11 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)9 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)8 RenameJavaElementDescriptor (org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor)7 MoveArguments (org.eclipse.ltk.core.refactoring.participants.MoveArguments)7 IType (org.eclipse.jdt.core.IType)6 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)6 BaseTest (org.eclipse.che.plugin.java.server.che.BaseTest)5 IFolder (org.eclipse.core.resources.IFolder)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IField (org.eclipse.jdt.core.IField)5 Ignore (org.junit.Ignore)5 IMethod (org.eclipse.jdt.core.IMethod)4 IResource (org.eclipse.core.resources.IResource)3 IPath (org.eclipse.core.runtime.IPath)3 RenamePackageProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenamePackageProcessor)3