FIR IDE: add type parameters support to scopes

This commit is contained in:
Ilya Kirillov
2020-09-01 19:17:43 +03:00
parent c0e9f05921
commit 6d18bb6ba2
9 changed files with 51 additions and 55 deletions
@@ -14,24 +14,24 @@ import org.jetbrains.kotlin.name.Name
interface KtScope : ValidityTokenOwner {
// TODO check that names are accessible
// maybe return some kind of lazy set
fun getAllNames(): Set<Name> = withValidityAssertion { getCallableNames() + getClassLikeSymbolNames() }
fun getAllNames(): Set<Name> = withValidityAssertion { getCallableNames() + getClassifierNames() }
fun getCallableNames(): Set<Name>
fun getClassLikeSymbolNames(): Set<Name>
fun getClassifierNames(): Set<Name>
fun getAllSymbols(): Sequence<KtSymbol> = withValidityAssertion {
sequence {
yieldAll(getCallableSymbols())
yieldAll(getClassClassLikeSymbols())
yieldAll(getClassifierSymbols())
}
}
fun getCallableSymbols(): Sequence<KtCallableSymbol>
fun getClassClassLikeSymbols(): Sequence<KtClassLikeSymbol>
fun getClassifierSymbols(): Sequence<KtClassifierSymbol>
fun containsName(name: Name): Boolean = withValidityAssertion {
name in getCallableNames() || name in getClassLikeSymbolNames()
name in getCallableNames() || name in getClassifierNames()
}
}
@@ -9,8 +9,13 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.name.ClassId
sealed class KtClassifierSymbol : KtSymbol, KtNamedSymbol
sealed class KtClassLikeSymbol : KtSymbol, KtNamedSymbol, KtSymbolWithKind {
abstract class KtTypeParameterSymbol : KtClassifierSymbol(), KtNamedSymbol {
abstract override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol>
}
sealed class KtClassLikeSymbol : KtClassifierSymbol(), KtNamedSymbol, KtSymbolWithKind {
abstract val classIdIfNonLocal: ClassId?
abstract override fun createPointer(): KtSymbolPointer<KtClassLikeSymbol>
@@ -34,4 +39,4 @@ abstract class KtClassOrObjectSymbol : KtClassLikeSymbol(),
enum class KtClassKind {
CLASS, ENUM_CLASS, ENUM_ENTRY, ANNOTATION_CLASS, OBJECT, COMPANION_OBJECT, INTERFACE
}
}
@@ -1,15 +0,0 @@
/*
* Copyright 2010-2020 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.idea.frontend.api.symbols
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtNamedSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
abstract class KtTypeParameterSymbol : KtSymbol, KtNamedSymbol {
abstract override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol>
}