Search in sources :

Example 1 with CodeAssistCallback

use of org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback 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();
    }
}
Also used : CodeAssistCallback(org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback) CompletionsSource(org.eclipse.che.ide.api.editor.codeassist.CompletionsSource) CodeAssistProcessor(org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor) CompletionReadyCallback(org.eclipse.che.ide.api.editor.codeassist.CompletionReadyCallback) List(java.util.List)

Aggregations

List (java.util.List)1 CodeAssistCallback (org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback)1 CodeAssistProcessor (org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor)1 CompletionReadyCallback (org.eclipse.che.ide.api.editor.codeassist.CompletionReadyCallback)1 CompletionsSource (org.eclipse.che.ide.api.editor.codeassist.CompletionsSource)1