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);
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.di.InjectorForJavaDescriptorResolver;
|
||||
@@ -90,7 +89,7 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
|
||||
Map<String, List<String>> errors = Maps.newLinkedHashMap();
|
||||
|
||||
for (int chunkIndex = 0; chunkIndex < affectedClasses.size() / CLASSES_IN_CHUNK + 1; chunkIndex++) {
|
||||
Disposable parentDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable parentDisposable = Disposer.newDisposable();
|
||||
|
||||
try {
|
||||
JetCoreEnvironment commonEnvironment = createEnvironment(parentDisposable);
|
||||
@@ -134,7 +133,7 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
|
||||
}
|
||||
|
||||
static List<FqName> getAffectedClasses(String rootUrl) {
|
||||
Disposable myDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable myDisposable = Disposer.newDisposable();
|
||||
|
||||
try {
|
||||
createEnvironment(myDisposable);
|
||||
|
||||
@@ -38,11 +38,7 @@ public class ReplInterpreterTest {
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
}
|
||||
|
||||
private final Disposable disposable = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
private final Disposable disposable = Disposer.newDisposable();
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.di.GeneratorsFileUtil;
|
||||
@@ -70,7 +69,7 @@ public class GenerateJavaToKotlinMethodMap {
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
configuration.add(CLASSPATH_KEY, PathUtil.findRtJar());
|
||||
|
||||
Disposable disposable = CompileEnvironmentUtil.createMockDisposable();
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
try {
|
||||
JetCoreEnvironment coreEnvironment = JetCoreEnvironment.createForProduction(disposable, configuration);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.core.JavaCoreProjectEnvironment;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
@@ -37,11 +38,7 @@ import java.net.URLClassLoader;
|
||||
|
||||
public class JavaToKotlinTranslator {
|
||||
|
||||
private static final Disposable DISPOSABLE = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
private static final Disposable DISPOSABLE = Disposer.newDisposable();
|
||||
|
||||
private JavaToKotlinTranslator() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user