use of org.apache.zeppelin.kotlin.reflect.KotlinFunctionInfo in project zeppelin by apache.
the class KotlinInterpreterTest method testReflectUtil.
@Test
public void testReflectUtil() throws Exception {
String message = interpreter.interpret("1", context).message().get(0).getData();
assertTrue(shorten(message).contains("Int = 1"));
interpreter.interpret("val f = { l: List<Int> -> l[0] }", context);
message = interpreter.interpret("f", context).message().get(0).getData();
assertTrue(shorten(message).contains("(List<Int>) -> Int"));
interpreter.interpret("fun first(s: String): Char = s[0]", context);
KotlinFunctionInfo first = interpreter.getFunctions().get(0);
assertEquals("fun first(String): Char", first.toString(true));
}
use of org.apache.zeppelin.kotlin.reflect.KotlinFunctionInfo in project zeppelin by apache.
the class KotlinCompleter method completion.
public List<InterpreterCompletion> completion(String buf, int cursor, InterpreterContext interpreterContext) {
if (ctx == null) {
return new ArrayList<>(keywords);
}
List<InterpreterCompletion> result = new ArrayList<>();
for (KotlinVariableInfo var : ctx.getVars()) {
result.add(new InterpreterCompletion(var.getName(), var.getName(), shorten(var.getType())));
}
for (KotlinFunctionInfo fun : ctx.getFunctions()) {
result.add(new InterpreterCompletion(fun.getName(), fun.getName(), fun.toString(true)));
}
result.addAll(keywords);
return result;
}
Aggregations