Java Code Examples for org.eclipse.xtext.ide.editor.contentassist.antlr.ContentAssistContextFactory#setPool()

The following examples show how to use org.eclipse.xtext.ide.editor.contentassist.antlr.ContentAssistContextFactory#setPool() . 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: XContentAssistService.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a single proposal.
 */
protected void createProposals(String document, TextRegion selection, int caretOffset,
		XtextResource resource, IIdeContentProposalAcceptor acceptor) {
	if (caretOffset > document.length()) {
		return;
	}
	ContentAssistContextFactory contextFactory = contextFactoryProvider.get();
	contextFactory.setPool(executorService);
	ContentAssistContext[] contexts = contextFactory.create(document, selection, caretOffset, resource);
	proposalProvider.createProposals(Arrays.asList(contexts), acceptor);
}
 
Example 2
Source File: ContentAssistService.java    From xtext-web with Eclipse Public License 2.0 5 votes vote down vote up
public ContentAssistContext[] getContexts(IXtextWebDocument document, ITextRegion selection, int caretOffset) {
	if (caretOffset > document.getText().length()) {
		return new ContentAssistContext[] {};
	}
	ContentAssistContextFactory contextFactory = contextFactoryProvider.get();
	contextFactory.setPool(executorService);
	return contextFactory.create(document.getText(), selection, caretOffset, document.getResource());
}
 
Example 3
Source File: ContentAssistContextTestHelper.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public String firstSetGrammarElementsToString(final ContentAssistContextFactory factory) {
  final int offset = this.document.indexOf(this.cursor);
  Preconditions.checkArgument((offset >= 0), "you forgot to provide a cursor");
  final String doc = this.document.replace(this.cursor, "");
  final XtextResource res = this.parse(doc);
  factory.setPool(Executors.newCachedThreadPool());
  TextRegion _textRegion = new TextRegion(0, 0);
  final ContentAssistContext[] ctxs = factory.create(doc, _textRegion, offset, res);
  final GrammarElementTitleSwitch f = new GrammarElementTitleSwitch().showAssignments().showQualified().showRule();
  StringConcatenation _builder = new StringConcatenation();
  {
    Iterable<Pair<Integer, ContentAssistContext>> _indexed = IterableExtensions.<ContentAssistContext>indexed(((Iterable<? extends ContentAssistContext>)Conversions.doWrapArray(ctxs)));
    for(final Pair<Integer, ContentAssistContext> ctx : _indexed) {
      _builder.append("context");
      Integer _key = ctx.getKey();
      _builder.append(_key);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      {
        ImmutableList<AbstractElement> _firstSetGrammarElements = ctx.getValue().getFirstSetGrammarElements();
        for(final AbstractElement ele : _firstSetGrammarElements) {
          _builder.append("\t");
          String _name = ele.eClass().getName();
          _builder.append(_name, "\t");
          _builder.append(": ");
          String _apply = f.apply(ele);
          _builder.append(_apply, "\t");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("}");
      _builder.newLine();
    }
  }
  return _builder.toString();
}
 
Example 4
Source File: ContentAssistService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected void createProposals(String document, TextRegion selection, int caretOffset, XtextResource resource,
		IIdeContentProposalAcceptor acceptor) {
	if (caretOffset > document.length()) {
		return;
	}
	ContentAssistContextFactory contextFactory = contextFactoryProvider.get();
	contextFactory.setPool(executorService);
	ContentAssistContext[] contexts = contextFactory.create(document, selection, caretOffset, resource);
	proposalProvider.createProposals(Arrays.asList(contexts), acceptor);
}