use of org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalAcceptor in project xtext-core by eclipse.
the class ContentAssistService method createCompletionList.
public CompletionList createCompletionList(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
try {
final CompletionList result = new CompletionList();
result.setIsIncomplete(true);
final IdeContentProposalAcceptor acceptor = this.proposalAcceptorProvider.get();
final int caretOffset = document.getOffSet(params.getPosition());
final Position caretPosition = params.getPosition();
final TextRegion position = new TextRegion(caretOffset, 0);
try {
this.createProposals(document.getContents(), position, caretOffset, resource, acceptor);
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable t = (Throwable) _t;
boolean _isOperationCanceledException = this.operationCanceledManager.isOperationCanceledException(t);
boolean _not = (!_isOperationCanceledException);
if (_not) {
throw t;
}
} else {
throw Exceptions.sneakyThrow(_t);
}
}
final Procedure2<ContentAssistEntry, Integer> _function = (ContentAssistEntry it, Integer idx) -> {
final CompletionItem item = this.toCompletionItem(it, caretOffset, caretPosition, document);
item.setSortText(Strings.padStart(Integer.toString((idx).intValue()), 5, '0'));
List<CompletionItem> _items = result.getItems();
_items.add(item);
};
IterableExtensions.<ContentAssistEntry>forEach(acceptor.getEntries(), _function);
return result;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations