Search in sources :

Example 1 with ParticipantDescriptor

use of org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor in project che by eclipse.

the class ParticipantExtensionPoint method getParticipants.

/**
	 * Returns all participants for a given element.
	 *
	 * @param status a refactoring status to report status if problems occurred while
	 *  loading the participants
	 * @param processor the processor that will own the participants
	 * @param element the element to be copied or a corresponding descriptor
	 * @param arguments the arguments for the participants
	 * @param filter a participant filter to exclude certain participants, or <code>null</code>
	 *  if no filtering is desired
	 * @param affectedNatures an array of project natures affected by the refactoring
	 * @param shared a list of shared participants
	 *
	 * @return an array of participants
	 */
public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, Object element, RefactoringArguments arguments, IParticipantDescriptorFilter filter, String[] affectedNatures, SharableParticipants shared) {
    if (fParticipants == null)
        init();
    EvaluationContext evalContext = createEvaluationContext(processor, element, affectedNatures);
    List result = new ArrayList();
    for (Iterator iter = fParticipants.iterator(); iter.hasNext(); ) {
        ParticipantDescriptor descriptor = (ParticipantDescriptor) iter.next();
        if (!descriptor.isEnabled()) {
            iter.remove();
        } else {
            try {
                RefactoringStatus filterStatus = new RefactoringStatus();
                if (descriptor.matches(evalContext, filter, filterStatus)) {
                    RefactoringParticipant participant = shared.get(descriptor);
                    if (participant != null) {
                        ((ISharableParticipant) participant).addElement(element, arguments);
                    } else {
                        participant = descriptor.createParticipant();
                        if (fParticipantClass.isInstance(participant)) {
                            if (participant.initialize(processor, element, arguments)) {
                                participant.setDescriptor(descriptor);
                                result.add(participant);
                                if (participant instanceof ISharableParticipant)
                                    shared.put(descriptor, participant);
                            }
                        } else {
                            status.addError(Messages.format(RefactoringCoreMessages.ParticipantExtensionPoint_participant_removed, descriptor.getName()));
                            RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.ParticipantExtensionPoint_wrong_type, new String[] { descriptor.getName(), fParticipantClass.getName() }));
                            iter.remove();
                        }
                    }
                } else {
                    status.merge(filterStatus);
                }
            } catch (CoreException e) {
                logMalfunctioningParticipant(status, descriptor, e);
                iter.remove();
            } catch (RuntimeException e) {
                logMalfunctioningParticipant(status, descriptor, e);
                iter.remove();
            }
        }
    }
    return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
}
Also used : ParticipantDescriptor(org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ArrayList(java.util.ArrayList) List(java.util.List) EvaluationContext(org.eclipse.core.expressions.EvaluationContext)

Example 2 with ParticipantDescriptor

use of org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor in project che by eclipse.

the class ParticipantExtensionPoint method init.

private void init() {
    //		IExtensionRegistry registry= Platform.getExtensionRegistry();
    //		IConfigurationElement[] ces= new IConfigurationElement[0];//registry.getConfigurationElementsFor(fPluginId, fParticipantID);
    Set<Class<? extends RefactoringParticipant>> ces = CheRefactoringParticipantsRegistry.getParticipantsFor(fParticipantID);
    fParticipants = new ArrayList(ces.size());
    for (Class<? extends RefactoringParticipant> clazz : ces) {
        ParticipantDescriptor descriptor = new ParticipantDescriptor(clazz);
        IStatus status = descriptor.checkSyntax();
        switch(status.getSeverity()) {
            case IStatus.ERROR:
                RefactoringCorePlugin.log(status);
                break;
            case IStatus.WARNING:
            case IStatus.INFO:
                RefactoringCorePlugin.log(status);
                fParticipants.add(descriptor);
                break;
            default:
                fParticipants.add(descriptor);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ParticipantDescriptor(org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor) ArrayList(java.util.ArrayList)

Example 3 with ParticipantDescriptor

use of org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor in project che by eclipse.

the class ProcessorBasedRefactoring method disableParticipant.

private static void disableParticipant(final RefactoringParticipant participant, Throwable e) {
    ParticipantDescriptor descriptor = participant.getDescriptor();
    descriptor.disable();
    RefactoringCorePlugin.logRemovedParticipant(descriptor, e);
}
Also used : ParticipantDescriptor(org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor)

Aggregations

ParticipantDescriptor (org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)1 List (java.util.List)1 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1