Java Code Examples for org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals()

The following examples show how to use org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals() . 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: CompletionProposalPopup.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the completion proposal available at the given offset of the viewer's document. Delegates the work to the
 * code assistant.
 * 
 * @param offset
 *            the offset
 * @param autoActivated
 * @return the completion proposals available at this offset
 */
private ICompletionProposal[] computeProposals(int offset, boolean autoActivated)
{
	if (fContentAssistSubjectControl != null)
	{
		return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, offset, fActivationKey);
	}
    IContentAssistProcessor processor = fContentAssistant.getProcessor(fViewer, offset);
    if (processor == null) {
    	 return null;
    }
    if (processor instanceof ICommonContentAssistProcessor) {
         ICommonContentAssistProcessor commonProcessor = (ICommonContentAssistProcessor)processor;
         return commonProcessor.computeCompletionProposals(fViewer, offset, fActivationKey, autoActivated);
    } else {
         return processor.computeCompletionProposals(fViewer, offset);
    }
}
 
Example 2
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer, cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
Example 3
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer, cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
Example 4
Source File: SourceCodeAssistProcessor.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected void doComputeCompletionProposals(T context, List<ICompletionProposal> completionProposals) {
   	for (IContentAssistProcessor contentAssistProcessor : contentAssistProcessors) {
   		if (contentAssistProcessor instanceof ICompletionContextUser) {
   			((ICompletionContextUser<T>)contentAssistProcessor).setCompletionContext(context);
   		}
   		ICompletionProposal[] cp = contentAssistProcessor.computeCompletionProposals(context.getViewer(), context.getOffset());
   		CollectionUtils.addAll(completionProposals, cp);
   	}
   }
 
Example 5
Source File: DotProposalProviderDelegator.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private ICompletionProposal[] computeCompletionProposals(
		final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration,
		ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration
			.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant
			.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer,
				cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
Example 6
Source File: DirtyEditorFilteringContentAssistTests.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public ICompletionProposal[] computeCompletionProposals(final XtextEditor editorForCompletion, final XtextEditor dirtyEditor, final int cursorPosition) throws BadLocationException {
  this.syncUtil.waitForReconciler(dirtyEditor);
  final ISourceViewer sourceViewer = editorForCompletion.getInternalSourceViewer();
  final IContentAssistant contentAssistant = editorForCompletion.getXtextSourceViewerConfiguration().getContentAssistant(sourceViewer);
  final String contentType = editorForCompletion.getDocument().getContentType(cursorPosition);
  final IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
  if ((processor != null)) {
    return processor.computeCompletionProposals(sourceViewer, cursorPosition);
  }
  return null;
}
 
Example 7
Source File: ContentAssistant.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an array of completion proposals computed based on the specified document position. The position is used
 * to determine the appropriate code assist processor to invoke.
 * 
 * @param viewer
 *            the viewer for which to compute the proposals
 * @param offset
 *            a document offset
 * @param autoActivated
 *            determines whether we were autoActivated or not
 * @return an array of completion proposals
 * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
 */
ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset, char activationChar,
		boolean autoActivated)
{
	fLastErrorMessage = null;
	fUserAgentColumnCount = 0;

	ICompletionProposal[] result = null;
	IContentAssistProcessor processor = this.getProcessor(viewer, offset);

	if (processor != null)
	{
		if (processor instanceof ICommonContentAssistProcessor)
		{
			ICommonContentAssistProcessor commonProcessor = (ICommonContentAssistProcessor) processor;

			result = commonProcessor.computeCompletionProposals(viewer, offset, activationChar, autoActivated);

			String[] ids = ((ICommonContentAssistProcessor) processor).getActiveUserAgentIds();

			fUserAgentColumnCount = (ids != null) ? ids.length : 0;
		}
		else
		{
			result = processor.computeCompletionProposals(viewer, offset);
		}

		fLastErrorMessage = processor.getErrorMessage();
	}

	return result;
}