Java 类org.eclipse.jface.text.source.TextInvocationContext 实例源码

项目:DarwinSPL    文件:DwprofileQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HyexpressionQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HyvalidityformulaQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HydatavalueQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HymappingQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HyconstraintsQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:DarwinSPL    文件:HymanifestQuickAssistProcessor.java   
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer sourceViewer = invocationContext.getSourceViewer();
    int offset = -1;
    int length = 0;
    if (invocationContext instanceof TextInvocationContext) {
        TextInvocationContext textContext = (TextInvocationContext) invocationContext;
        offset = textContext.getOffset();
        length = textContext.getLength();
    }
    List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
    ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
    for (int i = 0; i < proposals.length; i++) {
        proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
    }
    return proposals;
}
项目:Eclipse-Postfix-Code-Completion    文件:WordQuickFixProcessor.java   
public IJavaCompletionProposal[] getCorrections(IInvocationContext invocationContext, IProblemLocation[] locations) throws CoreException {

        final int threshold= PreferenceConstants.getPreferenceStore().getInt(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);

        int size= 0;
        List<RankedWordProposal> proposals= null;
        String[] arguments= null;

        IProblemLocation location= null;
        RankedWordProposal proposal= null;
        IJavaCompletionProposal[] result= null;

        boolean fixed= false;
        boolean match= false;
        boolean sentence= false;

        final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
        final ISpellChecker checker= engine.getSpellChecker();

        if (checker != null) {

            for (int index= 0; index < locations.length; index++) {
                location= locations[index];

                ISourceViewer sourceViewer= null;
                if (invocationContext instanceof IQuickAssistInvocationContext)
                    sourceViewer= ((IQuickAssistInvocationContext)invocationContext).getSourceViewer();
                IQuickAssistInvocationContext context= new TextInvocationContext(sourceViewer, location.getOffset(), location.getLength());

                if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {

                    arguments= location.getProblemArguments();
                    if (arguments != null && arguments.length > 4) {

                        sentence= Boolean.valueOf(arguments[3]).booleanValue();
                        match= Boolean.valueOf(arguments[4]).booleanValue();
                        fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX;

                        if ((sentence && match) && !fixed)
                            result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
                        else {

                            proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
                            size= proposals.size();

                            if (threshold > 0 && size > threshold) {

                                Collections.sort(proposals);
                                proposals= proposals.subList(size - threshold - 1, size - 1);
                                size= proposals.size();
                            }

                            boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
                            result= new IJavaCompletionProposal[size + (extendable ? 3 : 2)];

                            for (index= 0; index < size; index++) {

                                proposal= proposals.get(index);
                                result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
                            }

                            if (extendable)
                                result[index++]= new AddWordProposal(arguments[0], context);

                            result[index++]= new WordIgnoreProposal(arguments[0], context);
                            result[index++]= new DisableSpellCheckingProposal(context);
                        }
                        break;
                    }
                }
            }
        }
        return result;
    }
项目:anatlyzer    文件:AnalysisQuickfixProcessor.java   
/** See: SpellingCorrectionProcessor (before was, XtextQuickAssistProcessor) */
    @Override
    public ICompletionProposal[] computeQuickAssistProposals(
            IQuickAssistInvocationContext invocationContext) {

        ISourceViewer viewer= invocationContext.getSourceViewer();
        int documentOffset= invocationContext.getOffset();

        int length= viewer != null ? viewer.getSelectedRange().y : -1;
        TextInvocationContext context= new TextInvocationContext(viewer, documentOffset, length);

        IAnnotationModel model = viewer.getAnnotationModel();
        if (model == null)
            return new ICompletionProposal[0]; 

        // From computeProposals
        int offset= context.getOffset();
        ArrayList<IMarker> annotationMarkers = new ArrayList<IMarker>();
        Iterator iter= model.getAnnotationIterator();
        while (iter.hasNext()) {
            Annotation annotation = (Annotation)iter.next();
            if (canFix(annotation)) {
                Position pos= model.getPosition(annotation);
                if (isAtPosition(offset, pos)) {
                    collectMarkers(annotation, annotationMarkers);
                }
            }
        }

        List<ICompletionProposal> allProposals = new ArrayList<ICompletionProposal>();
        LinkedList<List<ICompletionProposal>> sortedProposals = new LinkedList<List<ICompletionProposal>>();

        for (IMarker iMarker : annotationMarkers) {
            ICompletionProposal[] qfixes = getQuickfixes(iMarker);

//          if ( qfixes.length > 0 && annotationMarkers.size() > 1 ) {
//              // There are quick fixes for several kinds of errors
//              allProposals.add(new ProposalCategory(iMarker));
//          }
            List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(qfixes.length);

            if ( qfixes.length > 0 ) {
                proposals.add(new ProposalCategory(iMarker));
            }

            for (ICompletionProposal iCompletionProposal : qfixes) {
                proposals.add(iCompletionProposal);
            }

            sortedProposals.add(proposals);
        }
        sortedProposals.sort((l1, l2) -> -1 * Integer.compare(l1.size(), l2.size()));

        allProposals = sortedProposals.stream().flatMap(l -> l.stream()).collect(Collectors.toList());

        if ( allProposals.isEmpty() ) {
            // If there are no errors, then try the quick assist
            return computeQuickAssist(invocationContext, invocationContext.getOffset());
        } else {        
            return (ICompletionProposal[]) allProposals.toArray(new ICompletionProposal[allProposals.size()]);
        }
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:WordQuickFixProcessor.java   
public IJavaCompletionProposal[] getCorrections(IInvocationContext invocationContext, IProblemLocation[] locations) throws CoreException {

        final int threshold= PreferenceConstants.getPreferenceStore().getInt(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);

        int size= 0;
        List<RankedWordProposal> proposals= null;
        String[] arguments= null;

        IProblemLocation location= null;
        RankedWordProposal proposal= null;
        IJavaCompletionProposal[] result= null;

        boolean fixed= false;
        boolean match= false;
        boolean sentence= false;

        final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
        final ISpellChecker checker= engine.getSpellChecker();

        if (checker != null) {

            for (int index= 0; index < locations.length; index++) {
                location= locations[index];

                ISourceViewer sourceViewer= null;
                if (invocationContext instanceof IQuickAssistInvocationContext)
                    sourceViewer= ((IQuickAssistInvocationContext)invocationContext).getSourceViewer();
                IQuickAssistInvocationContext context= new TextInvocationContext(sourceViewer, location.getOffset(), location.getLength());

                if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {

                    arguments= location.getProblemArguments();
                    if (arguments != null && arguments.length > 4) {

                        sentence= Boolean.valueOf(arguments[3]).booleanValue();
                        match= Boolean.valueOf(arguments[4]).booleanValue();
                        fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX;

                        if ((sentence && match) && !fixed)
                            result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
                        else {

                            proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
                            size= proposals.size();

                            if (threshold > 0 && size > threshold) {

                                Collections.sort(proposals);
                                proposals= proposals.subList(size - threshold - 1, size - 1);
                                size= proposals.size();
                            }

                            boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
                            result= new IJavaCompletionProposal[size + (extendable ? 3 : 2)];

                            for (index= 0; index < size; index++) {

                                proposal= proposals.get(index);
                                result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
                            }

                            if (extendable)
                                result[index++]= new AddWordProposal(arguments[0], context);

                            result[index++]= new WordIgnoreProposal(arguments[0], context);
                            result[index++]= new DisableSpellCheckingProposal(context);
                        }
                        break;
                    }
                }
            }
        }
        return result;
    }