use of org.eclipse.che.ide.api.editor.codeassist.CompletionsSource in project che by eclipse.
the class OrionEditorInit method showCompletion.
/**
* Show the available completions.
*
* @param codeAssistant the code assistant
* @param triggered if triggered by the content assist key binding
*/
private void showCompletion(final CodeAssistant codeAssistant, final boolean triggered) {
final int cursor = textEditor.getCursorOffset();
if (cursor < 0) {
return;
}
final CodeAssistProcessor processor = codeAssistant.getProcessor(cursor);
if (processor != null) {
this.textEditor.showCompletionProposals(new CompletionsSource() {
@Override
public void computeCompletions(final CompletionReadyCallback callback) {
// cursor must be computed here again so it's original value is not baked in
// the SMI instance closure - important for completion update when typing
final int cursor = textEditor.getCursorOffset();
codeAssistant.computeCompletionProposals(cursor, triggered, new CodeAssistCallback() {
@Override
public void proposalComputed(final List<CompletionProposal> proposals) {
callback.onCompletionReady(proposals);
}
});
}
});
} else {
showCompletion();
}
}
Aggregations