Refactor: TopDownAnalysisParameters doesn't implement GlobalContext
This commit is contained in:
@@ -113,8 +113,6 @@ public class ReplInterpreter {
|
||||
GlobalContextImpl context = ContextPackage.GlobalContext();
|
||||
|
||||
TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.create(
|
||||
context.getStorageManager(),
|
||||
context.getExceptionTracker(),
|
||||
false,
|
||||
true
|
||||
);
|
||||
@@ -131,7 +129,7 @@ public class ReplInterpreter {
|
||||
|
||||
InjectorForReplWithJava injector = new InjectorForReplWithJava(
|
||||
project,
|
||||
topDownAnalysisParameters,
|
||||
context,
|
||||
trace,
|
||||
module,
|
||||
scriptDeclarationFactory,
|
||||
@@ -355,7 +353,7 @@ public class ReplInterpreter {
|
||||
@Nullable
|
||||
private ScriptDescriptor doAnalyze(@NotNull JetFile psiFile, @NotNull MessageCollector messageCollector) {
|
||||
scriptDeclarationFactory.setDelegateFactory(
|
||||
new FileBasedDeclarationProviderFactory(topDownAnalysisContext.getStorageManager(), Collections.singletonList(psiFile)));
|
||||
new FileBasedDeclarationProviderFactory(resolveSession.getStorageManager(), Collections.singletonList(psiFile)));
|
||||
|
||||
TopDownAnalysisContext context = topDownAnalyzer.analyzeDeclarations(
|
||||
topDownAnalysisContext.getTopDownAnalysisParameters(),
|
||||
|
||||
+7
-7
@@ -72,12 +72,13 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@NotNull
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegrationNoIncremental(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@NotNull ModuleDescriptorImpl module
|
||||
) {
|
||||
return analyzeFilesWithJavaIntegration(project, files, trace, topDownAnalysisParameters, module, null, null);
|
||||
return analyzeFilesWithJavaIntegration(project, globalContext, files, trace, topDownAnalysisParameters, module, null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -91,20 +92,19 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@Nullable IncrementalCacheProvider incrementalCacheProvider
|
||||
) {
|
||||
TopDownAnalysisParameters topDownAnalysisParameters = TopDownAnalysisParameters.create(
|
||||
globalContext.getStorageManager(),
|
||||
globalContext.getExceptionTracker(),
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
return analyzeFilesWithJavaIntegration(
|
||||
project, files, trace, topDownAnalysisParameters, module,
|
||||
project, globalContext, files, trace, topDownAnalysisParameters, module,
|
||||
moduleIds, incrementalCacheProvider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static AnalysisResult analyzeFilesWithJavaIntegration(
|
||||
Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
Collection<JetFile> files,
|
||||
BindingTrace trace,
|
||||
TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@@ -115,11 +115,11 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
List<JetFile> allFiles = JvmAnalyzerFacade.getAllFilesToAnalyze(project, null, files);
|
||||
|
||||
FileBasedDeclarationProviderFactory providerFactory =
|
||||
new FileBasedDeclarationProviderFactory(topDownAnalysisParameters.getStorageManager(), allFiles);
|
||||
new FileBasedDeclarationProviderFactory(globalContext.getStorageManager(), allFiles);
|
||||
|
||||
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(
|
||||
project,
|
||||
topDownAnalysisParameters,
|
||||
globalContext,
|
||||
trace,
|
||||
module,
|
||||
providerFactory,
|
||||
@@ -135,7 +135,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
|
||||
additionalProviders.add(
|
||||
new IncrementalPackageFragmentProvider(
|
||||
files, module, topDownAnalysisParameters.getStorageManager(),
|
||||
files, module, globalContext.getStorageManager(),
|
||||
injector.getDeserializationComponentsForJava().getComponents(),
|
||||
incrementalCache, moduleId
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BodiesResolveContext extends GlobalContext {
|
||||
public interface BodiesResolveContext {
|
||||
@ReadOnly
|
||||
Collection<JetFile> getFiles();
|
||||
|
||||
|
||||
@@ -101,18 +101,6 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
return secondaryConstructors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StorageManager getStorageManager() {
|
||||
return topDownAnalysisParameters.getStorageManager();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExceptionTracker getExceptionTracker() {
|
||||
return topDownAnalysisParameters.getExceptionTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<JetFile> getFiles() {
|
||||
return files;
|
||||
|
||||
@@ -27,59 +27,35 @@ import org.jetbrains.kotlin.storage.StorageManager;
|
||||
/**
|
||||
* Various junk that cannot be placed into context (yet).
|
||||
*/
|
||||
public class TopDownAnalysisParameters extends TypeLazinessToken implements GlobalContext {
|
||||
public class TopDownAnalysisParameters extends TypeLazinessToken {
|
||||
|
||||
@NotNull
|
||||
public static TopDownAnalysisParameters create(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ExceptionTracker exceptionTracker,
|
||||
boolean analyzingBootstrapLibrary,
|
||||
boolean declaredLocally
|
||||
) {
|
||||
return new TopDownAnalysisParameters(storageManager, exceptionTracker, analyzingBootstrapLibrary,
|
||||
declaredLocally, true);
|
||||
return new TopDownAnalysisParameters(analyzingBootstrapLibrary, declaredLocally, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TopDownAnalysisParameters createForLocalDeclarations(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ExceptionTracker exceptionTracker
|
||||
) {
|
||||
return new TopDownAnalysisParameters(storageManager, exceptionTracker, false, true, false);
|
||||
public static TopDownAnalysisParameters createForLocalDeclarations() {
|
||||
return new TopDownAnalysisParameters(false, true, false);
|
||||
}
|
||||
|
||||
@NotNull private final StorageManager storageManager;
|
||||
@NotNull private final ExceptionTracker exceptionTracker;
|
||||
private final boolean analyzingBootstrapLibrary;
|
||||
private final boolean declaredLocally;
|
||||
private final boolean lazyTopDownAnalysis;
|
||||
|
||||
private TopDownAnalysisParameters(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ExceptionTracker exceptionTracker,
|
||||
boolean analyzingBootstrapLibrary,
|
||||
boolean declaredLocally,
|
||||
boolean lazyTopDownAnalysis
|
||||
) {
|
||||
this.storageManager = storageManager;
|
||||
this.exceptionTracker = exceptionTracker;
|
||||
this.analyzingBootstrapLibrary = analyzingBootstrapLibrary;
|
||||
this.declaredLocally = declaredLocally;
|
||||
this.lazyTopDownAnalysis = lazyTopDownAnalysis;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public StorageManager getStorageManager() {
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ExceptionTracker getExceptionTracker() {
|
||||
return exceptionTracker;
|
||||
}
|
||||
|
||||
public boolean isAnalyzingBootstrapLibrary() {
|
||||
return analyzingBootstrapLibrary;
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class LocalClassifierAnalyzer(
|
||||
additionalCheckerProvider: AdditionalCheckerProvider,
|
||||
dynamicTypesSettings: DynamicTypesSettings
|
||||
) {
|
||||
val topDownAnalysisParameters = TopDownAnalysisParameters.create(globalContext.storageManager, globalContext.exceptionTracker, false, true)
|
||||
val topDownAnalysisParameters = TopDownAnalysisParameters.create(false, true)
|
||||
|
||||
val moduleDescriptor = DescriptorUtils.getContainingModule(containingDeclaration)
|
||||
val injector = InjectorForLazyLocalClassifierAnalyzer(
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.context.ContextPackage;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
|
||||
@@ -37,8 +38,6 @@ import org.jetbrains.kotlin.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor;
|
||||
import org.jetbrains.kotlin.storage.ExceptionTracker;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
|
||||
@@ -152,14 +151,13 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
ModuleDescriptorImpl module = TopDownAnalyzerFacadeForJVM.createSealedJavaModule();
|
||||
|
||||
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
||||
new LockBasedStorageManager(),
|
||||
new ExceptionTracker(), // dummy
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationNoIncremental(
|
||||
environment.getProject(),
|
||||
ContextPackage.GlobalContext(),
|
||||
environment.getSourceFiles(),
|
||||
trace,
|
||||
parameters,
|
||||
|
||||
@@ -56,14 +56,8 @@ public class LazyResolveTestUtil {
|
||||
public static ModuleDescriptor resolve(@NotNull Project project, @NotNull BindingTrace trace, @NotNull List<JetFile> sourceFiles) {
|
||||
ModuleDescriptorImpl module = TopDownAnalyzerFacadeForJVM.createSealedJavaModule();
|
||||
|
||||
GlobalContextImpl globalContext = ContextPackage.GlobalContext();
|
||||
TopDownAnalysisParameters params = TopDownAnalysisParameters.create(
|
||||
globalContext.getStorageManager(),
|
||||
globalContext.getExceptionTracker(),
|
||||
false, false
|
||||
);
|
||||
|
||||
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationNoIncremental(project, sourceFiles, trace, params, module);
|
||||
TopDownAnalysisParameters params = TopDownAnalysisParameters.create(false, false);
|
||||
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationNoIncremental(project, ContextPackage.GlobalContext(), sourceFiles, trace, params, module);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization
|
||||
|
||||
import com.google.common.base.Predicates
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
@@ -27,7 +26,6 @@ import org.jetbrains.kotlin.di.InjectorForTopDownAnalyzerForJvm
|
||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.structure.reflect.classId
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisParameters
|
||||
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.test.*
|
||||
@@ -57,13 +55,10 @@ public abstract class AbstractLocalClassProtoTest : TestCaseWithTmpdir() {
|
||||
)
|
||||
val module = TopDownAnalyzerFacadeForJVM.createSealedJavaModule()
|
||||
val globalContext = GlobalContext()
|
||||
val params = TopDownAnalysisParameters.create(
|
||||
globalContext.storageManager, globalContext.exceptionTracker, false, false
|
||||
)
|
||||
val providerFactory = FileBasedDeclarationProviderFactory(globalContext.storageManager, emptyList())
|
||||
|
||||
val injector = InjectorForTopDownAnalyzerForJvm(
|
||||
environment.project, params, CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(), module,
|
||||
environment.project, globalContext, CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(), module,
|
||||
providerFactory, GlobalSearchScope.allScope(environment.project)
|
||||
)
|
||||
module.initialize(injector.getJavaDescriptorResolver().packageFragmentProvider)
|
||||
|
||||
Reference in New Issue
Block a user