From e1831877b78ee453a2b97fccb4d6d0db96f58c8c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 17 Jan 2013 12:19:06 +0400 Subject: [PATCH] GenerationStrategy removed --- .../jet/codegen/KotlinCodegenFacade.java | 15 +++++-- .../jetbrains/jet/codegen/ScriptCodegen.java | 3 +- .../jet/codegen/state/GenerationStrategy.java | 33 -------------- .../state/StandardGenerationStrategy.java | 44 ------------------- .../compiler/KotlinToJVMBytecodeCompiler.java | 4 +- .../jet/codegen/CodegenTestCase.java | 3 +- .../jet/codegen/GenerationUtils.java | 3 +- .../codewindow/BytecodeToolwindow.java | 3 +- 8 files changed, 17 insertions(+), 91 deletions(-) delete mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationStrategy.java delete mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/state/StandardGenerationStrategy.java diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/KotlinCodegenFacade.java b/compiler/backend/src/org/jetbrains/jet/codegen/KotlinCodegenFacade.java index 1b24ca2fece..9e06553a8e6 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/KotlinCodegenFacade.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/KotlinCodegenFacade.java @@ -20,7 +20,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.codegen.state.GenerationStrategy; import org.jetbrains.jet.lang.descriptors.ScriptDescriptor; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetPsiUtil; @@ -38,7 +37,7 @@ import static org.jetbrains.jet.codegen.binding.CodegenBinding.registerClassName public class KotlinCodegenFacade { public static void compileCorrectFiles( @NotNull GenerationState state, - @NotNull GenerationStrategy strategy, @NotNull CompilationErrorHandler errorHandler + @NotNull CompilationErrorHandler errorHandler ) { for (JetFile file : state.getFiles()) { if (file.isScript()) { @@ -60,9 +59,19 @@ public class KotlinCodegenFacade { } for (Map.Entry> entry : namespaceGrouping.entrySet()) { - strategy.generateNamespace(state, entry.getKey(), entry.getValue(), errorHandler); + generateNamespace(state, entry.getKey(), entry.getValue(), errorHandler); } } + public static void generateNamespace( + @NotNull GenerationState state, + @NotNull FqName fqName, + @NotNull Collection jetFiles, + @NotNull CompilationErrorHandler errorHandler + ) { + NamespaceCodegen codegen = state.getFactory().forNamespace(fqName, jetFiles); + codegen.generate(errorHandler); + } + private KotlinCodegenFacade() {} } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java index bac7698ddeb..34b83e85feb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java @@ -27,7 +27,6 @@ import org.jetbrains.jet.codegen.context.CodegenContext; import org.jetbrains.jet.codegen.context.ScriptContext; import org.jetbrains.jet.codegen.signature.JvmMethodSignature; import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.codegen.state.StandardGenerationStrategy; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ScriptDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; @@ -251,7 +250,7 @@ public class ScriptCodegen extends MemberCodegen { registerClassNameForScript(state.getBindingTrace(), script, className); state.beforeCompile(); - StandardGenerationStrategy.INSTANCE.generateNamespace( + KotlinCodegenFacade.generateNamespace( state, JetPsiUtil.getFQName((JetFile) script.getContainingFile()), Collections.singleton((JetFile) script.getContainingFile()), diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationStrategy.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationStrategy.java deleted file mode 100644 index 43e48ade461..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationStrategy.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.codegen.state; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.codegen.CompilationErrorHandler; -import org.jetbrains.jet.lang.psi.JetFile; -import org.jetbrains.jet.lang.resolve.name.FqName; - -import java.util.Collection; - -public interface GenerationStrategy { - void generateNamespace( - @NotNull GenerationState state, - @NotNull FqName fqName, - @NotNull Collection jetFiles, - @NotNull CompilationErrorHandler errorHandler - ); -} diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/StandardGenerationStrategy.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/StandardGenerationStrategy.java deleted file mode 100644 index 4b3b4c343ca..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/state/StandardGenerationStrategy.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.codegen.state; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.codegen.CompilationErrorHandler; -import org.jetbrains.jet.codegen.NamespaceCodegen; -import org.jetbrains.jet.lang.psi.JetFile; -import org.jetbrains.jet.lang.resolve.name.FqName; - -import java.util.Collection; - -public class StandardGenerationStrategy implements GenerationStrategy { - public static final GenerationStrategy INSTANCE = new StandardGenerationStrategy(); - - private StandardGenerationStrategy() { - } - - @Override - public void generateNamespace( - @NotNull GenerationState state, - @NotNull FqName fqName, - @NotNull Collection jetFiles, - @NotNull CompilationErrorHandler errorHandler - ) { - NamespaceCodegen codegen = state.getFactory().forNamespace(fqName, jetFiles); - codegen.generate(errorHandler); - } - -} diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java index c290780e61c..f2cf3db0133 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java @@ -36,7 +36,6 @@ import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys; import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.codegen.state.Progress; -import org.jetbrains.jet.codegen.state.StandardGenerationStrategy; import org.jetbrains.jet.config.CommonConfigurationKeys; import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.lang.parsing.JetScriptDefinition; @@ -49,7 +48,6 @@ import org.jetbrains.jet.lang.resolve.ScriptNameUtil; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; import org.jetbrains.jet.lang.resolve.name.FqName; -import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.plugin.JetMainDetector; import org.jetbrains.jet.utils.ExceptionUtils; import org.jetbrains.jet.utils.KotlinPaths; @@ -360,7 +358,7 @@ public class KotlinToJVMBytecodeCompiler { configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false), /*generateDeclaredClasses = */true ); - KotlinCodegenFacade.compileCorrectFiles(generationState, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION); + KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION); CompilerPluginContext context = new CompilerPluginContext(project, exhaust.getBindingContext(), environment.getSourceFiles()); for (CompilerPlugin plugin : configuration.getList(CLIConfigurationKeys.COMPILER_PLUGINS)) { diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java index 14818b9544b..7c4449608f1 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java @@ -33,7 +33,6 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.codegen.state.StandardGenerationStrategy; import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; @@ -372,7 +371,7 @@ public abstract class CodegenTestCase extends UsefulTestCase { configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true), /*generateDeclaredClasses = */true ); - KotlinCodegenFacade.compileCorrectFiles(state, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION); + KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); return state; } diff --git a/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java b/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java index 943dd338b8e..d29fff89360 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java +++ b/compiler/tests/org/jetbrains/jet/codegen/GenerationUtils.java @@ -22,7 +22,6 @@ import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.codegen.state.StandardGenerationStrategy; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; @@ -59,7 +58,7 @@ public class GenerationUtils { public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List files) { analyzeExhaust.throwIfError(); GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust.getBindingContext(), files); - KotlinCodegenFacade.compileCorrectFiles(state, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION); + KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); return state; } } diff --git a/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java b/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java index 62c5699c055..04793a1be18 100644 --- a/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java +++ b/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java @@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.codegen.*; import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.codegen.state.StandardGenerationStrategy; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.plugin.internal.Location; import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade; @@ -92,7 +91,7 @@ public class BytecodeToolwindow extends JPanel implements Disposable { return printStackTraceToString(exhaust.getError()); } state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEXT, exhaust.getBindingContext(), Collections.singletonList(jetFile)); - KotlinCodegenFacade.compileCorrectFiles(state, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION); + KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION); } catch (ProcessCanceledException e) { throw e;