Search in sources :

Example 6 with IQuickAssistProcessor

use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project webtools.sourceediting by eclipse.

the class CompoundQuickAssistProcessor method computeQuickAssistProposals.

public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    List proposalsList = new ArrayList();
    // first get list of fixes
    IQuickAssistProcessor processor = getQuickFixProcessor();
    ICompletionProposal[] proposals = processor.computeQuickAssistProposals(invocationContext);
    if (proposals != null && proposals.length > 0) {
        proposalsList.addAll(Arrays.asList(proposals));
    }
    // no fixes, so try adding assists
    if (proposalsList.isEmpty()) {
        Set processors = getQuickAssistProcessors(invocationContext);
        if (processors != null) {
            // canAssist
            for (Iterator it = processors.iterator(); it.hasNext(); ) {
                IQuickAssistProcessor assistProcessor = (IQuickAssistProcessor) it.next();
                ICompletionProposal[] assistProposals = assistProcessor.computeQuickAssistProposals(invocationContext);
                if (assistProposals != null && assistProposals.length > 0) {
                    proposalsList.addAll(Arrays.asList(assistProposals));
                }
            }
        }
    }
    /*
		 * Java editor currently returns a no modification completion proposal
		 * but it seems better to just return null so user does not get
		 * annoying proposal popup
		 */
    if (proposalsList.isEmpty()) {
        // proposalsList.add(new NoModificationCompletionProposal());
        return null;
    }
    return (ICompletionProposal[]) proposalsList.toArray(new ICompletionProposal[proposalsList.size()]);
}
Also used : IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with IQuickAssistProcessor

use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project eclipse.platform.text by eclipse.

the class CompositeQuickAssistProcessor method getErrorMessage.

@Override
public String getErrorMessage() {
    StringBuilder res = new StringBuilder();
    for (IQuickAssistProcessor processor : this.fProcessors) {
        String errorMessage = processor.getErrorMessage();
        if (errorMessage != null) {
            res.append(errorMessage);
            res.append('\n');
        }
    }
    if (res.length() == 0) {
        return null;
    }
    return res.toString();
}
Also used : IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor)

Example 8 with IQuickAssistProcessor

use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project webtools.sourceediting by eclipse.

the class CompoundQuickAssistProcessor method getQuickAssistProcessors.

private Set getQuickAssistProcessors(String partitionType) {
    if (fInstalledExtendedContentTypes == null || !fInstalledExtendedContentTypes.contains(partitionType)) {
        // get extended quick assist processors that have not already
        // been set
        List processors = ExtendedConfigurationBuilder.getInstance().getConfigurations(QUICK_ASSIST_PROCESSOR_EXTENDED_ID, partitionType);
        if (processors != null && !processors.isEmpty()) {
            Iterator iter = processors.iterator();
            while (iter.hasNext()) {
                IQuickAssistProcessor processor = (IQuickAssistProcessor) iter.next();
                setQuickAssistProcessor(partitionType, processor);
            }
        }
        // up every time)
        if (fInstalledExtendedContentTypes == null)
            fInstalledExtendedContentTypes = new ArrayList();
        fInstalledExtendedContentTypes.add(partitionType);
    }
    Set processors = null;
    if (fProcessors != null)
        processors = (Set) fProcessors.get(partitionType);
    return processors;
}
Also used : IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

IQuickAssistProcessor (org.eclipse.jface.text.quickassist.IQuickAssistProcessor)8 Iterator (java.util.Iterator)5 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 QuickAssistAssistant (org.eclipse.jface.text.quickassist.QuickAssistAssistant)2 Annotation (org.eclipse.jface.text.source.Annotation)2 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)2 TextInvocationContext (org.eclipse.jface.text.source.TextInvocationContext)2 XtextSourceViewer (org.eclipse.xtext.ui.editor.XtextSourceViewer)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 Position (org.eclipse.jface.text.Position)1 IQuickAssistInvocationContext (org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext)1 IQuickFixableAnnotation (org.eclipse.jface.text.quickassist.IQuickFixableAnnotation)1