当前位置: 首页>>代码示例>>Java>>正文


Java CompositeChange类代码示例

本文整理汇总了Java中org.eclipse.ltk.core.refactoring.CompositeChange的典型用法代码示例。如果您正苦于以下问题:Java CompositeChange类的具体用法?Java CompositeChange怎么用?Java CompositeChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompositeChange类属于org.eclipse.ltk.core.refactoring包,在下文中一共展示了CompositeChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public Change createChange(IProgressMonitor monitor) throws CoreException,
		OperationCanceledException {
	try {
		monitor.beginTask(
				Messages.ConvertConstantsToEnumRefactoring_CreatingChange,
				1);
		final Collection changes = this.changes.values();
		final CompositeChange change = new CompositeChange(this.getName(),
				(Change[]) changes.toArray(new Change[changes.size()])) {
			public ChangeDescriptor getDescriptor() {
				String project = ConvertConstantsToEnumRefactoring.this
						.getJavaProject().getElementName();
				String description = Messages.ConvertConstantsToEnum_Name;
				Map arguments = new HashMap();
				return new RefactoringChangeDescriptor(
						new ConvertConstantsToEnumDescriptor(project,
								description, new String(), arguments));
			}
		};
		return change;
	} finally {
		monitor.done();
	}
}
 
开发者ID:ponder-lab,项目名称:Constants-to-Enum-Eclipse-Plugin,代码行数:25,代码来源:ConvertConstantsToEnumRefactoring.java

示例2: postCreateChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
@Override
public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm)
    throws CoreException {
  if (fQualifiedNameSearchResult != null) {
    CompositeChange parent = (CompositeChange) fRenamePackageChange.getParent();
    try {
      /*
       * Sneak text changes in before the package rename to ensure
       * modified files are still at original location (see
       * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154238)
       */
      parent.remove(fRenamePackageChange);
      parent.add(
          fQualifiedNameSearchResult.getSingleChange(
              Changes.getModifiedFiles(participantChanges)));
    } finally {
      fQualifiedNameSearchResult = null;
      parent.add(fRenamePackageChange);
      fRenamePackageChange = null;
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:RenamePackageProcessor.java

示例3: createChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
  IFile[] file = getFiles();
  IFolder[] folders = getFolders();
  ICompilationUnit[] cus = getCus();
  pm.beginTask("", cus.length + file.length + folders.length); // $NON-NLS-1$
  NewNameProposer nameProposer = new NewNameProposer();
  CompositeChange composite =
      new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy);
  composite.markAsSynthetic();
  for (int i = 0; i < cus.length; i++) {
    composite.add(createChange(cus[i], nameProposer, copyQueries));
    pm.worked(1);
  }
  if (pm.isCanceled()) throw new OperationCanceledException();
  for (int i = 0; i < file.length; i++) {
    composite.add(createChange(file[i], nameProposer, copyQueries));
    pm.worked(1);
  }
  if (pm.isCanceled()) throw new OperationCanceledException();
  for (int i = 0; i < folders.length; i++) {
    composite.add(createChange(folders[i], nameProposer, copyQueries));
    pm.worked(1);
  }
  pm.done();
  return composite;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:ReorgPolicyFactory.java

示例4: createSimpleMoveChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
private Change createSimpleMoveChange(IProgressMonitor pm) {
  CompositeChange result =
      new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
  result.markAsSynthetic();
  IFile[] files = getFiles();
  IFolder[] folders = getFolders();
  ICompilationUnit[] cus = getCus();
  pm.beginTask("", files.length + folders.length + cus.length); // $NON-NLS-1$
  for (int i = 0; i < files.length; i++) {
    result.add(createChange(files[i]));
    pm.worked(1);
  }
  if (pm.isCanceled()) throw new OperationCanceledException();
  for (int i = 0; i < folders.length; i++) {
    result.add(createChange(folders[i]));
    pm.worked(1);
  }
  if (pm.isCanceled()) throw new OperationCanceledException();
  for (int i = 0; i < cus.length; i++) {
    result.add(createChange(cus[i]));
    pm.worked(1);
  }
  pm.done();
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ReorgPolicyFactory.java

示例5: createPackageFragmentRootDeleteChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
private static Change createPackageFragmentRootDeleteChange(IPackageFragmentRoot root)
    throws JavaModelException {
  IResource resource = root.getResource();
  if (resource != null && resource.isLinked()) {
    // XXX using this code is a workaround for jcore bug 31998
    // jcore cannot handle linked stuff
    // normally, we should always create DeletePackageFragmentRootChange
    CompositeChange composite =
        new DynamicValidationStateChange(
            RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);

    ClasspathChange change =
        ClasspathChange.removeEntryChange(root.getJavaProject(), root.getRawClasspathEntry());
    if (change != null) {
      composite.add(change);
    }
    Assert.isTrue(!Checks.isClasspathDelete(root)); // checked in preconditions
    composite.add(createDeleteChange(resource));

    return composite;
  } else {
    Assert.isTrue(!root.isExternal());
    // TODO remove the query argument
    return new DeletePackageFragmentRootChange(root, true, null);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:DeleteChangeCreator.java

示例6: getSingleChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public Change getSingleChange(IFile[] alreadyTouchedFiles) {
  Collection<TextChange> values = fChanges.values();
  if (values.size() == 0) return null;

  CompositeChange result =
      new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name);
  result.markAsSynthetic();
  List<IFile> files = Arrays.asList(alreadyTouchedFiles);
  for (Iterator<TextChange> iter = values.iterator(); iter.hasNext(); ) {
    TextFileChange change = (TextFileChange) iter.next();
    if (!files.contains(change.getFile())) {
      result.add(change);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:QualifiedNameSearchResult.java

示例7: getChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public TextFileChange getChange(IFile file) throws CoreException {
  final SelfEncapsulateFieldRefactoring refactoring =
      new SelfEncapsulateFieldRefactoring(fField);
  refactoring.setVisibility(Flags.AccPublic);
  refactoring.setConsiderVisibility(
      false); // private field references are just searched in local file
  refactoring.checkInitialConditions(new NullProgressMonitor());
  refactoring.checkFinalConditions(new NullProgressMonitor());
  Change createdChange = refactoring.createChange(new NullProgressMonitor());
  if (createdChange instanceof CompositeChange) {
    Change[] children = ((CompositeChange) createdChange).getChildren();
    for (int i = 0; i < children.length; i++) {
      Change curr = children[i];
      if (curr instanceof TextFileChange && ((TextFileChange) curr).getFile().equals(file)) {
        return (TextFileChange) curr;
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:GetterSetterCorrectionSubProcessor.java

示例8: createChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public Change createChange(IProgressMonitor pm) throws CoreException {
  pm.beginTask("", fResourcesToMove.length); // $NON-NLS-1$
  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();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:MoveResourcesProcessor.java

示例9: createChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
  pm.beginTask(RefactoringCoreMessages.DeleteResourcesProcessor_create_task, fResources.length);
  try {
    RefactoringChangeDescriptor descriptor = new RefactoringChangeDescriptor(createDescriptor());
    CompositeChange change =
        new CompositeChange(RefactoringCoreMessages.DeleteResourcesProcessor_change_name);
    change.markAsSynthetic();
    for (int i = 0; i < fResources.length; i++) {
      pm.worked(1);
      DeleteResourceChange dc =
          new DeleteResourceChange(fResources[i].getFullPath(), true, fDeleteContents);
      dc.setDescriptor(descriptor);
      change.add(dc);
    }
    return change;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:DeleteResourcesProcessor.java

示例10: addToTextChangeMap

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
private void addToTextChangeMap(Change change) {
  if (change instanceof TextChange) {
    Object element = ((TextChange) change).getModifiedElement();
    if (element != null) {
      fTextChangeMap.put(element, change);
    }
    // check if we have a subclass of TextFileChange. If so also put the 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]);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ProcessorBasedRefactoring.java

示例11: 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());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:GWTRefactoringSupportTest.java

示例12: testCreateChangeWithoutEdits

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
public void testCreateChangeWithoutEdits() throws JavaModelException {
  GWTRefactoringSupport support = new DummyGWTRefactoringSupport();
  support.setUpdateReferences(true);

  IType entryPointType = getTestProject().findType(
      AbstractGWTPluginTestCase.TEST_PROJECT_SRC_PACKAGE,
      AbstractGWTPluginTestCase.TEST_PROJECT_ENTRY_POINT);
  support.setOldElement(entryPointType);

  // There are no references to the entry point class, so the Change returned
  // should be null
  RefactoringParticipant participant = new DummyRefactoringParticipant();
  IRefactoringChangeFactory changeFactory = new DefaultChangeFactory();
  CompositeChange change = support.createChange(participant, changeFactory);
  assertNull(change);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:17,代码来源:GWTRefactoringSupportTest.java

示例13: 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]);
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:30,代码来源:ChangeUtilities.java

示例14: replaceChange

import org.eclipse.ltk.core.refactoring.CompositeChange; //导入依赖的package包/类
/**
 * Replaces a change with another change created by the given factory.
 * 
 * @param originalChange the original change that will be replaced in its
 *          hierarchy (no children will be copied)
 * @param replacementChangeFactory the factory that creates the replacement
 *          change
 * @return true if a replacement occurred
 */
public static boolean replaceChange(Change originalChange,
    ReplacementChangeFactory replacementChangeFactory) {
  // The old change must not have a parent when we wrap it
  Change parentChange = originalChange.getParent();
  if (parentChange == null || !(parentChange instanceof CompositeChange)) {
    return false;
  }

  int oldIndex = ChangeUtilities.removeChange(originalChange,
      (CompositeChange) parentChange);
  if (oldIndex == -1) {
    return false;
  }

  Change newChange = replacementChangeFactory.createChange(originalChange);
  if (newChange == null) {
    return false;
  }

  ChangeUtilities.insertChange(newChange, oldIndex,
      (CompositeChange) parentChange);

  return true;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:34,代码来源:ChangeUtilities.java

示例15: 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;
	}
}
 
开发者ID:umlet,项目名称:umlet,代码行数:18,代码来源:UmletRefactoringProcessorManager.java


注:本文中的org.eclipse.ltk.core.refactoring.CompositeChange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。