Search in sources :

Example 1 with QuickFixRegistry

use of org.eclipse.wst.sse.ui.internal.correction.QuickFixRegistry in project jbosstools-base by jbosstools.

the class MarkerAnnotationInfo method getProposals.

private List<ICompletionProposal> getProposals(TemporaryAnnotation annotation, Position position) {
    List<ICompletionProposal> allProposals = new ArrayList<ICompletionProposal>();
    List<IQuickAssistProcessor> processors = new ArrayList<IQuickAssistProcessor>();
    boolean isJBTAnnotation = isJBTAnnotation(annotation);
    // get all relevant quick fixes for this annotation
    if (QuickFixManager.getInstance().hasProposals(annotation, position)) {
        if (annotation.getText().startsWith(UNKNOWN_TAG) || annotation.getText().startsWith(MISSING_ATTRIBUTE)) {
            annotation.setAdditionalFixInfo(viewer.getDocument());
        }
        List<IJavaCompletionProposal> proposals = QuickFixManager.getInstance().getProposals(annotation, position);
        allProposals.addAll(proposals);
    }
    if (!isJBTAnnotation) {
        Object o = annotation.getAdditionalFixInfo();
        if (o instanceof IQuickAssistProcessor) {
            processors.add((IQuickAssistProcessor) o);
        }
        QuickFixRegistry registry = QuickFixRegistry.getInstance();
        processors.addAll(Arrays.asList(registry.getQuickFixProcessors(annotation)));
        // set up context
        Map attributes = annotation.getAttributes();
        StructuredTextInvocationContext sseContext = new StructuredTextInvocationContext(viewer, position.getOffset(), position.getLength(), attributes);
        ICompletionProposal[] compoundQuickAssistProcessorProposals = fCompoundQuickAssistProcessor.computeQuickAssistProposals(sseContext);
        if (compoundQuickAssistProcessorProposals != null) {
            for (ICompletionProposal proposal : compoundQuickAssistProcessorProposals) {
                allProposals.add(proposal);
            }
        }
        // call each processor
        for (int i = 0; i < processors.size(); ++i) {
            List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
            collectProposals((IQuickAssistProcessor) processors.get(i), annotation, sseContext, proposals);
            allProposals.addAll(proposals);
        }
    }
    return allProposals;
}
Also used : QuickFixRegistry(org.eclipse.wst.sse.ui.internal.correction.QuickFixRegistry) ArrayList(java.util.ArrayList) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal) IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) Map(java.util.Map) StructuredTextInvocationContext(org.eclipse.wst.sse.ui.StructuredTextInvocationContext)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 IJavaCompletionProposal (org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 IQuickAssistProcessor (org.eclipse.jface.text.quickassist.IQuickAssistProcessor)1 StructuredTextInvocationContext (org.eclipse.wst.sse.ui.StructuredTextInvocationContext)1 QuickFixRegistry (org.eclipse.wst.sse.ui.internal.correction.QuickFixRegistry)1