[FIR IDE] Supporting member scopes in EnumEntries

This commit is contained in:
Igor Yakovlev
2020-11-12 18:07:26 +03:00
parent fdaf31dbf3
commit 3e3ec5fc69
16 changed files with 118 additions and 44 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.frontend.api.components.*
import org.jetbrains.kotlin.idea.frontend.api.scopes.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithDeclarations
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
@@ -69,9 +70,9 @@ abstract class KtAnalysisSession(override val token: ValidityToken) : ValidityTo
fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = containingDeclarationProvider.getContainingDeclaration(this)
fun KtClassOrObjectSymbol.getMemberScope(): KtMemberScope = scopeProvider.getMemberScope(this)
fun KtSymbolWithDeclarations.getMemberScope(): KtMemberScope = scopeProvider.getMemberScope(this)
fun KtClassOrObjectSymbol.getDeclaredMemberScope(): KtDeclaredMemberScope = scopeProvider.getDeclaredMemberScope(this)
fun KtSymbolWithDeclarations.getDeclaredMemberScope(): KtDeclaredMemberScope = scopeProvider.getDeclaredMemberScope(this)
fun KtPackageSymbol.getPackageScope(): KtPackageScope = scopeProvider.getPackageScope(this)
@@ -5,17 +5,16 @@
package org.jetbrains.kotlin.idea.frontend.api.components
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.frontend.api.scopes.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPackageSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithDeclarations
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
abstract class KtScopeProvider : KtAnalysisSessionComponent() {
abstract fun getMemberScope(classSymbol: KtClassOrObjectSymbol): KtMemberScope
abstract fun getDeclaredMemberScope(classSymbol: KtClassOrObjectSymbol): KtDeclaredMemberScope
abstract fun getMemberScope(classSymbol: KtSymbolWithDeclarations): KtMemberScope
abstract fun getDeclaredMemberScope(classSymbol: KtSymbolWithDeclarations): KtDeclaredMemberScope
abstract fun getPackageScope(packageSymbol: KtPackageSymbol): KtPackageScope
abstract fun getCompositeScope(subScopes: List<KtScope>): KtCompositeScope
@@ -5,8 +5,10 @@
package org.jetbrains.kotlin.idea.frontend.api.scopes
import org.jetbrains.kotlin.idea.frontend.api.ValidityToken
import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithDeclarations
import org.jetbrains.kotlin.idea.frontend.api.withValidityAssertion
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -42,11 +44,11 @@ interface KtCompositeScope : KtScope {
}
interface KtMemberScope : KtScope {
val owner: KtClassOrObjectSymbol
val owner: KtSymbolWithDeclarations
}
interface KtDeclaredMemberScope : KtScope {
val owner: KtClassOrObjectSymbol
val owner: KtSymbolWithDeclarations
}
interface KtPackageScope : KtScope, KtSubstitutedScope<KtPackageScope> {
@@ -35,7 +35,8 @@ abstract class KtClassOrObjectSymbol : KtClassLikeSymbol(),
KtSymbolWithTypeParameters,
KtSymbolWithModality<KtSymbolModality>,
KtSymbolWithVisibility,
KtAnnotatedSymbol {
KtAnnotatedSymbol,
KtSymbolWithDeclarations {
abstract val classKind: KtClassKind
abstract val isInner: Boolean
@@ -14,10 +14,12 @@ sealed class KtVariableLikeSymbol : KtCallableSymbol(), KtTypedSymbol, KtNamedSy
abstract override fun createPointer(): KtSymbolPointer<KtVariableLikeSymbol>
}
abstract class KtEnumEntrySymbol : KtVariableLikeSymbol(), KtSymbolWithKind {
abstract class KtEnumEntrySymbol : KtVariableLikeSymbol(), KtSymbolWithDeclarations, KtSymbolWithKind {
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.MEMBER
abstract val containingEnumClassIdIfNonLocal: ClassId?
abstract val hasBody: Boolean
abstract override fun createPointer(): KtSymbolPointer<KtEnumEntrySymbol>
}
@@ -17,10 +17,6 @@ abstract class KtAnnotationCall {
abstract val arguments: List<KtNamedConstantValue>
}
sealed class KtConstantValue
object KtUnsupportedConstantValue : KtConstantValue()
data class KtSimpleConstantValue<T>(val constant: T) : KtConstantValue()
data class KtNamedConstantValue(val name: String, val expression: KtConstantValue)
interface KtAnnotatedSymbol : KtSymbol {
@@ -0,0 +1,11 @@
/*
* 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.markers
sealed class KtConstantValue
object KtUnsupportedConstantValue : KtConstantValue()
data class KtSimpleConstantValue<T>(val constant: T?) : KtConstantValue()
@@ -0,0 +1,10 @@
/*
* 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.markers
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
interface KtSymbolWithDeclarations : KtSymbol
@@ -17,4 +17,5 @@ sealed class KtCommonSymbolModality : KtSymbolModality() {
object FINAL : KtCommonSymbolModality()
object ABSTRACT : KtCommonSymbolModality()
object OPEN : KtCommonSymbolModality()
object UNKNOWN : KtCommonSymbolModality()
}