Using Disposer.newDisposable() instead of an anonymous class
This commit is contained in:
@@ -23,7 +23,6 @@ import com.sampullara.cli.Args;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.cli.common.messages.*;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
|
||||
import java.io.PrintStream;
|
||||
@@ -125,7 +124,7 @@ public abstract class CLICompiler<A extends CompilerArguments> {
|
||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull A arguments) {
|
||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||
try {
|
||||
Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
try {
|
||||
MessageSeverityCollector severityCollector = new MessageSeverityCollector(groupingCollector);
|
||||
ExitCode code = doExecute(arguments, severityCollector, rootDisposable);
|
||||
|
||||
@@ -56,13 +56,6 @@ import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_L
|
||||
import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERROR;
|
||||
|
||||
public class CompileEnvironmentUtil {
|
||||
public static Disposable createMockDisposable() {
|
||||
return new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static File getRuntimeJarPath() {
|
||||
@@ -97,12 +90,6 @@ public class CompileEnvironmentUtil {
|
||||
|
||||
@NotNull
|
||||
private static List<Module> loadModuleScript(KotlinPaths paths, String moduleScriptFile, MessageCollector messageCollector) {
|
||||
Disposable disposable = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
};
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
File runtimePath = paths.getRuntimePath();
|
||||
if (runtimePath.exists()) {
|
||||
@@ -117,6 +104,8 @@ public class CompileEnvironmentUtil {
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||
|
||||
List<Module> modules;
|
||||
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
try {
|
||||
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createForProduction(disposable, configuration);
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment);
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
compilerConfiguration.add(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, new File(annotationsRoot));
|
||||
}
|
||||
|
||||
Disposable parentDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable parentDisposable = Disposer.newDisposable();
|
||||
JetCoreEnvironment moduleEnvironment = null;
|
||||
try {
|
||||
moduleEnvironment = JetCoreEnvironment.createForProduction(parentDisposable, compilerConfiguration);
|
||||
@@ -325,7 +325,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
@Nullable List<JetScriptDefinition> scriptDefinitions) {
|
||||
MessageRenderer messageRenderer = MessageRenderer.PLAIN;
|
||||
GroupingMessageCollector messageCollector = new GroupingMessageCollector(new PrintingMessageCollector(System.err, messageRenderer, false));
|
||||
Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
try {
|
||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||
compilerConfiguration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||
|
||||
Reference in New Issue
Block a user