Add FirScope::getCallableNames function
This commit is contained in:
committed by
Ilya Kirillov
parent
1f3add49f4
commit
656086f90a
+22
@@ -55,6 +55,28 @@ class FirSignatureEnhancement(
|
|||||||
FirJavaEnhancementContext(session) { null }.copyWithNewDefaultTypeQualifiers(typeQualifierResolver, jsr305State, owner.annotations)
|
FirJavaEnhancementContext(session) { null }.copyWithNewDefaultTypeQualifiers(typeQualifierResolver, jsr305State, owner.annotations)
|
||||||
|
|
||||||
private val enhancements = mutableMapOf<FirCallableSymbol<*>, FirCallableSymbol<*>>()
|
private val enhancements = mutableMapOf<FirCallableSymbol<*>, FirCallableSymbol<*>>()
|
||||||
|
private val overriddenFunctions = mutableMapOf<FirFunctionSymbol<*>, Collection<FirFunctionSymbol<*>>>()
|
||||||
|
|
||||||
|
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||||
|
useSiteMemberScope.processPropertiesByName(name) process@{ original ->
|
||||||
|
|
||||||
|
val field = enhancements.getOrPut(original) { enhance(original, name) }
|
||||||
|
processor(field as FirVariableSymbol<*>)
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.processPropertiesByName(name, processor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return useSiteMemberScope.getCallableNames() + super.getCallableNames()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
|
useSiteMemberScope.processFunctionsByName(name) process@{ original ->
|
||||||
|
|
||||||
|
val function = enhancements.getOrPut(original) { enhance(original, name) }
|
||||||
|
processor(function as FirFunctionSymbol<*>)
|
||||||
|
}
|
||||||
|
|
||||||
fun enhancedFunction(
|
fun enhancedFunction(
|
||||||
function: FirFunctionSymbol<*>,
|
function: FirFunctionSymbol<*>,
|
||||||
|
|||||||
+4
@@ -45,6 +45,10 @@ class JavaClassUseSiteMemberScope(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return declaredMemberScope.getCallableNames() + superTypesScope.getCallableNames()
|
||||||
|
}
|
||||||
|
|
||||||
private fun generateAccessorSymbol(
|
private fun generateAccessorSymbol(
|
||||||
functionSymbol: FirFunctionSymbol<*>,
|
functionSymbol: FirFunctionSymbol<*>,
|
||||||
syntheticPropertyName: Name,
|
syntheticPropertyName: Name,
|
||||||
|
|||||||
+4
@@ -130,4 +130,8 @@ abstract class AbstractFirUseSiteMemberScope(
|
|||||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||||
declaredMemberScope.processDeclaredConstructors(processor)
|
declaredMemberScope.processDeclaredConstructors(processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return declaredMemberScope.getCallableNames() + superTypesScope.getCallableNames()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -76,6 +76,10 @@ class FirClassDeclaredMemberScope(
|
|||||||
) {
|
) {
|
||||||
nestedClassifierScope?.processClassifiersByNameWithSubstitution(name, processor)
|
nestedClassifierScope?.processClassifiersByNameWithSubstitution(name, processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return callablesIndex.keys
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
@@ -341,6 +341,10 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
return ProcessorAction.NEXT
|
return ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return scopes.flatMapTo(mutableSetOf()) { it.getCallableNames() }
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun prepareIntersectionScope(
|
fun prepareIntersectionScope(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
|
|||||||
@@ -44,4 +44,8 @@ class FirCompositeScope(private val scopes: Iterable<FirScope>) : FirScope() {
|
|||||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||||
return processComposite(FirScope::processPropertiesByName, name, processor)
|
return processComposite(FirScope::processPropertiesByName, name, processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> {
|
||||||
|
return scopes.flatMapTo(mutableSetOf()) { it.getCallableNames() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ abstract class FirScope {
|
|||||||
|
|
||||||
open fun mayContainName(name: Name) = true
|
open fun mayContainName(name: Name) = true
|
||||||
|
|
||||||
|
open fun getCallableNames(): Set<Name> = emptySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FirTypeScope.processOverriddenFunctionsAndSelf(
|
fun FirTypeScope.processOverriddenFunctionsAndSelf(
|
||||||
|
|||||||
Reference in New Issue
Block a user