Use CompileEnvironmentConfiguretion instead of its components
This commit is contained in:
@@ -173,7 +173,7 @@ public class CompileEnvironmentUtil {
|
||||
scriptEnvironment.addSources(moduleFile);
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
.analyzeAndGenerate(scriptEnvironment, dependencies, messageCollector, false);
|
||||
.analyzeAndGenerate(new CompileEnvironmentConfiguration(scriptEnvironment, dependencies, messageCollector), false);
|
||||
if (generationState == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
@@ -219,19 +218,16 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(CompileEnvironmentConfiguration configuration) {
|
||||
return analyzeAndGenerate(configuration.getEnvironment(), configuration.getCompilerDependencies(), configuration.getMessageCollector(), configuration.getCompilerDependencies().getCompilerSpecialMode().isStubs());
|
||||
return analyzeAndGenerate(configuration, configuration.getCompilerDependencies().getCompilerSpecialMode().isStubs());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(
|
||||
JetCoreEnvironment environment,
|
||||
CompilerDependencies dependencies,
|
||||
|
||||
final MessageCollector messageCollector,
|
||||
CompileEnvironmentConfiguration configuration,
|
||||
|
||||
boolean stubs
|
||||
) {
|
||||
AnalyzeExhaust exhaust = analyze(environment, dependencies, messageCollector, stubs);
|
||||
AnalyzeExhaust exhaust = analyze(configuration, stubs);
|
||||
|
||||
if (exhaust == null) {
|
||||
return null;
|
||||
@@ -239,14 +235,13 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
exhaust.throwIfError();
|
||||
|
||||
return generate(environment, dependencies, messageCollector, exhaust, stubs);
|
||||
return generate(configuration, exhaust, stubs);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AnalyzeExhaust analyze(
|
||||
JetCoreEnvironment environment,
|
||||
CompilerDependencies dependencies,
|
||||
final MessageCollector messageCollector,
|
||||
final CompileEnvironmentConfiguration configuration,
|
||||
|
||||
boolean stubs) {
|
||||
final Ref<Boolean> hasErrors = new Ref<Boolean>(false);
|
||||
final MessageCollector messageCollectorWrapper = new MessageCollector() {
|
||||
@@ -258,10 +253,12 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
if (CompilerMessageSeverity.ERRORS.contains(severity)) {
|
||||
hasErrors.set(true);
|
||||
}
|
||||
messageCollector.report(severity, message, location);
|
||||
configuration.getMessageCollector().report(severity, message, location);
|
||||
}
|
||||
};
|
||||
|
||||
JetCoreEnvironment environment = configuration.getEnvironment();
|
||||
|
||||
// Report syntax errors
|
||||
for (JetFile file : environment.getSourceFiles()) {
|
||||
file.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@@ -280,7 +277,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
stubs ? Predicates.<PsiFile>alwaysFalse() : Predicates.<PsiFile>alwaysTrue();
|
||||
AnalyzeExhaust exhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
environment.getProject(), environment.getSourceFiles(), filesToAnalyzeCompletely, JetControlFlowDataTraceFactory.EMPTY,
|
||||
dependencies);
|
||||
configuration.getCompilerDependencies());
|
||||
|
||||
for (Diagnostic diagnostic : exhaust.getBindingContext().getDiagnostics()) {
|
||||
reportDiagnostic(messageCollectorWrapper, diagnostic);
|
||||
@@ -293,26 +290,24 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@NotNull
|
||||
private static GenerationState generate(
|
||||
JetCoreEnvironment environment,
|
||||
CompilerDependencies dependencies,
|
||||
|
||||
final MessageCollector messageCollector,
|
||||
final CompileEnvironmentConfiguration configuration,
|
||||
|
||||
AnalyzeExhaust exhaust,
|
||||
|
||||
boolean stubs) {
|
||||
JetCoreEnvironment environment = configuration.getEnvironment();
|
||||
Project project = environment.getProject();
|
||||
Progress backendProgress = new Progress() {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
messageCollector.report(CompilerMessageSeverity.LOGGING, message, CompilerMessageLocation.NO_LOCATION);
|
||||
configuration.getMessageCollector().report(CompilerMessageSeverity.LOGGING, message, CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
};
|
||||
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), backendProgress,
|
||||
exhaust, environment.getSourceFiles(), dependencies.getCompilerSpecialMode());
|
||||
exhaust, environment.getSourceFiles(), configuration.getCompilerDependencies().getCompilerSpecialMode());
|
||||
generationState.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
List<CompilerPlugin> plugins = environment.getCompilerPlugins();
|
||||
List<CompilerPlugin> plugins = configuration.getCompilerPlugins();
|
||||
if (plugins != null) {
|
||||
CompilerPluginContext context = new CompilerPluginContext(project, exhaust.getBindingContext(), environment.getSourceFiles());
|
||||
for (CompilerPlugin plugin : plugins) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.jet.compiler.CompileEnvironmentConfiguration;
|
||||
import org.jetbrains.jet.compiler.KotlinToJVMBytecodeCompiler;
|
||||
import org.jetbrains.jet.compiler.messages.MessageCollector;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -37,7 +38,6 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
@@ -75,7 +75,6 @@ public class TestlibTest extends CodegenTestCase {
|
||||
|
||||
private TestSuite doBuildSuite() {
|
||||
try {
|
||||
PrintStream err = System.err;
|
||||
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR);
|
||||
File junitJar = new File("libraries/lib/junit-4.9.jar");
|
||||
|
||||
@@ -92,7 +91,7 @@ public class TestlibTest extends CodegenTestCase {
|
||||
myEnvironment.addSources(localFileSystem.findFileByPath(JetParsingTest.getTestDataDir() + "/../../libraries/kunit/src"));
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
.analyzeAndGenerate(myEnvironment, compilerDependencies, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false);
|
||||
.analyzeAndGenerate(new CompileEnvironmentConfiguration(myEnvironment, compilerDependencies, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR), false);
|
||||
|
||||
if (generationState == null) {
|
||||
throw new RuntimeException("There were compilation errors");
|
||||
|
||||
Reference in New Issue
Block a user