@Before public void setUp() throws Exception { tmpDir = new File( System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo"); tmpDir.mkdirs(); if (repl == null) { intpGroup = new InterpreterGroup(); intpGroup.put("note", new LinkedList<Interpreter>()); repl = new SparkInterpreter(getSparkTestProperties()); repl.setInterpreterGroup(intpGroup); intpGroup.get("note").add(repl); repl.open(); } context = new InterpreterContext( "note", "id", "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), new InterpreterOutput( new InterpreterOutputListener() { @Override public void onAppend(InterpreterOutput out, byte[] line) {} @Override public void onUpdate(InterpreterOutput out, byte[] output) {} })); }
public List<InterpreterCompletion> completion(String buffer, int cursor) { String lines[] = buffer.split(System.getProperty("line.separator")); if (lines.length > 0 && lines[0].startsWith("%") && cursor <= lines[0].trim().length()) { int idx = lines[0].indexOf(' '); if (idx < 0 || (idx > 0 && cursor <= idx)) { return getInterpreterCompletion(); } } String replName = getRequiredReplName(buffer); if (replName != null && cursor > replName.length()) { cursor -= replName.length() + 1; } String body = getScriptBody(buffer); Interpreter repl = getRepl(replName); if (repl == null) { return null; } List completion = repl.completion(body, cursor); return completion; }
private static String generateId() { return "paragraph_" + System.currentTimeMillis() + "_" + new Random(System.currentTimeMillis()).nextInt(); }