Got rid of actual using CompilerDependencies in REPL interpreter classes.
This commit is contained in:
@@ -93,7 +93,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
arguments.freeArgs.isEmpty() &&
|
||||
(argumentsSourceDirs == null || argumentsSourceDirs.size() == 0)) {
|
||||
|
||||
ReplFromTerminal.run(rootDisposable, dependencies, getClasspath(arguments));
|
||||
ReplFromTerminal.run(rootDisposable, dependencies, createCompilerConfiguration(arguments));
|
||||
return ExitCode.OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import jline.console.ConsoleReader;
|
||||
import jline.console.history.FileHistory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,12 +44,12 @@ public class ReplFromTerminal {
|
||||
public ReplFromTerminal(
|
||||
@NotNull final Disposable disposable,
|
||||
@NotNull final CompilerDependencies compilerDependencies,
|
||||
@NotNull final List<File> extraClasspath) {
|
||||
@NotNull final CompilerConfiguration compilerConfiguration) {
|
||||
new Thread("initialize-repl") {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
replInterpreter = new ReplInterpreter(disposable, compilerDependencies, extraClasspath);
|
||||
replInterpreter = new ReplInterpreter(disposable, compilerDependencies, compilerConfiguration);
|
||||
} catch (Throwable e) {
|
||||
replInitializationFailed = e;
|
||||
}
|
||||
@@ -195,8 +195,9 @@ public class ReplFromTerminal {
|
||||
return Arrays.asList(command.split(" "));
|
||||
}
|
||||
|
||||
public static void run(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies, @NotNull List<File> extraClasspath) {
|
||||
new ReplFromTerminal(disposable, compilerDependencies, extraClasspath).doRun();
|
||||
public static void run(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies,
|
||||
@NotNull CompilerConfiguration compilerConfiguration) {
|
||||
new ReplFromTerminal(disposable, compilerDependencies, compilerConfiguration).doRun();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,12 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorToString;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorImpl;
|
||||
@@ -65,6 +67,7 @@ import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Collections;
|
||||
@@ -91,12 +94,10 @@ public class ReplInterpreter {
|
||||
@NotNull
|
||||
private final ModuleDescriptor module;
|
||||
|
||||
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies, @NotNull List<File> extraClasspath) {
|
||||
// TODO: add extraClasspath to jetCoreEnvironment
|
||||
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies,
|
||||
@NotNull CompilerConfiguration configuration) {
|
||||
jetCoreEnvironment = new JetCoreEnvironment(disposable, compilerDependencies);
|
||||
for (File pathElement : extraClasspath) {
|
||||
jetCoreEnvironment.addToClasspath(pathElement);
|
||||
}
|
||||
jetCoreEnvironment.configure(configuration);
|
||||
Project project = jetCoreEnvironment.getProject();
|
||||
trace = new BindingTraceContext();
|
||||
module = new ModuleDescriptor(Name.special("<repl>"));
|
||||
@@ -110,16 +111,13 @@ public class ReplInterpreter {
|
||||
|
||||
List<URL> classpath = Lists.newArrayList();
|
||||
|
||||
try {
|
||||
if (compilerDependencies.getRuntimeJar() != null) {
|
||||
classpath.add(compilerDependencies.getRuntimeJar().toURI().toURL());
|
||||
for (File file : configuration.getUserData(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
||||
try {
|
||||
classpath.add(file.toURI().toURL());
|
||||
}
|
||||
|
||||
for (File extra : extraClasspath) {
|
||||
classpath.add(extra.toURI().toURL());
|
||||
catch (MalformedURLException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
}
|
||||
|
||||
classLoader = new ReplClassLoader(new URLClassLoader(classpath.toArray(new URL[0])));
|
||||
|
||||
Reference in New Issue
Block a user