GenerationStrategy removed

This commit is contained in:
Andrey Breslav
2013-01-17 12:19:06 +04:00
parent 99aee736d1
commit e1831877b7
8 changed files with 17 additions and 91 deletions
@@ -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<FqName, Collection<JetFile>> 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<JetFile> jetFiles,
@NotNull CompilationErrorHandler errorHandler
) {
NamespaceCodegen codegen = state.getFactory().forNamespace(fqName, jetFiles);
codegen.generate(errorHandler);
}
private KotlinCodegenFacade() {}
}
@@ -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()),
@@ -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<JetFile> jetFiles,
@NotNull CompilationErrorHandler errorHandler
);
}
@@ -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<JetFile> jetFiles,
@NotNull CompilationErrorHandler errorHandler
) {
NamespaceCodegen codegen = state.getFactory().forNamespace(fqName, jetFiles);
codegen.generate(errorHandler);
}
}