use of org.eclipse.ltk.core.refactoring.CompositeChange in project che by eclipse.
the class Changes method getModifiedFiles.
private static void getModifiedFiles(List<IFile> result, Change[] changes) {
for (int i = 0; i < changes.length; i++) {
Change change = changes[i];
Object modifiedElement = change.getModifiedElement();
if (modifiedElement instanceof IAdaptable) {
IFile file = (IFile) ((IAdaptable) modifiedElement).getAdapter(IFile.class);
if (file != null)
result.add(file);
}
if (change instanceof CompositeChange) {
getModifiedFiles(result, ((CompositeChange) change).getChildren());
}
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project che by eclipse.
the class MoveResourcesProcessor method createChange.
/* (non-Javadoc)
* @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change createChange(IProgressMonitor pm) throws CoreException {
//$NON-NLS-1$
pm.beginTask("", fResourcesToMove.length);
try {
CompositeChange compositeChange = new CompositeChange(getMoveDescription());
compositeChange.markAsSynthetic();
RefactoringChangeDescriptor descriptor = new RefactoringChangeDescriptor(createDescriptor());
for (int i = 0; i < fResourcesToMove.length; i++) {
MoveResourceChange moveChange = new MoveResourceChange(fResourcesToMove[i], fDestination);
moveChange.setDescriptor(descriptor);
compositeChange.add(moveChange);
}
return compositeChange;
} finally {
pm.done();
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project che by eclipse.
the class ProcessorBasedRefactoring method addToTextChangeMap.
private void addToTextChangeMap(Change change) {
if (change instanceof TextChange) {
Object element = ((TextChange) change).getModifiedElement();
if (element != null) {
fTextChangeMap.put(element, change);
}
// under the file resource into the hash table if possible.
if (change instanceof TextFileChange && !change.getClass().equals(TextFileChange.class)) {
IFile file = ((TextFileChange) change).getFile();
fTextChangeMap.put(file, change);
}
} else if (change instanceof CompositeChange) {
Change[] children = ((CompositeChange) change).getChildren();
for (int i = 0; i < children.length; i++) {
addToTextChangeMap(children[i]);
}
}
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project xtext-eclipse by eclipse.
the class CompositeRefactoringProcessor method createChange.
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
SubMonitor monitor = SubMonitor.convert(pm, processors.size());
CompositeChange compositeChange = new CompositeChange(getProcessorName());
for (RefactoringProcessor processor : processors) {
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
compositeChange.add(processor.createChange(monitor.newChild(1)));
}
return textChangeCombiner.combineChanges(compositeChange);
}
use of org.eclipse.ltk.core.refactoring.CompositeChange in project xtext-eclipse by eclipse.
the class TextChangeCombinerTest method assertTextType.
protected void assertTextType(Change change) {
if (change instanceof CompositeChange) {
for (Change child : ((CompositeChange) change).getChildren()) {
assertTextType(child);
}
} else {
assertTrue(change.getClass().getName(), change instanceof TextEditBasedChange);
assertEquals(TEXT_TYPE, ((TextEditBasedChange) change).getTextType());
}
}
Aggregations