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

下面列出了怎么用org.eclipse.jface.text.contentassist.ICompletionProposalExtension的API类实例代码及写法,或者点击链接到github查看源代码。

protected ContentAssistProcessorTestBuilder appendAndApplyProposal(ICompletionProposal proposal, ISourceViewer sourceViewer, String model, int position)
		throws Exception {
	IDocument document = sourceViewer.getDocument();
	int offset = position;
	if (model != null) {
		document.set(getModel() + model);
		offset += model.length();
	}
	if (proposal instanceof ICompletionProposalExtension2) {
		ICompletionProposalExtension2 proposalExtension2 = (ICompletionProposalExtension2) proposal;
		proposalExtension2.apply(sourceViewer, (char) 0, SWT.NONE, offset);	
	} else if (proposal instanceof ICompletionProposalExtension) {
		ICompletionProposalExtension proposalExtension = (ICompletionProposalExtension) proposal;
		proposalExtension.apply(document, (char) 0, offset);	
	} else  {
		proposal.apply(document);
	}
	return reset().append(document.get());
}
 
protected ContentAssistProcessorTestBuilder appendAndApplyProposal(ICompletionProposal proposal, ISourceViewer sourceViewer, String model, int position)
		throws Exception {
	IDocument document = sourceViewer.getDocument();
	int offset = position;
	if (model != null) {
		document.set(getModel() + model);
		offset += model.length();
	}
	if (proposal instanceof ICompletionProposalExtension2) {
		ICompletionProposalExtension2 proposalExtension2 = (ICompletionProposalExtension2) proposal;
		proposalExtension2.apply(sourceViewer, (char) 0, SWT.NONE, offset);	
	} else if (proposal instanceof ICompletionProposalExtension) {
		ICompletionProposalExtension proposalExtension = (ICompletionProposalExtension) proposal;
		proposalExtension.apply(document, (char) 0, offset);	
	} else  {
		proposal.apply(document);
	}
	return reset().append(document.get());
}
 
源代码3 项目: 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;
}
 
 类所在包
 类方法
 同包方法