Java 类org.eclipse.jface.text.contentassist.ICompletionProposalExtension 实例源码

项目:APICloud-Studio    文件:CompletionProposalPopup.java   
/**
 * Computes the subset of already computed proposals that are still valid for the given offset.
 * 
 * @param offset
 *            the offset
 * @param event
 *            the merged document event
 * @return the set of filtered proposals
 * @since 3.0
 */
private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event)
{

    if (offset == fInvocationOffset && event == null)
    {
        fIsFilteredSubset = false;
        return fComputedProposals;
    }
    IDocument document = fContentAssistSubjectControlAdapter.getDocument();
    // this does go through the array twice (once to figure out if it's okay to use the else case, and the second
    // time to actual filter the proposals, but it is what the original logic suggests
    if ((offset < fInvocationOffset) || ((event != null) && (event.fText.startsWith("("))))
    {
        fIsFilteredSubset = false;
        fInvocationOffset = offset;
        fComputedProposals = computeProposals(fInvocationOffset, false);
        fComputedProposals = filterProposals(fComputedProposals, document, fInvocationOffset, event);
        return fComputedProposals;
    }

    ICompletionProposal[] proposals;
    if (offset < fFilterOffset)
    {
        proposals = fComputedProposals;
        fIsFilteredSubset = false;
    }
    else
    {
        proposals = fFilteredProposals;
        fIsFilteredSubset = true;
    }

    if (proposals == null)
    {
        fIsFilteredSubset = false;
        return null;
    }

    for (int i = 0; i < proposals.length; i++)
    {
        ICompletionProposal proposal = proposals[i];
        if ((proposal instanceof ICompletionProposalExtension2)
                || (proposal instanceof ICompletionProposalExtension))
        {
            continue;
        }
        fIsFilteredSubset = false;
        fInvocationOffset = offset;
        fComputedProposals = computeProposals(fInvocationOffset, false);

        return fComputedProposals;
    }

    ICompletionProposal[] filtered = filterProposals(proposals, document, offset, event);
    return filtered;
}