org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant Java Examples

The following examples show how to use org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GWTRefactoringSupportTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: GWTRefactoringSupportTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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());
}
 
Example #3
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>();
	for (int i= 0; i < fMoves.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status,
			owner, fMoves.get(i),
			(MoveArguments) fMoveArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #4
Source File: RenameModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>();
	for (int i= 0; i < fRename.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
			owner, fRename.get(i),
			(RenameArguments) fRenameArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #5
Source File: DeleteModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>();
	for (Iterator<IJavaElement> iter= fDelete.iterator(); iter.hasNext();) {
		result.addAll(Arrays.asList(ParticipantManager.loadDeleteParticipants(status,
			owner, iter.next(),
			new DeleteArguments(), natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #6
Source File: MoveStaticMembersProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
	List<MoveParticipant> result= new ArrayList<MoveParticipant>();
	MoveArguments args= new MoveArguments(fDestinationType, true);
	String[] natures= JavaProcessors.computeAffectedNaturs(fMembersToMove);
	for (int i= 0; i < fMembersToMove.length; i++) {
		IMember member= fMembersToMove[i];
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(
			status, this, member, args, natures, sharedParticipants)));
	}
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #7
Source File: ChangeUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Attempts to merge all the text changes rooted at <code>rootChange</code>
 * into the refactoring's shared text change for each file (via
 * {@link RefactoringParticipant#getTextChange(Object)}). Any text changes
 * that are merged will be removed from their parents.
 * 
 * 
 * @param participant the participant which will be used to get the shared
 *          text change for each file
 * @param rootChange the root of the change tree that will be searched for
 *          text changes to merge into the shared text changes
 * @return true if the entire tree was merged and the root change is no longer
 *         valid
 */
public static boolean mergeParticipantTextChanges(
    final RefactoringParticipant participant, Change rootChange) {
  final List<Change> dupChanges = new ArrayList<Change>();
  ChangeUtilities.acceptOnChange(rootChange, new ChangeVisitor() {
    public void visit(Change change) {
      if (change instanceof TextEditBasedChange) {
        TextEditBasedChange textChange = (TextEditBasedChange) change;
        TextChange existingTextChange = participant.getTextChange(textChange.getModifiedElement());
        if (existingTextChange == null) {
          return;
        }

        // Merge all changes from text change into the existing
        TextEditUtilities.moveTextEditGroupsIntoChange(
            textChange.getChangeGroups(), existingTextChange);

        dupChanges.add(textChange);
      }
    }
  });

  for (Change dupChange : dupChanges) {
    ChangeUtilities.removeChange(dupChange,
        (CompositeChange) dupChange.getParent());
  }

  return dupChanges.contains(rootChange);
}
 
Example #8
Source File: GWTRefactoringSupportTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public void testCreateChangeWithoutUpdateReferences() {
  GWTRefactoringSupport support = new DummyGWTRefactoringSupport();
  support.setUpdateReferences(false);

  // With update references turned off, Change returned should be null
  RefactoringParticipant participant = new DummyRefactoringParticipant();
  IRefactoringChangeFactory changeFactory = new DefaultChangeFactory();
  Change change = support.createChange(participant, changeFactory);
  assertNull(change);
}
 
Example #9
Source File: CopyModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<>();
	for (int i= 0; i < fCopies.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadCopyParticipants(status,
			owner, fCopies.get(i),
			(CopyArguments) fCopyArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #10
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) throws CoreException {
	RefactoringModifications modifications= getModifications();
	if (modifications != null) {
		return modifications.loadParticipants(status, processor, natures, shared);
	} else {
		return new RefactoringParticipant[0];
	}
}
 
Example #11
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) throws CoreException {
	RefactoringModifications modifications= getModifications();
	if (modifications != null) {
		return modifications.loadParticipants(status, processor, natures, shared);
	} else {
		return new RefactoringParticipant[0];
	}
}
 
Example #12
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<>();
	for (int i= 0; i < fMoves.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status,
			owner, fMoves.get(i),
			(MoveArguments) fMoveArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #13
Source File: CopyModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>();
	for (int i= 0; i < fCopies.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadCopyParticipants(status,
			owner, fCopies.get(i),
			(CopyArguments) fCopyArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #14
Source File: RenameModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) {
	List<RefactoringParticipant> result= new ArrayList<>();
	for (int i= 0; i < fRename.size(); i++) {
		result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
			owner, fRename.get(i),
			(RenameArguments) fRenameArguments.get(i),
			fParticipantDescriptorFilter.get(i),
			natures, shared)));
	}
	result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared)));
	return result.toArray(new RefactoringParticipant[result.size()]);
}
 
Example #15
Source File: CompositeRefactoringProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(final RefactoringStatus status,
		final SharableParticipants sharedParticipants) throws CoreException {
	List<RefactoringParticipant> participants = newArrayList();
	for (RefactoringProcessor processor : processors) {
		for (RefactoringParticipant participant : processor.loadParticipants(status, sharedParticipants)) {
			if (!(participant instanceof JdtRenameParticipant))
				participants.add(participant);
		}
	}
	return toArray(participants, RefactoringParticipant.class);
}
 
Example #16
Source File: CombinedJvmJdtRenameProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(final RefactoringStatus status,
		final SharableParticipants sharedParticipants) throws CoreException {
	List<RefactoringParticipant> participants = newArrayList(super.loadParticipants(status, sharedParticipants));
	for (JavaRenameProcessor processor : jvmElements2jdtProcessors.values()) {
		for (RefactoringParticipant participant : processor.loadParticipants(status, sharedParticipants)) {
			if(participant instanceof JdtRenameParticipant) {
				((JdtRenameParticipant) participant).disableFor(getElements());
			}
			participants.add(participant);
		}
	}
	return toArray(participants, RefactoringParticipant.class);
}
 
Example #17
Source File: RenameElementProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants)
		throws CoreException {
	RenameParticipant[] renameParticipants = ParticipantManager.loadRenameParticipants(status, this,
			renameElementContext, new RenameArguments(newName, true),
			new String[] { XtextProjectHelper.NATURE_ID }, sharedParticipants);
	return renameParticipants;
}
 
Example #18
Source File: PyRenameEntryPoint.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants)
        throws CoreException {
    return EMPTY_REFACTORING_PARTICIPANTS; // no participants are loaded
}
 
Example #19
Source File: JavaMoveProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException {
	return fMovePolicy.loadParticipants(status, this, getAffectedProjectNatures(), shared);
}
 
Example #20
Source File: JavaCopyProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
	RefactoringParticipant[] result= fCopyPolicy.loadParticipants(status, this, getAffectedProjectNatures(), sharedParticipants);
	fExecutionLog= fCopyPolicy.getReorgExecutionLog();
	return result;
}
 
Example #21
Source File: RenameElementProcessor2.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants)
		throws CoreException {
	return ParticipantManager.loadRenameParticipants(status, this, renameElementContext, new RenameArguments(newName, true),
			new String[] { XtextProjectHelper.NATURE_ID }, sharedParticipants);
}
 
Example #22
Source File: JavaDeleteProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException {
	return fDeleteModifications.loadParticipants(status, this, getAffectedProjectNatures(), shared);
}
 
Example #23
Source File: JavaRenameProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException {
	return fRenameModifications.loadParticipants(status, this, getAffectedProjectNatures(), shared);
}
 
Example #24
Source File: ChangeSignatureProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
	String[] affectedNatures= JavaProcessors.computeAffectedNatures(fMethod);
	return JavaParticipantManager.loadChangeMethodSignatureParticipants(status, this, fMethod, getParticipantArguments(), null, affectedNatures, sharedParticipants);
}
 
Example #25
Source File: ExtractInterfaceProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final RefactoringParticipant[] loadParticipants(final RefactoringStatus status, final SharableParticipants sharedParticipants) throws CoreException {
	return new RefactoringParticipant[0];
}
 
Example #26
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final RefactoringParticipant[] loadParticipants(final RefactoringStatus status, final SharableParticipants participants) throws CoreException {
	return new RefactoringParticipant[0];
}
 
Example #27
Source File: UseSuperTypeProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final RefactoringParticipant[] loadParticipants(final RefactoringStatus status, final SharableParticipants sharedParticipants) throws CoreException {
	return new RefactoringParticipant[0];
}
 
Example #28
Source File: HierarchyProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(final RefactoringStatus status, final SharableParticipants sharedParticipants) throws CoreException {
	return new RefactoringParticipant[0];
}
 
Example #29
Source File: TypeScriptRenameProcessor.java    From typescript.java with MIT License 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants)
		throws CoreException {
	return null;
}
 
Example #30
Source File: RenameRefactoringProcessor.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
		SharableParticipants sharedParticipants) throws CoreException {
	return new RefactoringParticipant[0];
}