[Analysis API] optimize scope members processing when a candidate name set is known
Use KtScope.getCallableSymbols/getClassifier symbols overloads which accept a candidate name set. ^KT-58653
This commit is contained in:
committed by
Space Team
parent
29be88e3c9
commit
41976a2932
+1
-1
@@ -40,7 +40,7 @@ internal class KtFirSymbolProviderByJavaPsi(
|
|||||||
val classSymbol = getNamedClassSymbol(containingClass) ?: return null
|
val classSymbol = getNamedClassSymbol(containingClass) ?: return null
|
||||||
return with(analysisSession) {
|
return with(analysisSession) {
|
||||||
classSymbol.getDeclaredMemberScope()
|
classSymbol.getDeclaredMemberScope()
|
||||||
.getCallableSymbols { it == name }
|
.getCallableSymbols(name)
|
||||||
.firstOrNull { it.psi == callable }
|
.firstOrNull { it.psi == callable }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -56,15 +56,15 @@ internal object KDocReferenceResolver {
|
|||||||
.dropLast(1)
|
.dropLast(1)
|
||||||
.fold(initialScope) { currentScope, fqNamePart ->
|
.fold(initialScope) { currentScope, fqNamePart ->
|
||||||
currentScope
|
currentScope
|
||||||
.getClassifierSymbols { it == fqNamePart }
|
.getClassifierSymbols(fqNamePart)
|
||||||
.mapNotNull { (it as? KtSymbolWithMembers)?.getDeclaredMemberScope() }
|
.mapNotNull { (it as? KtSymbolWithMembers)?.getDeclaredMemberScope() }
|
||||||
.toList()
|
.toList()
|
||||||
.asCompositeScope()
|
.asCompositeScope()
|
||||||
}
|
}
|
||||||
|
|
||||||
val shortName = fqName.shortName()
|
val shortName = fqName.shortName()
|
||||||
addAll(scope.getCallableSymbols { it == shortName })
|
addAll(scope.getCallableSymbols(shortName))
|
||||||
addAll(scope.getClassifierSymbols { it == shortName })
|
addAll(scope.getClassifierSymbols(shortName))
|
||||||
}
|
}
|
||||||
|
|
||||||
context(KtAnalysisSession)
|
context(KtAnalysisSession)
|
||||||
@@ -122,7 +122,7 @@ internal object KDocReferenceResolver {
|
|||||||
else -> {
|
else -> {
|
||||||
getClassOrObjectSymbolByClassId(classId)
|
getClassOrObjectSymbolByClassId(classId)
|
||||||
?.getDeclaredMemberScope()
|
?.getDeclaredMemberScope()
|
||||||
?.getCallableSymbols { it == callableId.callableName }
|
?.getCallableSymbols(callableId.callableName)
|
||||||
?.let(::addAll)
|
?.let(::addAll)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -66,8 +66,7 @@ sealed class SymbolData {
|
|||||||
val classSymbol =
|
val classSymbol =
|
||||||
getClassOrObjectSymbolByClassId(classId)
|
getClassOrObjectSymbolByClassId(classId)
|
||||||
?: error("Class $classId is not found")
|
?: error("Class $classId is not found")
|
||||||
classSymbol.getDeclaredMemberScope().getCallableSymbols()
|
classSymbol.getDeclaredMemberScope().getCallableSymbols(callableId.callableName)
|
||||||
.filter { (it as? KtNamedSymbol)?.name == callableId.callableName }
|
|
||||||
.toList()
|
.toList()
|
||||||
}
|
}
|
||||||
if (symbols.isEmpty()) {
|
if (symbols.isEmpty()) {
|
||||||
|
|||||||
+1
-1
@@ -197,7 +197,7 @@ internal open class SymbolLightClassForClassOrObject : SymbolLightClassForNamedC
|
|||||||
// Compiler will generate 'equals/hashCode/toString' for data class if they are not final.
|
// Compiler will generate 'equals/hashCode/toString' for data class if they are not final.
|
||||||
// We want to mimic that.
|
// We want to mimic that.
|
||||||
val nonFinalFunctionsFromAny = classOrObjectSymbol.getMemberScope()
|
val nonFinalFunctionsFromAny = classOrObjectSymbol.getMemberScope()
|
||||||
.getCallableSymbols { name -> name.isFromAny }
|
.getCallableSymbols(EQUALS, HASHCODE_NAME, TO_STRING)
|
||||||
.filterIsInstance<KtFunctionSymbol>()
|
.filterIsInstance<KtFunctionSymbol>()
|
||||||
.filterNot {
|
.filterNot {
|
||||||
it.modality == Modality.FINAL || (it.getContainingSymbol() as? KtNamedClassOrObjectSymbol)?.modality == Modality.FINAL
|
it.modality == Modality.FINAL || (it.getContainingSymbol() as? KtNamedClassOrObjectSymbol)?.modality == Modality.FINAL
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ internal class SymbolLightClassForInlineClass : SymbolLightClassForClassOrObject
|
|||||||
?.singleOrNull()
|
?.singleOrNull()
|
||||||
|
|
||||||
if (inlineClassParameterSymbol != null) {
|
if (inlineClassParameterSymbol != null) {
|
||||||
val propertySymbol = declaredMemberScope.getCallableSymbols { it == inlineClassParameterSymbol.name }
|
val propertySymbol = declaredMemberScope.getCallableSymbols(inlineClassParameterSymbol.name)
|
||||||
.singleOrNull { it is KtPropertySymbol && it.isFromPrimaryConstructor } as? KtPropertySymbol
|
.singleOrNull { it is KtPropertySymbol && it.isFromPrimaryConstructor } as? KtPropertySymbol
|
||||||
|
|
||||||
if (propertySymbol != null) {
|
if (propertySymbol != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user