[analysis api] optimize search for declarations in IDE
This commit is contained in:
+1
-1
@@ -158,7 +158,7 @@ internal class LLFirIdePredicateBasedProvider(
|
||||
val directAnnotations = annotationsOnDeclaration(declaration)
|
||||
val metaAnnotations = directAnnotations
|
||||
.asSequence()
|
||||
.mapNotNull { declarationProvider.getClassesByClassId(ClassId.topLevel(it)).singleOrNull() }
|
||||
.mapNotNull { declarationProvider.getAllClassesByClassId(ClassId.topLevel(it)).singleOrNull() }
|
||||
.flatMap { annotationsResolver.annotationsOnDeclaration(it) }
|
||||
.toSet()
|
||||
|
||||
|
||||
+3
-4
@@ -35,10 +35,9 @@ internal class LLFirProviderHelper(
|
||||
if (classId.isLocal) return null
|
||||
return executeOrReturnDefaultValueOnPCE(null) {
|
||||
cache.classifierByClassId.computeIfAbsent(classId) {
|
||||
val ktClass = when (val klass = declarationProvider.getClassesByClassId(classId).firstOrNull()) {
|
||||
null -> declarationProvider.getTypeAliasesByClassId(classId).firstOrNull()
|
||||
else -> if (klass.getClassId() == null) null else klass
|
||||
} ?: return@computeIfAbsent Optional.empty()
|
||||
val ktClass = declarationProvider.getClassLikeDeclarationByClassId(classId)
|
||||
?: return@computeIfAbsent Optional.empty()
|
||||
if (ktClass.getClassId() == null) return@computeIfAbsent Optional.empty()
|
||||
val firFile = firFileBuilder.buildRawFirFileWithCaching(ktClass.containingKtFile)
|
||||
val classifier = FirElementFinder.findElementIn<FirClassLikeDeclaration>(firFile) { classifier ->
|
||||
classifier.symbol.classId == classId
|
||||
|
||||
Reference in New Issue
Block a user