Got rid of using CompilerDependencies in JetCoreEnvironment. CompilerConfiguration is passed instead.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
<orderEntry type="library" name="idea-full" level="project" />
|
<orderEntry type="library" name="idea-full" level="project" />
|
||||||
|
<orderEntry type="module" module-name="frontend" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,13 @@ import jet.modules.Module;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
||||||
|
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.*;
|
import org.jetbrains.jet.cli.jvm.compiler.*;
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -50,20 +53,28 @@ public class BytecodeCompiler {
|
|||||||
* @return compile environment instance
|
* @return compile environment instance
|
||||||
*/
|
*/
|
||||||
private K2JVMCompileEnvironmentConfiguration env( String stdlib, String[] classpath ) {
|
private K2JVMCompileEnvironmentConfiguration env( String stdlib, String[] classpath ) {
|
||||||
CompilerDependencies dependencies = CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.REGULAR);
|
List<File> classpathItems = new ArrayList<File>();
|
||||||
JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), dependencies);
|
classpathItems.add(PathUtil.findRtJar());
|
||||||
|
if ((stdlib != null) && (stdlib.trim().length() > 0)) {
|
||||||
|
classpathItems.add(new File(stdlib));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
classpathItems.add(PathUtil.getDefaultRuntimePath());
|
||||||
|
}
|
||||||
|
if ((classpath != null) && (classpath.length > 0)) {
|
||||||
|
for (String path : classpath) {
|
||||||
|
classpathItems.add(new File(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||||
|
configuration.putUserData(JVMConfigurationKeys.CLASSPATH_KEY, classpathItems.toArray(new File[classpathItems.size()]));
|
||||||
|
configuration.putUserData(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, new File[]{PathUtil.getJdkAnnotationsPath()});
|
||||||
|
|
||||||
|
JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), configuration,
|
||||||
|
CompilerSpecialMode.REGULAR);
|
||||||
K2JVMCompileEnvironmentConfiguration
|
K2JVMCompileEnvironmentConfiguration
|
||||||
env = new K2JVMCompileEnvironmentConfiguration(environment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false);
|
env = new K2JVMCompileEnvironmentConfiguration(environment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false);
|
||||||
|
|
||||||
if (( stdlib != null ) && ( stdlib.trim().length() > 0 )) {
|
|
||||||
File file = new File(stdlib);
|
|
||||||
CompileEnvironmentUtil.addToClasspath(env.getEnvironment(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (( classpath != null ) && ( classpath.length > 0 )) {
|
|
||||||
CompileEnvironmentUtil.addToClasspath(env.getEnvironment(), classpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets register any compiler plugins
|
// lets register any compiler plugins
|
||||||
env.getCompilerPlugins().addAll(getCompilerPlugins());
|
env.getCompilerPlugins().addAll(getCompilerPlugins());
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.cli.jvm;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Evgeny Gerashchenko
|
||||||
|
* @since 7/4/12
|
||||||
|
*/
|
||||||
|
public class CompilerConfigurationUtl {
|
||||||
|
// TODO merge with similar K2JVMCompiler method
|
||||||
|
public static CompilerConfiguration getDefaultConfiguration(@NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
|
List<File> classpath = new ArrayList<File>();
|
||||||
|
if (compilerSpecialMode.includeJdk()) {
|
||||||
|
classpath.add(PathUtil.findRtJar());
|
||||||
|
}
|
||||||
|
if (compilerSpecialMode.includeKotlinRuntime()) {
|
||||||
|
classpath.add(PathUtil.getDefaultRuntimePath());
|
||||||
|
}
|
||||||
|
File[] annotationsPath = new File[0];
|
||||||
|
if (compilerSpecialMode.includeJdkAnnotations()) {
|
||||||
|
annotationsPath = new File[]{PathUtil.getJdkAnnotationsPath()};
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||||
|
configuration.putUserData(JVMConfigurationKeys.CLASSPATH_KEY, classpath.toArray(new File[classpath.size()]));
|
||||||
|
configuration.putUserData(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, annotationsPath);
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,36 +55,8 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
||||||
|
|
||||||
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
||||||
File jdkAnnotationsJar;
|
CompilerConfiguration compilerConfiguration = createCompilerConfiguration(arguments);
|
||||||
if (mode.includeJdkAnnotations()) {
|
|
||||||
if (arguments.jdkAnnotations != null) {
|
|
||||||
jdkAnnotationsJar = new File(arguments.jdkAnnotations);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
jdkAnnotationsJar = PathUtil.getJdkAnnotationsPath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
jdkAnnotationsJar = null;
|
|
||||||
}
|
|
||||||
File runtimeJar;
|
|
||||||
|
|
||||||
if (mode.includeKotlinRuntime()) {
|
|
||||||
if (arguments.stdlib != null) {
|
|
||||||
runtimeJar = new File(arguments.stdlib);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
runtimeJar = PathUtil.getDefaultRuntimePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
runtimeJar = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// will be ignored later
|
|
||||||
CompilerDependencies dependencies = new CompilerDependencies(mode, PathUtil.findRtJar(), jdkAnnotationsJar, runtimeJar);
|
|
||||||
|
|
||||||
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
||||||
if (!arguments.script &&
|
if (!arguments.script &&
|
||||||
@@ -93,12 +65,13 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
arguments.freeArgs.isEmpty() &&
|
arguments.freeArgs.isEmpty() &&
|
||||||
(argumentsSourceDirs == null || argumentsSourceDirs.size() == 0)) {
|
(argumentsSourceDirs == null || argumentsSourceDirs.size() == 0)) {
|
||||||
|
|
||||||
ReplFromTerminal.run(rootDisposable, dependencies, createCompilerConfiguration(arguments));
|
ReplFromTerminal.run(rootDisposable, compilerConfiguration, mode);
|
||||||
return ExitCode.OK;
|
return ExitCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, dependencies);
|
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration, mode);
|
||||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(environment, messageCollector, arguments.script);
|
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(environment, messageCollector,
|
||||||
|
arguments.script);
|
||||||
|
|
||||||
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
||||||
CompilerMessageLocation.NO_LOCATION);
|
CompilerMessageLocation.NO_LOCATION);
|
||||||
|
|||||||
@@ -27,13 +27,14 @@ import jet.modules.Module;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
|
import org.jetbrains.jet.cli.jvm.CompilerConfigurationUtl;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
||||||
import org.jetbrains.jet.codegen.GenerationState;
|
import org.jetbrains.jet.codegen.GenerationState;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.utils.PathUtil;
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -139,8 +140,8 @@ public class CompileEnvironmentUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CompilerDependencies dependencies = CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.REGULAR);
|
CompilerConfiguration configuration = CompilerConfigurationUtl.getDefaultConfiguration(CompilerSpecialMode.REGULAR);
|
||||||
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(disposable, dependencies);
|
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(disposable, configuration, CompilerSpecialMode.REGULAR);
|
||||||
scriptEnvironment.addSources(moduleScriptFile);
|
scriptEnvironment.addSources(moduleScriptFile);
|
||||||
|
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.jetbrains.jet.config.CompilerConfiguration;
|
|||||||
import org.jetbrains.jet.lang.parsing.JetParser;
|
import org.jetbrains.jet.lang.parsing.JetParser;
|
||||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.java.extAnnotations.CoreAnnotationsProvider;
|
import org.jetbrains.jet.lang.resolve.java.extAnnotations.CoreAnnotationsProvider;
|
||||||
@@ -56,21 +55,23 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetCoreEnvironment createCoreEnvironmentForJS(Disposable disposable) {
|
public static JetCoreEnvironment createCoreEnvironmentForJS(Disposable disposable) {
|
||||||
return new JetCoreEnvironment(disposable, CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.JS));
|
return new JetCoreEnvironment(disposable, new CompilerConfiguration(), CompilerSpecialMode.JS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetCoreEnvironment createCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
|
public static JetCoreEnvironment createCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerConfiguration configuration,
|
||||||
return new JetCoreEnvironment(disposable, dependencies);
|
@NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
|
return new JetCoreEnvironment(disposable, configuration, compilerSpecialMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final CompilerSpecialMode compilerSpecialMode;
|
private final CompilerSpecialMode compilerSpecialMode;
|
||||||
|
|
||||||
public JetCoreEnvironment(Disposable parentDisposable, @NotNull CompilerDependencies compilerDependencies) {
|
public JetCoreEnvironment(Disposable parentDisposable, @NotNull CompilerConfiguration configuration,
|
||||||
|
@NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
super(parentDisposable);
|
super(parentDisposable);
|
||||||
|
|
||||||
this.compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
|
this.compilerSpecialMode = compilerSpecialMode;
|
||||||
|
|
||||||
registerFileType(JetFileType.INSTANCE, "kt");
|
registerFileType(JetFileType.INSTANCE, "kt");
|
||||||
registerFileType(JetFileType.INSTANCE, "kts");
|
registerFileType(JetFileType.INSTANCE, "kts");
|
||||||
@@ -86,24 +87,10 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||||
.registerExtension(new JavaElementFinder(myProject));
|
.registerExtension(new JavaElementFinder(myProject));
|
||||||
|
|
||||||
CompilerSpecialMode compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
|
|
||||||
|
|
||||||
if (compilerSpecialMode.includeJdk()) {
|
|
||||||
addToClasspath(compilerDependencies.getJdkJar());
|
|
||||||
}
|
|
||||||
|
|
||||||
annotationsProvider = new CoreAnnotationsProvider();
|
annotationsProvider = new CoreAnnotationsProvider();
|
||||||
if (compilerSpecialMode.includeJdkAnnotations()) {
|
|
||||||
for (VirtualFile root : compilerDependencies.getJdkAnnotationsRoots()) {
|
|
||||||
annotationsProvider.addExternalAnnotationsRoot(root);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myProject.registerService(ExternalAnnotationsProvider.class, annotationsProvider);
|
myProject.registerService(ExternalAnnotationsProvider.class, annotationsProvider);
|
||||||
|
|
||||||
if (compilerSpecialMode.includeKotlinRuntime()) {
|
configure(configuration);
|
||||||
addToClasspath(compilerDependencies.getRuntimeJar());
|
|
||||||
}
|
|
||||||
|
|
||||||
JetStandardLibrary.initialize(getProject());
|
JetStandardLibrary.initialize(getProject());
|
||||||
}
|
}
|
||||||
@@ -196,12 +183,15 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
public void configure(@NotNull CompilerConfiguration compilerConfiguration) {
|
public void configure(@NotNull CompilerConfiguration compilerConfiguration) {
|
||||||
File[] classpath = compilerConfiguration.getUserData(JVMConfigurationKeys.CLASSPATH_KEY);
|
File[] classpath = compilerConfiguration.getUserData(JVMConfigurationKeys.CLASSPATH_KEY);
|
||||||
File[] annotationsPath = compilerConfiguration.getUserData(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY);
|
File[] annotationsPath = compilerConfiguration.getUserData(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY);
|
||||||
assert classpath != null && annotationsPath != null;
|
if (classpath != null) {
|
||||||
for (File path : classpath) {
|
for (File path : classpath) {
|
||||||
addToClasspath(path);
|
addToClasspath(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (File path : annotationsPath) {
|
if (annotationsPath != null) {
|
||||||
addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(path));
|
for (File path : annotationsPath) {
|
||||||
|
addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import jline.console.history.FileHistory;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -43,13 +44,13 @@ public class ReplFromTerminal {
|
|||||||
|
|
||||||
public ReplFromTerminal(
|
public ReplFromTerminal(
|
||||||
@NotNull final Disposable disposable,
|
@NotNull final Disposable disposable,
|
||||||
@NotNull final CompilerDependencies compilerDependencies,
|
@NotNull final CompilerConfiguration compilerConfiguration,
|
||||||
@NotNull final CompilerConfiguration compilerConfiguration) {
|
@NotNull final CompilerSpecialMode mode) {
|
||||||
new Thread("initialize-repl") {
|
new Thread("initialize-repl") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
replInterpreter = new ReplInterpreter(disposable, compilerDependencies, compilerConfiguration);
|
replInterpreter = new ReplInterpreter(disposable, compilerConfiguration, mode);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
replInitializationFailed = e;
|
replInitializationFailed = e;
|
||||||
}
|
}
|
||||||
@@ -195,9 +196,9 @@ public class ReplFromTerminal {
|
|||||||
return Arrays.asList(command.split(" "));
|
return Arrays.asList(command.split(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void run(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies,
|
public static void run(@NotNull Disposable disposable, @NotNull CompilerConfiguration configuration,
|
||||||
@NotNull CompilerConfiguration compilerConfiguration) {
|
@NotNull CompilerSpecialMode mode) {
|
||||||
new ReplFromTerminal(disposable, compilerDependencies, compilerConfiguration).doRun();
|
new ReplFromTerminal(disposable, configuration, mode).doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,13 +45,8 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorImpl;
|
|||||||
import org.jetbrains.jet.lang.descriptors.NamespaceLikeBuilderDummy;
|
import org.jetbrains.jet.lang.descriptors.NamespaceLikeBuilderDummy;
|
||||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.jet.lang.resolve.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
|
||||||
import org.jetbrains.jet.lang.resolve.ScriptHeaderResolver;
|
|
||||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
|
||||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
@@ -94,9 +89,8 @@ public class ReplInterpreter {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final ModuleDescriptor module;
|
private final ModuleDescriptor module;
|
||||||
|
|
||||||
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies,
|
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerConfiguration configuration, @NotNull CompilerSpecialMode mode) {
|
||||||
@NotNull CompilerConfiguration configuration) {
|
jetCoreEnvironment = new JetCoreEnvironment(disposable, configuration, mode);
|
||||||
jetCoreEnvironment = new JetCoreEnvironment(disposable, compilerDependencies);
|
|
||||||
jetCoreEnvironment.configure(configuration);
|
jetCoreEnvironment.configure(configuration);
|
||||||
Project project = jetCoreEnvironment.getProject();
|
Project project = jetCoreEnvironment.getProject();
|
||||||
trace = new BindingTraceContext();
|
trace = new BindingTraceContext();
|
||||||
@@ -106,8 +100,7 @@ public class ReplInterpreter {
|
|||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
Collections.<AnalyzerScriptParameter>emptyList());
|
Collections.<AnalyzerScriptParameter>emptyList());
|
||||||
injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module,
|
injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module, mode);
|
||||||
compilerDependencies.getCompilerSpecialMode());
|
|
||||||
|
|
||||||
List<URL> classpath = Lists.newArrayList();
|
List<URL> classpath = Lists.newArrayList();
|
||||||
|
|
||||||
|
|||||||
@@ -180,8 +180,9 @@ public class JetTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JetCoreEnvironment createEnvironmentWithMockJdkAndIdeaAnnotations(Disposable disposable, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
public static JetCoreEnvironment createEnvironmentWithMockJdkAndIdeaAnnotations(Disposable disposable, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
JetCoreEnvironment environment =
|
JetCoreEnvironment environment = new JetCoreEnvironment(disposable,
|
||||||
new JetCoreEnvironment(disposable, CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode, true));
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(compilerSpecialMode, true),
|
||||||
|
compilerSpecialMode);
|
||||||
environment.addToClasspath(getAnnotationsJar());
|
environment.addToClasspath(getAnnotationsJar());
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
@@ -253,7 +254,8 @@ public class JetTestUtils {
|
|||||||
|
|
||||||
public static JetCoreEnvironment createEnvironmentWithFullJdk(Disposable disposable) {
|
public static JetCoreEnvironment createEnvironmentWithFullJdk(Disposable disposable) {
|
||||||
return new JetCoreEnvironment(disposable,
|
return new JetCoreEnvironment(disposable,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false));
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.REGULAR, false),
|
||||||
|
CompilerSpecialMode.REGULAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PsiFile createFile(@NonNls String name, String text, @NotNull Project project) {
|
public static PsiFile createFile(@NonNls String name, String text, @NotNull Project project) {
|
||||||
|
|||||||
+6
-9
@@ -30,19 +30,15 @@ import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
|||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.TimeUtils;
|
import org.jetbrains.jet.TimeUtils;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.utils.PathUtil;
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@@ -153,8 +149,9 @@ public class ResolveDescriptorsFromExternalLibraries {
|
|||||||
jetCoreEnvironment.addToClasspath(jar);
|
jetCoreEnvironment.addToClasspath(jar);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.STDLIB, false);
|
CompilerConfiguration configuration =
|
||||||
jetCoreEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(junk, compilerDependencies);
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.STDLIB, false);
|
||||||
|
jetCoreEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(junk, configuration, CompilerSpecialMode.STDLIB);
|
||||||
if (!PathUtil.findRtJar().equals(jar)) {
|
if (!PathUtil.findRtJar().equals(jar)) {
|
||||||
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + PathUtil.findRtJar());
|
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + PathUtil.findRtJar());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
|||||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -47,9 +46,9 @@ public abstract class AbstractLazyResolveTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final CompilerDependencies
|
protected final JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(rootDisposable,
|
||||||
compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, true);
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.JDK_HEADERS, true),
|
||||||
protected final JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(rootDisposable, compilerDependencies);
|
CompilerSpecialMode.JDK_HEADERS);
|
||||||
protected final Project project = jetCoreEnvironment.getProject();
|
protected final Project project = jetCoreEnvironment.getProject();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
|||||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||||
import org.jetbrains.jet.cli.jvm.repl.ReplInterpreter;
|
import org.jetbrains.jet.cli.jvm.repl.ReplInterpreter;
|
||||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -54,13 +53,12 @@ public class ReplInterpreterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void testFile(@NotNull String relativePath) {
|
private void testFile(@NotNull String relativePath) {
|
||||||
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, false);
|
|
||||||
CompilerConfiguration configuration =
|
CompilerConfiguration configuration =
|
||||||
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.JDK_HEADERS, false);
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.JDK_HEADERS, false);
|
||||||
File[] classpath = configuration.getUserData(JVMConfigurationKeys.CLASSPATH_KEY);
|
File[] classpath = configuration.getUserData(JVMConfigurationKeys.CLASSPATH_KEY);
|
||||||
assert classpath != null;
|
assert classpath != null;
|
||||||
configuration.putUserData(JVMConfigurationKeys.CLASSPATH_KEY, ArrayUtil.append(classpath, new File("out/production/runtime")));
|
configuration.putUserData(JVMConfigurationKeys.CLASSPATH_KEY, ArrayUtil.append(classpath, new File("out/production/runtime")));
|
||||||
ReplInterpreter repl = new ReplInterpreter(disposable, compilerDependencies, configuration);
|
ReplInterpreter repl = new ReplInterpreter(disposable, configuration, CompilerSpecialMode.JDK_HEADERS);
|
||||||
|
|
||||||
ReplSessionTestFile file = ReplSessionTestFile.load(new File("compiler/testData/repl/" + relativePath));
|
ReplSessionTestFile file = ReplSessionTestFile.load(new File("compiler/testData/repl/" + relativePath));
|
||||||
for (ReplSessionTestFile.OneLine t : file.getLines()) {
|
for (ReplSessionTestFile.OneLine t : file.getLines()) {
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ public abstract class TestWithEnvironment extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void createEnvironmentWithMockJdkAndIdeaAnnotations() {
|
protected void createEnvironmentWithMockJdkAndIdeaAnnotations() {
|
||||||
myEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(getTestRootDisposable(),
|
myEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(
|
getTestRootDisposable(),
|
||||||
CompilerSpecialMode.JS,
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(CompilerSpecialMode.JS, true),
|
||||||
true));
|
CompilerSpecialMode.JS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user