[FIR IDE] Initial descriptor-based implementation of the Analysis API
This commit is contained in:
committed by
teamcityserver
parent
e2c9be0932
commit
516dd825c2
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtCallResolver
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
abstract class AbstractKtCallResolver : KtCallResolver() {
|
||||
protected companion object {
|
||||
val kotlinFunctionInvokeCallableIds = (0..23).flatMapTo(hashSetOf()) { arity ->
|
||||
listOf(
|
||||
CallableId(StandardNames.getFunctionClassId(arity), OperatorNameConventions.INVOKE),
|
||||
CallableId(StandardNames.getSuspendFunctionClassId(arity), OperatorNameConventions.INVOKE)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtCompositeScope
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScopeNameFilter
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassifierSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
class SimpleKtCompositeScope(
|
||||
override val subScopes: List<KtScope>,
|
||||
override val token: ValidityToken
|
||||
) : KtCompositeScope, ValidityTokenOwner {
|
||||
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 getAllSymbols(): Sequence<KtSymbol> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getAllSymbols()) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCallableSymbols(nameFilter: KtScopeNameFilter): Sequence<KtCallableSymbol> = withValidityAssertion {
|
||||
sequence {
|
||||
subScopes.forEach { yieldAll(it.getCallableSymbols(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) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user