Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZEPPELIN-982] Improve interpreter completion API #984

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix type casting error in SparkInterpreter
  • Loading branch information
AhyoungRyu committed Jun 13, 2016
commit 24912fa5ab8f842ee939ea0e43158e17b7245cb7
20 changes: 14 additions & 6 deletions spark/src/main/java/org/apache/zeppelin/spark/DepInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.io.File;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.*;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import org.apache.spark.repl.SparkILoop;
import org.apache.spark.repl.SparkIMain;
import org.apache.spark.repl.SparkJLineCompletion;
Expand All @@ -50,6 +50,7 @@
import scala.Console;
import scala.None;
import scala.Some;
import scala.collection.convert.WrapAsJava$;
import scala.tools.nsc.Settings;
import scala.tools.nsc.interpreter.Completion.Candidates;
import scala.tools.nsc.interpreter.Completion.ScalaCompleter;
Expand Down Expand Up @@ -246,8 +247,15 @@ public int getProgress(InterpreterContext context) {
public List<InterpreterCompletion> completion(String buf, int cursor) {
ScalaCompleter c = completor.completer();
Candidates ret = c.complete(buf, cursor);
List completion = scala.collection.JavaConversions.seqAsJavaList(ret.candidates());
return completion;

List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates());
List<InterpreterCompletion> completions = new LinkedList<InterpreterCompletion>();

for (String candidate : candidates) {
completions.add(new InterpreterCompletion(candidate, candidate));
}

return completions;
}

private List<File> currentClassPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@

import java.io.File;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

import com.google.common.base.Joiner;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import org.apache.spark.HttpServer;
import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
Expand Down Expand Up @@ -64,7 +63,10 @@
import scala.collection.Iterator;
import scala.collection.JavaConversions;
import scala.collection.JavaConverters;
import scala.collection.convert.WrapAsJava;
import scala.collection.Seq;
import scala.collection.convert.WrapAsJava$;
import scala.collection.convert.WrapAsScala;
import scala.collection.mutable.HashMap;
import scala.collection.mutable.HashSet;
import scala.reflect.io.AbstractFile;
Expand Down Expand Up @@ -654,9 +656,15 @@ public List<InterpreterCompletion> completion(String buf, int cursor) {
}
ScalaCompleter c = completor.completer();
Candidates ret = c.complete(completionText, cursor);
List completion = scala.collection.JavaConversions.seqAsJavaList(ret.candidates());

return completion;
List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates());
List<InterpreterCompletion> completions = new LinkedList<InterpreterCompletion>();

for (String candidate : candidates) {
completions.add(new InterpreterCompletion(candidate, candidate));
}

return completions;
}

private String getCompletionTargetString(String text, int cursor) {
Expand Down