Search in sources :

Example 1 with CompletionResponse

use of org.apache.zeppelin.interpreter.jupyter.proto.CompletionResponse in project zeppelin by apache.

the class JupyterKernelInterpreter method completion.

@Override
public List<InterpreterCompletion> completion(String buf, int cursor, InterpreterContext interpreterContext) {
    LOGGER.debug("Call completion for: {}, cursor: {}", buf, cursor);
    List<InterpreterCompletion> completions = new ArrayList<>();
    CompletionResponse response = jupyterKernelClient.complete(CompletionRequest.getDefaultInstance().newBuilder().setCode(buf).setCursor(cursor).build());
    for (int i = 0; i < response.getMatchesCount(); i++) {
        String match = response.getMatches(i);
        int lastIndexOfDot = match.lastIndexOf(".");
        if (lastIndexOfDot != -1) {
            match = match.substring(lastIndexOfDot + 1);
        }
        LOGGER.debug("Candidate completion: {}", match);
        completions.add(new InterpreterCompletion(match, match, ""));
    }
    return completions;
}
Also used : CompletionResponse(org.apache.zeppelin.interpreter.jupyter.proto.CompletionResponse) InterpreterCompletion(org.apache.zeppelin.interpreter.thrift.InterpreterCompletion) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 CompletionResponse (org.apache.zeppelin.interpreter.jupyter.proto.CompletionResponse)1 InterpreterCompletion (org.apache.zeppelin.interpreter.thrift.InterpreterCompletion)1