Drop LazyTopDownAnalyzerForTopLevel
Replace it everywhere with LazyTopDownAnalyzer
This commit is contained in:
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.script.ScriptPriorities
|
||||
|
||||
class CliReplAnalyzerEngine(environment: KotlinCoreEnvironment) {
|
||||
private val topDownAnalysisContext: TopDownAnalysisContext
|
||||
private val topDownAnalyzer: LazyTopDownAnalyzerForTopLevel
|
||||
private val topDownAnalyzer: LazyTopDownAnalyzer
|
||||
private val resolveSession: ResolveSession
|
||||
private val scriptDeclarationFactory: ScriptMutableDeclarationProviderFactory
|
||||
val module: ModuleDescriptorImpl
|
||||
@@ -67,7 +67,7 @@ class CliReplAnalyzerEngine(environment: KotlinCoreEnvironment) {
|
||||
this.topDownAnalysisContext = TopDownAnalysisContext(
|
||||
TopDownAnalysisMode.LocalDeclarations, DataFlowInfoFactory.EMPTY, resolveSession.declarationScopeProvider
|
||||
)
|
||||
this.topDownAnalyzer = container.get<LazyTopDownAnalyzerForTopLevel>()
|
||||
this.topDownAnalyzer = container.get<LazyTopDownAnalyzer>()
|
||||
|
||||
moduleContext.initializeModuleContents(CompositePackageFragmentProvider(
|
||||
listOf(
|
||||
|
||||
@@ -56,7 +56,6 @@ fun StorageComponentContainer.configureJavaTopDownAnalysis(
|
||||
useImpl<ResolveSession>()
|
||||
|
||||
useImpl<LazyTopDownAnalyzer>()
|
||||
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
||||
useImpl<JavaDescriptorResolver>()
|
||||
useImpl<DeserializationComponentsForJava>()
|
||||
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.JvmBuiltIns
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisMode
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisCompletedHandlerExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
|
||||
@@ -152,7 +152,7 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
additionalProviders
|
||||
))
|
||||
|
||||
container.get<LazyTopDownAnalyzerForTopLevel>().analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, files)
|
||||
container.get<LazyTopDownAnalyzer>().analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, files)
|
||||
|
||||
for (extension in AnalysisCompletedHandlerExtension.getInstances(project)) {
|
||||
val result = extension.analysisCompleted(project, module, trace, files)
|
||||
|
||||
@@ -96,7 +96,7 @@ fun createContainerForLazyBodyResolve(
|
||||
useInstance(kotlinCodeAnalyzer.fileScopeProvider)
|
||||
useInstance(bodyResolveCache)
|
||||
useInstance(languageVersionSettings)
|
||||
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
||||
useImpl<LazyTopDownAnalyzer>()
|
||||
useImpl<BasicAbsentDescriptorHandler>()
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,11 @@ class LazyTopDownAnalyzer(
|
||||
private val languageVersionSettings: LanguageVersionSettings,
|
||||
private val classifierUsageCheckers: Iterable<ClassifierUsageChecker>
|
||||
) {
|
||||
fun analyzeDeclarations(topDownAnalysisMode: TopDownAnalysisMode, declarations: Collection<PsiElement>, outerDataFlowInfo: DataFlowInfo): TopDownAnalysisContext {
|
||||
|
||||
fun analyzeDeclarations(
|
||||
topDownAnalysisMode: TopDownAnalysisMode,
|
||||
declarations: Collection<PsiElement>,
|
||||
outerDataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY
|
||||
): TopDownAnalysisContext {
|
||||
val c = TopDownAnalysisContext(topDownAnalysisMode, outerDataFlowInfo, declarationScopeProvider)
|
||||
|
||||
val topLevelFqNames = HashMultimap.create<FqName, KtElement>()
|
||||
@@ -108,7 +111,7 @@ class LazyTopDownAnalyzer(
|
||||
val descriptor = lazyDeclarationResolver.getClassDescriptor(classOrObject, location) as ClassDescriptorWithResolutionScopes
|
||||
|
||||
c.declaredClasses.put(classOrObject, descriptor)
|
||||
registerDeclarations(classOrObject.getDeclarations())
|
||||
registerDeclarations(classOrObject.declarations)
|
||||
registerTopLevelFqName(topLevelFqNames, classOrObject, descriptor)
|
||||
|
||||
checkClassOrObjectDeclarations(classOrObject, descriptor)
|
||||
@@ -116,7 +119,7 @@ class LazyTopDownAnalyzer(
|
||||
|
||||
private fun checkClassOrObjectDeclarations(classOrObject: KtClassOrObject, classDescriptor: ClassDescriptor) {
|
||||
var companionObjectAlreadyFound = false
|
||||
for (jetDeclaration in classOrObject.getDeclarations()) {
|
||||
for (jetDeclaration in classOrObject.declarations) {
|
||||
if (jetDeclaration is KtObjectDeclaration && jetDeclaration.isCompanion()) {
|
||||
if (companionObjectAlreadyFound) {
|
||||
trace.report(MANY_COMPANION_OBJECTS.on(jetDeclaration))
|
||||
@@ -266,5 +269,3 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.kotlin.resolve;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class LazyTopDownAnalyzerForTopLevel {
|
||||
private final LazyTopDownAnalyzer lazyTopDownAnalyzer;
|
||||
|
||||
public LazyTopDownAnalyzerForTopLevel(@NotNull LazyTopDownAnalyzer lazyTopDownAnalyzer) {
|
||||
this.lazyTopDownAnalyzer = lazyTopDownAnalyzer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TopDownAnalysisContext analyzeDeclarations(
|
||||
@NotNull TopDownAnalysisMode topDownAnalysisMode,
|
||||
@NotNull Collection<? extends PsiElement> elements
|
||||
) {
|
||||
return lazyTopDownAnalyzer.analyzeDeclarations(topDownAnalysisMode, elements, DataFlowInfoFactory.EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
|
||||
@@ -326,8 +327,8 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
DslKt.getService(container, JavaDescriptorResolver.class).getPackageFragmentProvider()
|
||||
)));
|
||||
|
||||
DslKt.getService(container, LazyTopDownAnalyzerForTopLevel.class).analyzeDeclarations(
|
||||
TopDownAnalysisMode.TopLevelDeclarations, files
|
||||
DslKt.getService(container, LazyTopDownAnalyzer.class).analyzeDeclarations(
|
||||
TopDownAnalysisMode.TopLevelDeclarations, files, DataFlowInfo.Companion.getEMPTY()
|
||||
);
|
||||
|
||||
return AnalysisResult.success(moduleTrace.getBindingContext(), moduleDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user