Add FirSymbolProvider::getAllCallableNamesInPackage function
- Also, fix implementation of `getCallableNames` in few cases
This commit is contained in:
committed by
Ilya Kirillov
parent
97d4918ed3
commit
0f5fc1fa99
+2
@@ -55,6 +55,8 @@ abstract class FirSymbolProvider : FirSessionComponent {
|
||||
open fun getNestedClassesNamesInClass(classId: ClassId): Set<Name> = emptySet()
|
||||
|
||||
abstract fun getPackage(fqName: FqName): FqName? // TODO: Replace to symbol sometime
|
||||
|
||||
open fun getAllCallableNamesInPackage(): Set<Name> = emptySet()
|
||||
}
|
||||
|
||||
fun FirSession.getNestedClassifierScope(lookupTag: ConeClassLikeLookupTag): FirScope? =
|
||||
|
||||
+4
@@ -46,4 +46,8 @@ class FirCompositeSymbolProvider(val providers: List<FirSymbolProvider>) : FirSy
|
||||
override fun getNestedClassesNamesInClass(classId: ClassId): Set<Name> {
|
||||
return providers.flatMapTo(mutableSetOf()) { it.getNestedClassesNamesInClass(classId) }
|
||||
}
|
||||
|
||||
override fun getAllCallableNamesInPackage(): Set<Name> {
|
||||
return providers.flatMapTo(mutableSetOf()) { it.getAllCallableNamesInPackage() }
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -76,6 +76,12 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: KotlinSc
|
||||
klass.accept(FirRecorder, state to owner.file)
|
||||
}
|
||||
|
||||
override fun getAllCallableNamesInPackage(): Set<Name> {
|
||||
return state.callableMap.keys.asSequence()
|
||||
.filter { it.className == null }
|
||||
.mapTo(mutableSetOf()) { it.callableName }
|
||||
}
|
||||
|
||||
private val FirAnnotatedDeclaration.file: FirFile
|
||||
get() = when (this) {
|
||||
is FirFile -> this
|
||||
|
||||
@@ -71,5 +71,5 @@ class FirLocalScope private constructor(
|
||||
|
||||
override fun mayContainName(name: Name) = properties.containsKey(name) || functions[name].isNotEmpty() || classes.containsKey(name)
|
||||
|
||||
override fun getCallableNames(): Set<Name> = properties.keys + functions.keys + classes.keys
|
||||
override fun getCallableNames(): Set<Name> = properties.keys + functions.keys
|
||||
}
|
||||
|
||||
@@ -56,4 +56,8 @@ class FirPackageMemberScope(val fqName: FqName, val session: FirSession) : FirSc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCallableNames(): Set<Name> {
|
||||
return symbolProvider.getAllCallableNamesInPackage()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,8 @@ class FirStaticScope(private val delegateScope: FirScope) : FirScope() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCallableNames(): Set<Name> {
|
||||
return delegateScope.getCallableNames()
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -166,6 +166,11 @@ internal class FirIdeProvider(
|
||||
// TODO: check that this implementation is correct
|
||||
cacheProvider.recordGeneratedMember(owner, klass)
|
||||
}
|
||||
|
||||
// TODO this should be reworked because [FirIdeProvider] should not have such method
|
||||
override fun getAllCallableNamesInPackage(): Set<Name> {
|
||||
return cacheProvider.getAllCallableNamesInPackage()
|
||||
}
|
||||
}
|
||||
|
||||
internal val FirSession.firIdeProvider: FirIdeProvider by FirSession.sessionComponentAccessor()
|
||||
Reference in New Issue
Block a user