FIR: Minor. Extract common parts in FirClassDeclaredMemberScope
This commit is contained in:
+13
-16
@@ -32,7 +32,7 @@ class FirClassDeclaredMemberScope(
|
|||||||
when (declaration) {
|
when (declaration) {
|
||||||
is FirCallableMemberDeclaration<*> -> {
|
is FirCallableMemberDeclaration<*> -> {
|
||||||
val name = when (declaration) {
|
val name = when (declaration) {
|
||||||
is FirConstructor -> constructorName
|
is FirConstructor -> CONSTRUCTOR_NAME
|
||||||
is FirVariable<*> -> declaration.name
|
is FirVariable<*> -> declaration.name
|
||||||
is FirSimpleFunction -> declaration.name
|
is FirSimpleFunction -> declaration.name
|
||||||
else -> continue@loop
|
else -> continue@loop
|
||||||
@@ -45,28 +45,25 @@ class FirClassDeclaredMemberScope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
if (name == constructorName) return
|
if (name == CONSTRUCTOR_NAME) return
|
||||||
val symbols = callablesIndex[name] ?: emptyList()
|
processCallables(name, processor)
|
||||||
for (symbol in symbols) {
|
|
||||||
if (symbol is FirFunctionSymbol<*>) {
|
|
||||||
processor(symbol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||||
val symbols = callablesIndex[constructorName] ?: return
|
processCallables(CONSTRUCTOR_NAME, processor)
|
||||||
for (symbol in symbols) {
|
|
||||||
if (symbol is FirConstructorSymbol) {
|
|
||||||
processor(symbol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||||
|
processCallables(name, processor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <reified D : FirCallableSymbol<*>> processCallables(
|
||||||
|
name: Name,
|
||||||
|
processor: (D) -> Unit
|
||||||
|
) {
|
||||||
val symbols = callablesIndex[name] ?: emptyList()
|
val symbols = callablesIndex[name] ?: emptyList()
|
||||||
for (symbol in symbols) {
|
for (symbol in symbols) {
|
||||||
if (symbol is FirVariableSymbol) {
|
if (symbol is D) {
|
||||||
processor(symbol)
|
processor(symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,4 +86,4 @@ class FirClassDeclaredMemberScope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val constructorName = Name.special("<init>")
|
private val CONSTRUCTOR_NAME = Name.special("<init>")
|
||||||
|
|||||||
Reference in New Issue
Block a user