Project is available in codegen
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -58,11 +59,12 @@ public class GenerationState {
|
||||
private final JetTypeMapper typeMapper;
|
||||
|
||||
|
||||
public GenerationState(ClassBuilderFactory builderFactory, AnalyzeExhaust analyzeExhaust, List<JetFile> files) {
|
||||
this(builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED);
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, AnalyzeExhaust analyzeExhaust, List<JetFile> files) {
|
||||
this(project, builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED);
|
||||
}
|
||||
|
||||
public GenerationState(
|
||||
@NotNull Project project,
|
||||
ClassBuilderFactory builderFactory, Progress progress,
|
||||
@NotNull AnalyzeExhaust exhaust, @NotNull List<JetFile> files, @NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping
|
||||
) {
|
||||
@@ -72,7 +74,7 @@ public class GenerationState {
|
||||
bindingContext = exhaust.getBindingContext();
|
||||
this.injector = new InjectorForJvmCodegen(
|
||||
bindingContext,
|
||||
this.files, builtinToJavaTypesMapping, builderFactory.getClassBuilderMode(), this, builderFactory);
|
||||
this.files, builtinToJavaTypesMapping, builderFactory.getClassBuilderMode(), this, builderFactory, project);
|
||||
typeMapper = injector.getJetTypeMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
|
||||
package org.jetbrains.jet.di;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import java.util.List;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.BuiltinToJavaTypesMapping;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
||||
import org.jetbrains.jet.codegen.ClosureAnnotator;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.List;
|
||||
|
||||
/* This file is generated by org.jetbrains.jet.di.AllInjectorsGenerator. DO NOT EDIT! */
|
||||
public class InjectorForJetTypeMapper {
|
||||
@@ -39,8 +38,8 @@ public class InjectorForJetTypeMapper {
|
||||
private ClosureAnnotator closureAnnotator;
|
||||
|
||||
public InjectorForJetTypeMapper(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> listOfJetFile
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> listOfJetFile
|
||||
) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.listOfJetFile = listOfJetFile;
|
||||
@@ -58,6 +57,7 @@ public class InjectorForJetTypeMapper {
|
||||
closureAnnotator.setFiles(listOfJetFile);
|
||||
|
||||
jetTypeMapper.init();
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
@@ -67,4 +67,5 @@ public class InjectorForJetTypeMapper {
|
||||
public JetTypeMapper getJetTypeMapper() {
|
||||
return this.jetTypeMapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,14 +17,23 @@
|
||||
|
||||
package org.jetbrains.jet.di;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.List;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.codegen.BuiltinToJavaTypesMapping;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.ClassCodegen;
|
||||
import org.jetbrains.jet.codegen.ScriptCodegen;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.codegen.MemberCodegen;
|
||||
import org.jetbrains.jet.codegen.ClosureAnnotator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
/* This file is generated by org.jetbrains.jet.di.AllInjectorsGenerator. DO NOT EDIT! */
|
||||
public class InjectorForJvmCodegen {
|
||||
@@ -35,6 +44,7 @@ public class InjectorForJvmCodegen {
|
||||
private final ClassBuilderMode classBuilderMode;
|
||||
private final GenerationState generationState;
|
||||
private final ClassBuilderFactory classBuilderFactory;
|
||||
private final Project project;
|
||||
private JetTypeMapper jetTypeMapper;
|
||||
private ClassCodegen classCodegen;
|
||||
private ScriptCodegen scriptCodegen;
|
||||
@@ -44,12 +54,13 @@ public class InjectorForJvmCodegen {
|
||||
private ClosureAnnotator closureAnnotator;
|
||||
|
||||
public InjectorForJvmCodegen(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> listOfJetFile,
|
||||
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
|
||||
@NotNull ClassBuilderMode classBuilderMode,
|
||||
@NotNull GenerationState generationState,
|
||||
@NotNull ClassBuilderFactory classBuilderFactory
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> listOfJetFile,
|
||||
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
|
||||
@NotNull ClassBuilderMode classBuilderMode,
|
||||
@NotNull GenerationState generationState,
|
||||
@NotNull ClassBuilderFactory classBuilderFactory,
|
||||
@NotNull Project project
|
||||
) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.listOfJetFile = listOfJetFile;
|
||||
@@ -57,6 +68,7 @@ public class InjectorForJvmCodegen {
|
||||
this.classBuilderMode = classBuilderMode;
|
||||
this.generationState = generationState;
|
||||
this.classBuilderFactory = classBuilderFactory;
|
||||
this.project = project;
|
||||
this.jetTypeMapper = new JetTypeMapper();
|
||||
this.classCodegen = new ClassCodegen();
|
||||
this.scriptCodegen = new ScriptCodegen();
|
||||
@@ -91,6 +103,7 @@ public class InjectorForJvmCodegen {
|
||||
jetTypeMapper.init();
|
||||
|
||||
intrinsics.init();
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
@@ -101,6 +114,10 @@ public class InjectorForJvmCodegen {
|
||||
return this.generationState;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public JetTypeMapper getJetTypeMapper() {
|
||||
return this.jetTypeMapper;
|
||||
}
|
||||
@@ -128,4 +145,5 @@ public class InjectorForJvmCodegen {
|
||||
public ClosureAnnotator getClosureAnnotator() {
|
||||
return this.closureAnnotator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(CompilerMessageSeverity.LOGGING, message, CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
};
|
||||
GenerationState generationState = new GenerationState(ClassBuilderFactories.binaries(stubs), backendProgress,
|
||||
GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), backendProgress,
|
||||
exhaust, environment.getSourceFiles(),
|
||||
environment.getConfiguration().get(
|
||||
JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY,
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ReplInterpreter {
|
||||
earierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassName()));
|
||||
}
|
||||
|
||||
GenerationState generationState = new GenerationState(ClassBuilderFactories.binaries(false), backendProgress,
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), backendProgress,
|
||||
AnalyzeExhaust.success(trace.getBindingContext()), Collections.singletonList(psiFile),
|
||||
BuiltinToJavaTypesMapping.ENABLED);
|
||||
generationState.compileScript(psiFile.getScript(), scriptClassName, earierScripts, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
@@ -179,7 +179,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
||||
throw new IllegalStateException("failed to analyze: " + context.getError(), context.getError());
|
||||
}
|
||||
|
||||
final GenerationState state = new GenerationState(builderFactory, context, Collections.singletonList(file)) {
|
||||
final GenerationState state = new GenerationState(project, builderFactory, context, Collections.singletonList(file)) {
|
||||
@Override
|
||||
protected void generateNamespace(FqName fqName, Collection<JetFile> namespaceFiles, CompilationErrorHandler errorHandler, Progress progress) {
|
||||
PsiManager manager = PsiManager.getInstance(project);
|
||||
|
||||
@@ -306,7 +306,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
BuiltinsScopeExtensionMode.ALL);
|
||||
analyzeExhaust.throwIfError();
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
alreadyGenerated = new GenerationState(classBuilderFactory, analyzeExhaust, myFiles.getPsiFiles());
|
||||
alreadyGenerated = new GenerationState(myEnvironment.getProject(), classBuilderFactory, analyzeExhaust, myFiles.getPsiFiles());
|
||||
alreadyGenerated.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||
return alreadyGenerated;
|
||||
}
|
||||
|
||||
@@ -46,21 +46,21 @@ public class GenerationUtils {
|
||||
public static GenerationState compileFileGetGenerationStateForTest(@NotNull JetFile psiFile) {
|
||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||
psiFile, Collections.<AnalyzerScriptParameter>emptyList(), BuiltinsScopeExtensionMode.ALL);
|
||||
return compileFilesGetGenerationState(analyzeExhaust, Collections.singletonList(psiFile));
|
||||
return compileFilesGetGenerationState(psiFile.getProject(), analyzeExhaust, Collections.singletonList(psiFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GenerationState compileManyFilesGetGenerationStateForTest(@NotNull Project project, @NotNull List<JetFile> files) {
|
||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
project, files, Collections.<AnalyzerScriptParameter>emptyList(), Predicates.<PsiFile>alwaysTrue(), BuiltinsScopeExtensionMode.ALL);
|
||||
return compileFilesGetGenerationState(analyzeExhaust, files);
|
||||
return compileFilesGetGenerationState(project,analyzeExhaust, files);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static GenerationState compileFilesGetGenerationState(@NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) {
|
||||
public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) {
|
||||
analyzeExhaust.throwIfError();
|
||||
GenerationState state = new GenerationState(ClassBuilderFactories.TEST, analyzeExhaust, files);
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust, files);
|
||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class BytecodeToolwindow extends JPanel implements Disposable {
|
||||
if (binding.isError()) {
|
||||
return printStackTraceToString(binding.getError());
|
||||
}
|
||||
state = new GenerationState(ClassBuilderFactories.TEXT, binding, Collections.singletonList(file));
|
||||
state = new GenerationState(file.getProject(), ClassBuilderFactories.TEXT, binding, Collections.singletonList(file));
|
||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -193,6 +193,7 @@ public class AllInjectorsGenerator {
|
||||
generator.addParameter(ClassBuilderMode.class);
|
||||
generator.addPublicParameter(GenerationState.class);
|
||||
generator.addParameter(ClassBuilderFactory.class);
|
||||
generator.addPublicParameter(Project.class);
|
||||
generator.addPublicField(JetTypeMapper.class);
|
||||
generator.addPublicField(ClassCodegen.class);
|
||||
generator.addPublicField(ScriptCodegen.class);
|
||||
|
||||
Reference in New Issue
Block a user