Drop LazyTopDownAnalyzerForTopLevel

Replace it everywhere with LazyTopDownAnalyzer
This commit is contained in:
Alexander Udalov
2016-10-04 10:43:53 +03:00
parent 9c70094ceb
commit 0905b361d0
9 changed files with 23 additions and 66 deletions
@@ -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(
}
}
}
@@ -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);
}
}