Do not create TopDownAnalysisContext in injectors
This commit is contained in:
@@ -318,7 +318,7 @@ public class ReplInterpreter {
|
||||
return null;
|
||||
}
|
||||
|
||||
ScriptDescriptor scriptDescriptor = injector.getTopDownAnalysisContext().getScripts().get(psiFile.getScript());
|
||||
ScriptDescriptor scriptDescriptor = topDownAnalysisContext.getScripts().get(psiFile.getScript());
|
||||
lastLineScope = trace.get(BindingContext.SCRIPT_SCOPE, scriptDescriptor);
|
||||
if (lastLineScope == null) {
|
||||
throw new IllegalStateException("last line scope is not initialized");
|
||||
|
||||
+1
-8
@@ -23,7 +23,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisContext;
|
||||
import org.jetbrains.jet.lang.resolve.MutablePackageFragmentProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaClassFinderImpl;
|
||||
@@ -78,7 +77,6 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private final ModuleDescriptorImpl moduleDescriptor;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final TopDownAnalyzer topDownAnalyzer;
|
||||
private final TopDownAnalysisContext topDownAnalysisContext;
|
||||
private final MutablePackageFragmentProvider mutablePackageFragmentProvider;
|
||||
private final JavaDescriptorResolver javaDescriptorResolver;
|
||||
private final JavaClassFinderImpl javaClassFinder;
|
||||
@@ -133,7 +131,6 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.topDownAnalyzer = new TopDownAnalyzer();
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext(topDownAnalysisParameters);
|
||||
this.mutablePackageFragmentProvider = new MutablePackageFragmentProvider(getModuleDescriptor());
|
||||
this.javaClassFinder = new JavaClassFinderImpl();
|
||||
this.virtualFileFinder = org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder.SERVICE.getInstance(project);
|
||||
@@ -232,7 +229,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
expressionTypingComponents.setExpressionTypingServices(expressionTypingServices);
|
||||
expressionTypingComponents.setExpressionTypingUtils(expressionTypingUtils);
|
||||
expressionTypingComponents.setForLoopConventionsChecker(forLoopConventionsChecker);
|
||||
expressionTypingComponents.setGlobalContext(topDownAnalysisContext);
|
||||
expressionTypingComponents.setGlobalContext(topDownAnalysisParameters);
|
||||
expressionTypingComponents.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
|
||||
forLoopConventionsChecker.setExpressionTypingServices(expressionTypingServices);
|
||||
@@ -321,10 +318,6 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
return this.topDownAnalyzer;
|
||||
}
|
||||
|
||||
public TopDownAnalysisContext getTopDownAnalysisContext() {
|
||||
return this.topDownAnalysisContext;
|
||||
}
|
||||
|
||||
public JavaDescriptorResolver getJavaDescriptorResolver() {
|
||||
return this.javaDescriptorResolver;
|
||||
}
|
||||
|
||||
+2
-2
@@ -229,9 +229,9 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
||||
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module);
|
||||
try {
|
||||
module.addFragmentProvider(DependencyKind.BINARIES, injector.getJavaDescriptorResolver().getPackageFragmentProvider());
|
||||
injector.getTopDownAnalyzer().analyzeFiles(files, scriptParameters);
|
||||
TopDownAnalysisContext topDownAnalysisContext = injector.getTopDownAnalyzer().analyzeFiles(files, scriptParameters);
|
||||
BodiesResolveContext bodiesResolveContext = storeContextForBodiesResolve ?
|
||||
new CachedBodiesResolveContext(injector.getTopDownAnalysisContext()) :
|
||||
new CachedBodiesResolveContext(topDownAnalysisContext) :
|
||||
null;
|
||||
return AnalyzeExhaust.success(trace.getBindingContext(), bodiesResolveContext, module);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,11 @@ package org.jetbrains.jet.di;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||
import org.jetbrains.jet.context.SimpleGlobalContext;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
@@ -53,13 +51,11 @@ public class InjectorForBodyResolve {
|
||||
|
||||
private final Project project;
|
||||
private final TopDownAnalysisParameters topDownAnalysisParameters;
|
||||
private final ExceptionTracker exceptionTracker;
|
||||
private final StorageManager storageManager;
|
||||
private final BindingTrace bindingTrace;
|
||||
private final ModuleDescriptor moduleDescriptor;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final BodyResolver bodyResolver;
|
||||
private final SimpleGlobalContext simpleGlobalContext;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
private final CallResolver callResolver;
|
||||
private final ArgumentTypeResolver argumentTypeResolver;
|
||||
@@ -88,13 +84,11 @@ public class InjectorForBodyResolve {
|
||||
) {
|
||||
this.project = project;
|
||||
this.topDownAnalysisParameters = topDownAnalysisParameters;
|
||||
this.exceptionTracker = topDownAnalysisParameters.getExceptionTracker();
|
||||
this.storageManager = topDownAnalysisParameters.getStorageManager();
|
||||
this.bindingTrace = bindingTrace;
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.bodyResolver = new BodyResolver();
|
||||
this.simpleGlobalContext = new SimpleGlobalContext(storageManager, exceptionTracker);
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
this.argumentTypeResolver = new ArgumentTypeResolver();
|
||||
@@ -150,7 +144,7 @@ public class InjectorForBodyResolve {
|
||||
expressionTypingComponents.setExpressionTypingServices(expressionTypingServices);
|
||||
expressionTypingComponents.setExpressionTypingUtils(expressionTypingUtils);
|
||||
expressionTypingComponents.setForLoopConventionsChecker(forLoopConventionsChecker);
|
||||
expressionTypingComponents.setGlobalContext(simpleGlobalContext);
|
||||
expressionTypingComponents.setGlobalContext(topDownAnalysisParameters);
|
||||
expressionTypingComponents.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
|
||||
forLoopConventionsChecker.setExpressionTypingServices(expressionTypingServices);
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisContext;
|
||||
import org.jetbrains.jet.lang.resolve.MutablePackageFragmentProvider;
|
||||
import org.jetbrains.jet.lang.types.DependencyClassByQualifiedNameResolverDummyImpl;
|
||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||
@@ -67,7 +66,6 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
private final ModuleDescriptorImpl moduleDescriptor;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final TopDownAnalyzer topDownAnalyzer;
|
||||
private final TopDownAnalysisContext topDownAnalysisContext;
|
||||
private final MutablePackageFragmentProvider mutablePackageFragmentProvider;
|
||||
private final DependencyClassByQualifiedNameResolverDummyImpl dependencyClassByQualifiedNameResolverDummy;
|
||||
private final BodyResolver bodyResolver;
|
||||
@@ -111,7 +109,6 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.topDownAnalyzer = new TopDownAnalyzer();
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext(topDownAnalysisParameters);
|
||||
this.mutablePackageFragmentProvider = new MutablePackageFragmentProvider(getModuleDescriptor());
|
||||
this.dependencyClassByQualifiedNameResolverDummy = new DependencyClassByQualifiedNameResolverDummyImpl();
|
||||
this.bodyResolver = new BodyResolver();
|
||||
@@ -187,7 +184,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
expressionTypingComponents.setExpressionTypingServices(expressionTypingServices);
|
||||
expressionTypingComponents.setExpressionTypingUtils(expressionTypingUtils);
|
||||
expressionTypingComponents.setForLoopConventionsChecker(forLoopConventionsChecker);
|
||||
expressionTypingComponents.setGlobalContext(topDownAnalysisContext);
|
||||
expressionTypingComponents.setGlobalContext(topDownAnalysisParameters);
|
||||
expressionTypingComponents.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
|
||||
forLoopConventionsChecker.setExpressionTypingServices(expressionTypingServices);
|
||||
@@ -264,8 +261,4 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
return this.topDownAnalyzer;
|
||||
}
|
||||
|
||||
public TopDownAnalysisContext getTopDownAnalysisContext() {
|
||||
return this.topDownAnalysisContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.context.GlobalContext;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
@@ -27,7 +28,7 @@ import java.util.List;
|
||||
/**
|
||||
* Various junk that cannot be placed into context (yet).
|
||||
*/
|
||||
public class TopDownAnalysisParameters {
|
||||
public class TopDownAnalysisParameters implements GlobalContext {
|
||||
@NotNull
|
||||
private final StorageManager storageManager;
|
||||
@NotNull
|
||||
@@ -55,13 +56,13 @@ public class TopDownAnalysisParameters {
|
||||
this.scriptParameters = scriptParameters;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
@NotNull
|
||||
public StorageManager getStorageManager() {
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
@NotNull
|
||||
public ExceptionTracker getExceptionTracker() {
|
||||
return exceptionTracker;
|
||||
|
||||
@@ -216,7 +216,8 @@ public class TopDownAnalyzer {
|
||||
);
|
||||
}
|
||||
|
||||
public void analyzeFiles(
|
||||
@NotNull
|
||||
public TopDownAnalysisContext analyzeFiles(
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull List<AnalyzerScriptParameter> scriptParameters) {
|
||||
((ModuleDescriptorImpl) moduleDescriptor).addFragmentProvider(DependencyKind.SOURCES, packageFragmentProvider);
|
||||
@@ -227,8 +228,10 @@ public class TopDownAnalyzer {
|
||||
// dummy builder is used because "root" is module descriptor,
|
||||
// packages added to module explicitly in
|
||||
|
||||
doProcess(new TopDownAnalysisContext(topDownAnalysisParameters), JetModuleUtil.getSubpackagesOfRootScope(moduleDescriptor),
|
||||
TopDownAnalysisContext c = new TopDownAnalysisContext(topDownAnalysisParameters);
|
||||
doProcess(c, JetModuleUtil.getSubpackagesOfRootScope(moduleDescriptor),
|
||||
new PackageLikeBuilderDummy(), files);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user