Search in sources :

Example 1 with ScalaCompleter

use of scala.tools.nsc.interpreter.Completion.ScalaCompleter in project zeppelin by apache.

the class SparkInterpreter method completion.

@Override
public List<InterpreterCompletion> completion(String buf, int cursor) {
    if (completer == null) {
        logger.warn("Can't find completer");
        return new LinkedList<>();
    }
    if (buf.length() < cursor) {
        cursor = buf.length();
    }
    String completionText = getCompletionTargetString(buf, cursor);
    if (completionText == null) {
        completionText = "";
        cursor = completionText.length();
    }
    ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completer, "completer");
    Candidates ret = c.complete(completionText, cursor);
    List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates());
    List<InterpreterCompletion> completions = new LinkedList<>();
    for (String candidate : candidates) {
        completions.add(new InterpreterCompletion(candidate, candidate));
    }
    return completions;
}
Also used : Candidates(scala.tools.nsc.interpreter.Completion.Candidates) InterpreterCompletion(org.apache.zeppelin.interpreter.thrift.InterpreterCompletion) ScalaCompleter(scala.tools.nsc.interpreter.Completion.ScalaCompleter)

Example 2 with ScalaCompleter

use of scala.tools.nsc.interpreter.Completion.ScalaCompleter in project zeppelin by apache.

the class DepInterpreter method completion.

@Override
public List<InterpreterCompletion> completion(String buf, int cursor) {
    if (Utils.isScala2_10()) {
        ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completer, "completer");
        Candidates ret = c.complete(buf, cursor);
        List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates());
        List<InterpreterCompletion> completions = new LinkedList<>();
        for (String candidate : candidates) {
            completions.add(new InterpreterCompletion(candidate, candidate));
        }
        return completions;
    } else {
        return new LinkedList<>();
    }
}
Also used : Candidates(scala.tools.nsc.interpreter.Completion.Candidates) InterpreterCompletion(org.apache.zeppelin.interpreter.thrift.InterpreterCompletion) ScalaCompleter(scala.tools.nsc.interpreter.Completion.ScalaCompleter) LinkedList(java.util.LinkedList)

Aggregations

InterpreterCompletion (org.apache.zeppelin.interpreter.thrift.InterpreterCompletion)2 Candidates (scala.tools.nsc.interpreter.Completion.Candidates)2 ScalaCompleter (scala.tools.nsc.interpreter.Completion.ScalaCompleter)2 LinkedList (java.util.LinkedList)1