本文整理汇总了Java中org.eclipse.ltk.core.refactoring.CompositeChange.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeChange.getChildren方法的具体用法?Java CompositeChange.getChildren怎么用?Java CompositeChange.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ltk.core.refactoring.CompositeChange
的用法示例。
在下文中一共展示了CompositeChange.getChildren方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateChange
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
public void testCreateChange() {
GWTRefactoringSupport support = new DummyGWTRefactoringSupport();
support.setUpdateReferences(true);
IType refactorTestType = refactorTestClass.getCompilationUnit().findPrimaryType();
support.setOldElement(refactorTestType);
RefactoringParticipant participant = new DummyRefactoringParticipant();
IRefactoringChangeFactory changeFactory = new DefaultChangeFactory();
CompositeChange change = support.createChange(participant, changeFactory);
// Return value should contain one child change
Change[] changeChildren = change.getChildren();
assertEquals(1, changeChildren.length);
// Root edit should contain two child edits, one for each JSNI ref
TextChange childChange = (TextChange) changeChildren[0];
TextEdit changeEdit = childChange.getEdit();
assertEquals(2, changeEdit.getChildrenSize());
}
示例2: insertChange
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
/**
* Inserts a change at the specified index.
*
* @param change the change to insert
* @param insertIndex the index to insert at (if >= the number of children, it
* will be added to the end)
* @param parentChange the new parent of the change
*/
public static void insertChange(Change change, int insertIndex,
CompositeChange parentChange) {
Change[] changes = parentChange.getChildren();
if (insertIndex >= changes.length) {
parentChange.add(change);
} else {
// CompositeChange.clear does not clear the parent field on the removed
// changes, but CompositeChange.remove does
for (Change curChange : changes) {
parentChange.remove(curChange);
}
for (int i = 0; i < changes.length; i++) {
if (i == insertIndex) {
parentChange.add(change);
}
parentChange.add(changes[i]);
}
}
}
示例3: createChange
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
public Change createChange(IProgressMonitor pm) throws CoreException {
CompositeChange change = new CompositeChange("Umlet");
for (UmletRefactoringProcessor processor : processors) {
List<? extends Change> changes = processor.createChange(pm);
if (changes != null) {
change.addAll(changes.toArray(new Change[] {}));
}
}
change.addAll(additionalChanges.toArray(new Change[] {}));
if (change.getChildren().length == 0) {
return null;
}
else {
return change;
}
}
示例4: apply
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
/**
* @return instance of {@link
* org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus}. That describes
* status of the refactoring operation.
*/
public RefactoringResult apply() {
PerformChangeOperation operation = new PerformChangeOperation(change);
FinishResult result = internalPerformFinish(operation);
if (result.isException()) {
return DtoConverter.toRefactoringResultDto(
RefactoringStatus.createErrorStatus("Refactoring failed with Exception."));
}
CompositeChange operationChange = (CompositeChange) operation.getUndoChange();
if (operationChange == null) {
return DtoConverter.toRefactoringResultDto(new RefactoringStatus());
}
Change[] changes = operationChange.getChildren();
RefactoringStatus validationStatus = operation.getValidationStatus();
if (validationStatus == null) {
return DtoConverter.toRefactoringResultDto(new RefactoringStatus());
}
List<ChangeInfo> changesInfo = new ArrayList<>();
prepareChangesInfo(changes, changesInfo);
RefactoringResult status = DtoConverter.toRefactoringResultDto(validationStatus);
status.setChanges(changesInfo);
return status;
}
示例5: doRename
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
/**
* Make rename operation.
*
* @param newName the name which will be applied
* @return result of the rename operation
* @throws CoreException if an error occurs while creating the refactoring instance
* @throws InvocationTargetException if an error occurred while executing the operation.
* @throws InterruptedException if the operation has been canceled by the user.
*/
public RefactoringResult doRename(String newName)
throws CoreException, InvocationTargetException, InterruptedException {
if (fOriginalName.equals(newName)) {
return DtoConverter.toRefactoringResultDto(new RefactoringStatus());
}
RenameSupport renameSupport = undoAndCreateRenameSupport(newName);
if (renameSupport == null)
return DtoConverter.toRefactoringResultDto(
RefactoringStatus.createFatalErrorStatus("Can't create rename refactoring"));
RefactoringResult refactoringResult =
DtoConverter.toRefactoringResultDto(renameSupport.perform());
PerformChangeOperation operation = renameSupport.getfPerformChangeOperation();
if (operation == null) {
return refactoringResult;
}
CompositeChange operationChange = (CompositeChange) operation.getUndoChange();
Change[] changes = operationChange.getChildren();
List<ChangeInfo> changesInfo = new ArrayList<>();
prepareChangesInfo(changes, changesInfo);
refactoringResult.setChanges(changesInfo);
return refactoringResult;
}
示例6: getFlattendedChildren
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
private void getFlattendedChildren(
List result, CompositeChangeNode parent, CompositeChange focus) {
Change[] changes = focus.getChildren();
for (int i = 0; i < changes.length; i++) {
Change change = changes[i];
if (fFilter == null || fFilter.select(change)) {
if (change instanceof CompositeChange && ((CompositeChange) change).isSynthetic()) {
getFlattendedChildren(result, parent, (CompositeChange) change);
} else {
result.add(createNode(parent, change));
}
}
}
}
示例7: acceptOnChange
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
/**
* Visits the given change and all its descendents.
*/
public static void acceptOnChange(Change change, ChangeVisitor visitor) {
if (change instanceof CompositeChange) {
CompositeChange compositeChange = (CompositeChange) change;
for (Change curChange : compositeChange.getChildren()) {
acceptOnChange(curChange, visitor);
}
}
visitor.visit(change);
}
示例8: removeChange
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
/**
* Removes a change and returns its old index, or -1 if it was not found.
*/
public static int removeChange(Change change, CompositeChange parentChange) {
Change[] changes = parentChange.getChildren();
for (int index = 0; index < changes.length; index++) {
if (changes[index] == change) {
parentChange.remove(change);
return index;
}
}
return -1;
}
示例9: createChangeFromMethodsToRefactor
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
private Change createChangeFromMethodsToRefactor() {
CompositeChange changes = new CompositeChange(
"GWT RPC paired method renames");
changes.markAsSynthetic();
// Traverse the methods to refactor and create a rename change for each
// Note: due to the recursive nature, this List could grow through each
// iteration
while (refactoringContext.toRefactorMethods.size() > 0) {
IMethod method = refactoringContext.toRefactorMethods.remove(0);
try {
// Call to JDT to get a change that renames this method
Change change = createChangeForMethodRename(method);
if (change != null) {
if (ChangeUtilities.mergeParticipantTextChanges(this, change)) {
// This change was completely merged into existing changes
continue;
}
// Walk through the created change tree and weave a change that, at
// perform-time, will update the text regions
ChangeUtilities.acceptOnChange(change,
new RegionUpdaterChangeWeavingVisitor(
new RenamedElementAstMatcher(pairedMethod.getElementName(),
newMethodName), new ReferenceUpdater()));
changes.add(change);
}
} catch (RefactoringException e) {
GWTPluginLog.logError("Could not rename method " + method);
// TODO: warn
}
}
return (changes.getChildren().length > 0) ? changes : null;
}
示例10: findFilesToBeModified
import org.eclipse.ltk.core.refactoring.CompositeChange; //导入方法依赖的package包/类
private void findFilesToBeModified(CompositeChange change, List<IResource> result) throws JavaModelException {
Change[] children= change.getChildren();
for (int i= 0; i < children.length; i++) {
Change child= children[i];
if (child instanceof CompositeChange) {
findFilesToBeModified((CompositeChange)child, result);
} else if (child instanceof MultiStateCompilationUnitChange) {
result.add(((MultiStateCompilationUnitChange)child).getCompilationUnit().getCorrespondingResource());
} else if (child instanceof CompilationUnitChange) {
result.add(((CompilationUnitChange)child).getCompilationUnit().getCorrespondingResource());
}
}
}