Removed factory methods from JetCoreEnvironment since they only invoke constuctor.
This commit is contained in:
@@ -75,7 +75,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
|||||||
|
|
||||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||||
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, Arrays.asList(arguments.sourceFiles));
|
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, Arrays.asList(arguments.sourceFiles));
|
||||||
JetCoreEnvironment environmentForJS = JetCoreEnvironment.createCoreEnvironmentForJS(rootDisposable, configuration);
|
JetCoreEnvironment environmentForJS = new JetCoreEnvironment(rootDisposable, configuration);
|
||||||
|
|
||||||
Project project = environmentForJS.getProject();
|
Project project = environmentForJS.getProject();
|
||||||
|
|
||||||
|
|||||||
@@ -127,11 +127,11 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
|||||||
}
|
}
|
||||||
else if (arguments.script) {
|
else if (arguments.script) {
|
||||||
List<String> scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size());
|
List<String> scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size());
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, configuration);
|
JetCoreEnvironment environment = new JetCoreEnvironment(rootDisposable, configuration);
|
||||||
noErrors = KotlinToJVMBytecodeCompiler.compileAndExecuteScript(environment, scriptArgs);
|
noErrors = KotlinToJVMBytecodeCompiler.compileAndExecuteScript(environment, scriptArgs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, configuration);
|
JetCoreEnvironment environment = new JetCoreEnvironment(rootDisposable, configuration);
|
||||||
noErrors = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
|
noErrors = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
|
||||||
}
|
}
|
||||||
return noErrors ? OK : COMPILATION_ERROR;
|
return noErrors ? OK : COMPILATION_ERROR;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class CompileEnvironmentUtil {
|
|||||||
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, moduleScriptFile);
|
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, moduleScriptFile);
|
||||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||||
|
|
||||||
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(disposable, configuration);
|
JetCoreEnvironment scriptEnvironment = new JetCoreEnvironment(disposable, configuration);
|
||||||
|
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment, false);
|
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment, false);
|
||||||
if (generationState == null) {
|
if (generationState == null) {
|
||||||
|
|||||||
@@ -55,15 +55,6 @@ import java.util.List;
|
|||||||
* @author yole
|
* @author yole
|
||||||
*/
|
*/
|
||||||
public class JetCoreEnvironment {
|
public class JetCoreEnvironment {
|
||||||
@NotNull
|
|
||||||
public static JetCoreEnvironment createCoreEnvironmentForJS(Disposable disposable, @NotNull CompilerConfiguration configuration) {
|
|
||||||
return new JetCoreEnvironment(disposable, configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static JetCoreEnvironment createCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerConfiguration configuration) {
|
|
||||||
return new JetCoreEnvironment(disposable, configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final JavaCoreApplicationEnvironment applicationEnvironment;
|
private final JavaCoreApplicationEnvironment applicationEnvironment;
|
||||||
private final JavaCoreProjectEnvironment projectEnvironment;
|
private final JavaCoreProjectEnvironment projectEnvironment;
|
||||||
|
|||||||
+2
-3
@@ -103,8 +103,7 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
Disposable parentDisposable = CompileEnvironmentUtil.createMockDisposable();
|
Disposable parentDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||||
JetCoreEnvironment moduleEnvironment = null;
|
JetCoreEnvironment moduleEnvironment = null;
|
||||||
try {
|
try {
|
||||||
moduleEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(parentDisposable,
|
moduleEnvironment = new JetCoreEnvironment(parentDisposable, compilerConfiguration);
|
||||||
compilerConfiguration);
|
|
||||||
|
|
||||||
|
|
||||||
GenerationState generationState = analyzeAndGenerate(moduleEnvironment);
|
GenerationState generationState = analyzeAndGenerate(moduleEnvironment);
|
||||||
@@ -371,7 +370,7 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
scriptDefinitions != null ? scriptDefinitions : Collections.<JetScriptDefinition>emptyList());
|
scriptDefinitions != null ? scriptDefinitions : Collections.<JetScriptDefinition>emptyList());
|
||||||
compilerConfiguration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, scriptParameters);
|
compilerConfiguration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, scriptParameters);
|
||||||
|
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration);
|
JetCoreEnvironment environment = new JetCoreEnvironment(rootDisposable, compilerConfiguration);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JetScriptDefinitionProvider.getInstance(environment.getProject()).markFileAsScript(environment.getSourceFiles().get(0));
|
JetScriptDefinitionProvider.getInstance(environment.getProject()).markFileAsScript(environment.getSourceFiles().get(0));
|
||||||
|
|||||||
+1
-1
@@ -149,7 +149,7 @@ public class ResolveDescriptorsFromExternalLibraries {
|
|||||||
else {
|
else {
|
||||||
CompilerConfiguration configuration =
|
CompilerConfiguration configuration =
|
||||||
CompileCompilerDependenciesTest.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK);
|
CompileCompilerDependenciesTest.compilerConfigurationForTests(ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK);
|
||||||
jetCoreEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(junk, configuration);
|
jetCoreEnvironment = new JetCoreEnvironment(junk, configuration);
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JetCoreEnvironment createEnvironment() {
|
protected JetCoreEnvironment createEnvironment() {
|
||||||
return JetCoreEnvironment.createCoreEnvironmentForJVM(getTestRootDisposable(), new CompilerConfiguration());
|
return new JetCoreEnvironment(getTestRootDisposable(), new CompilerConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user