org.eclipse.jface.text.contentassist.ICompletionProposalExtension Java Examples

The following examples show how to use org.eclipse.jface.text.contentassist.ICompletionProposalExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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());
}
 
Example #2
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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());
}
 
Example #3
Source File: CompletionProposalPopup.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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;
}