Search in sources :

Example 36 with CompositeChange

use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.

the class JSPRenameParticipant method createChange.

/**
 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(
 * 	org.eclipse.core.runtime.IProgressMonitor)
 */
public Change createChange(IProgressMonitor pm) throws CoreException {
    // $NON-NLS-1$
    this.getTextChange("");
    // create one multi change to contain all new created changes
    CompositeChange multiChange = new CompositeChange(JSPUIMessages.JSP_changes);
    // for each element get the changes for it and add it to the multi change
    Iterator iter = fElementAndArgumentPairs.values().iterator();
    while (iter.hasNext()) {
        ElementAndArgumentsPair elemArgsPair = (ElementAndArgumentsPair) iter.next();
        Change[] changes = createChangesFor(elemArgsPair.fElement, elemArgsPair.fArgs.getNewName(), pm);
        /* add all new text changes to the local list of text changes so that
			 * future iterations through the while loop will be aware of already
			 * existing changes
			 */
        for (int i = 0; i < changes.length; ++i) {
            if (changes[i] instanceof TextChange) {
                fLocalTextChanges.put(((TextChange) changes[i]).getModifiedElement(), changes[i]);
            }
        }
        if (changes.length > 0) {
            multiChange.addAll(changes);
        }
    }
    // unless there are actually new changes return null
    Change result = null;
    if (multiChange.getChildren().length > 0) {
        result = multiChange;
    }
    return result;
}
Also used : Iterator(java.util.Iterator) TextChange(org.eclipse.ltk.core.refactoring.TextChange) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) TextChange(org.eclipse.ltk.core.refactoring.TextChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Example 37 with CompositeChange

use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.

the class JSPMethodRenameParticipant method createChange.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
	 */
public Change createChange(IProgressMonitor pm) throws CoreException {
    Change[] changes = JSPMethodRenameChange.createChangesFor(this.fMethod, getArguments().getNewName());
    CompositeChange multiChange = null;
    if (changes.length > 0) {
        multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
    }
    return multiChange;
}
Also used : CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Example 38 with CompositeChange

use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.

the class JSPTypeRenameParticipant method createChange.

/**
 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
 */
public Change createChange(IProgressMonitor pm) throws CoreException {
    Change[] changes = JSPTypeRenameChange.createChangesFor(fType, getArguments().getNewName());
    CompositeChange multiChange = null;
    if (changes.length > 0) {
        multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
    }
    return multiChange;
}
Also used : CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Example 39 with CompositeChange

use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.

the class JSPPackageRenameParticipant method createChange.

/**
 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
 */
public Change createChange(IProgressMonitor pm) throws CoreException {
    Change[] changes = JSPPackageRenameChange.createChangesFor(this.fPkg, getArguments().getNewName());
    CompositeChange multiChange = null;
    if (changes.length > 0) {
        multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
    }
    return multiChange;
}
Also used : CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Example 40 with CompositeChange

use of org.eclipse.ltk.core.refactoring.CompositeChange in project webtools.sourceediting by eclipse.

the class RenameComponentProcessor method postCreateChange.

public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException, OperationCanceledException {
    Assert.isNotNull(pm);
    try {
        String changeName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_updates");
        TextChange[] changes = changeManager.getAllChanges();
        // };
        if (changes.length > 0) {
            // Arrays.sort(changes, c);
            CompositeChange compositeChange = new CompositeChange("!" + changeName, changes);
            compositeChange.markAsSynthetic();
            return compositeChange;
        } else {
            return null;
        }
    } finally {
        pm.done();
    }
}
Also used : TextChange(org.eclipse.ltk.core.refactoring.TextChange) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Aggregations

CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)49 Change (org.eclipse.ltk.core.refactoring.Change)22 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)14 IFile (org.eclipse.core.resources.IFile)10 IResource (org.eclipse.core.resources.IResource)9 TextChange (org.eclipse.ltk.core.refactoring.TextChange)9 IResourceVisitor (org.eclipse.core.resources.IResourceVisitor)7 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)6 EditorDocumentChange (org.eclipse.xtext.ui.refactoring.impl.EditorDocumentChange)6 CoreException (org.eclipse.core.runtime.CoreException)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)4 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)4 TextEditBasedChange (org.eclipse.ltk.core.refactoring.TextEditBasedChange)4 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)3 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)3 TextEdit (org.eclipse.text.edits.TextEdit)3 IOException (java.io.IOException)2