[analysis api] introduce KtTypeScope which will contain callable signatures

This commit is contained in:
Ilya Kirillov
2022-06-07 16:16:55 +02:00
parent 3ee0410c77
commit 3033a91567
8 changed files with 222 additions and 46 deletions
@@ -0,0 +1,61 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.api.impl.base.scopes
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.analysis.api.scopes.KtScopeNameFilter
import org.jetbrains.kotlin.analysis.api.scopes.KtTypeScope
import org.jetbrains.kotlin.analysis.api.symbols.*
import org.jetbrains.kotlin.name.Name
@KtAnalysisApiInternals
class KtCompositeTypeScope(
private val subScopes: List<KtTypeScope>,
override val token: KtLifetimeToken
) : KtTypeScope {
override fun getAllPossibleNames(): Set<Name> = withValidityAssertion {
buildSet {
subScopes.flatMapTo(this) { it.getAllPossibleNames() }
}
}
override fun getPossibleCallableNames(): Set<Name> = withValidityAssertion {
buildSet {
subScopes.flatMapTo(this) { it.getPossibleCallableNames() }
}
}
override fun getPossibleClassifierNames(): Set<Name> = withValidityAssertion {
buildSet {
subScopes.flatMapTo(this) { it.getPossibleClassifierNames() }
}
}
override fun getCallableSignatures(nameFilter: KtScopeNameFilter): Sequence<KtSignature<*>> = withValidityAssertion {
sequence {
subScopes.forEach { yieldAll(it.getCallableSignatures(nameFilter)) }
}
}
override fun getClassifierSymbols(nameFilter: KtScopeNameFilter): Sequence<KtClassifierSymbol> = withValidityAssertion {
sequence {
subScopes.forEach { yieldAll(it.getClassifierSymbols(nameFilter)) }
}
}
override fun getConstructors(): Sequence<KtConstructorSymbol> = withValidityAssertion {
sequence {
subScopes.forEach { yieldAll(it.getConstructors()) }
}
}
override fun mayContainName(name: Name): Boolean = withValidityAssertion {
subScopes.any { it.mayContainName(name) }
}
}