[FIR IDE] Add symbol kind to Kt accessor symbols
This commit is contained in:
+3
-2
@@ -13,7 +13,8 @@ sealed class KtPropertyAccessorSymbol : KtCallableSymbol(),
|
|||||||
KtPossibleMemberSymbol,
|
KtPossibleMemberSymbol,
|
||||||
KtSymbolWithModality,
|
KtSymbolWithModality,
|
||||||
KtSymbolWithVisibility,
|
KtSymbolWithVisibility,
|
||||||
KtAnnotatedSymbol {
|
KtAnnotatedSymbol,
|
||||||
|
KtSymbolWithKind {
|
||||||
|
|
||||||
final override val callableIdIfNonLocal: CallableId? get() = null
|
final override val callableIdIfNonLocal: CallableId? get() = null
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ sealed class KtPropertyAccessorSymbol : KtCallableSymbol(),
|
|||||||
abstract val isOverride: Boolean
|
abstract val isOverride: Boolean
|
||||||
abstract val hasBody: Boolean
|
abstract val hasBody: Boolean
|
||||||
|
|
||||||
abstract val symbolKind: KtSymbolKind
|
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.ACCESSOR
|
||||||
|
|
||||||
abstract override fun createPointer(): KtSymbolPointer<KtPropertyAccessorSymbol>
|
abstract override fun createPointer(): KtSymbolPointer<KtPropertyAccessorSymbol>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,6 @@ interface KtSymbolWithKind : KtSymbol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum class KtSymbolKind {
|
enum class KtSymbolKind {
|
||||||
TOP_LEVEL, MEMBER, LOCAL
|
TOP_LEVEL, MEMBER, LOCAL, ACCESSOR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolKind
|
|||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
|
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||||
|
|
||||||
internal class KtFirSymbolContainingDeclarationProvider(
|
internal class KtFirSymbolContainingDeclarationProvider(
|
||||||
@@ -46,9 +47,13 @@ internal class KtFirSymbolContainingDeclarationProvider(
|
|||||||
|
|
||||||
private fun getContainingDeclarationForKotlinInSourceSymbol(symbol: KtSymbolWithKind): KtSymbolWithKind = with(analysisSession) {
|
private fun getContainingDeclarationForKotlinInSourceSymbol(symbol: KtSymbolWithKind): KtSymbolWithKind = with(analysisSession) {
|
||||||
require(symbol.origin == KtSymbolOrigin.SOURCE || symbol.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED)
|
require(symbol.origin == KtSymbolOrigin.SOURCE || symbol.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED)
|
||||||
val psi = symbol.getPsi()
|
|
||||||
|
|
||||||
check(psi is KtDeclaration) { "PSI of kotlin declaration should be KtDeclaration" }
|
val psi = when (val psi = symbol.getPsi()) {
|
||||||
|
is KtDeclaration -> psi
|
||||||
|
is KtObjectLiteralExpression -> psi.objectDeclaration
|
||||||
|
else -> error { "PSI of kotlin declaration should be KtDeclaration but was ${psi::class.simpleName}" }
|
||||||
|
}
|
||||||
|
|
||||||
val containingDeclaration = when (symbol.origin) {
|
val containingDeclaration = when (symbol.origin) {
|
||||||
KtSymbolOrigin.SOURCE -> psi.parentOfType()
|
KtSymbolOrigin.SOURCE -> psi.parentOfType()
|
||||||
?: error("Containing declaration should present for non-toplevel declaration")
|
?: error("Containing declaration should present for non-toplevel declaration")
|
||||||
@@ -56,7 +61,6 @@ internal class KtFirSymbolContainingDeclarationProvider(
|
|||||||
else -> error("Unsupported declaration origin ${symbol.origin}")
|
else -> error("Unsupported declaration origin ${symbol.origin}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return with(analysisSession) {
|
return with(analysisSession) {
|
||||||
val containingSymbol = containingDeclaration.getSymbol()
|
val containingSymbol = containingDeclaration.getSymbol()
|
||||||
check(containingSymbol is KtSymbolWithKind)
|
check(containingSymbol is KtSymbolWithKind)
|
||||||
|
|||||||
+1
@@ -107,6 +107,7 @@ internal class KtFirFunctionSymbol(
|
|||||||
fir.createSignature()
|
fir.createSignature()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
KtSymbolKind.ACCESSOR -> TODO("Creating symbol for accessors fun is not supported yet")
|
||||||
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(
|
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(
|
||||||
callableIdIfNonLocal?.toString() ?: name.asString()
|
callableIdIfNonLocal?.toString() ?: name.asString()
|
||||||
)
|
)
|
||||||
|
|||||||
+1
@@ -118,6 +118,7 @@ internal class KtFirKotlinPropertySymbol(
|
|||||||
fir.createSignature()
|
fir.createSignature()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
KtSymbolKind.ACCESSOR -> TODO("Creating symbol for accessors is not supported yet")
|
||||||
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(name.asString())
|
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(name.asString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-8
@@ -46,14 +46,6 @@ internal class KtFirPropertyGetterSymbol(
|
|||||||
override val isOverride: Boolean get() = firRef.withFir { it.isOverride }
|
override val isOverride: Boolean get() = firRef.withFir { it.isOverride }
|
||||||
override val hasBody: Boolean get() = firRef.withFir { it.body != null }
|
override val hasBody: Boolean get() = firRef.withFir { it.body != null }
|
||||||
|
|
||||||
override val symbolKind: KtSymbolKind
|
|
||||||
get() = firRef.withFir { fir ->
|
|
||||||
when (fir.symbol.callableId.classId) {
|
|
||||||
null -> KtSymbolKind.TOP_LEVEL
|
|
||||||
else -> KtSymbolKind.MEMBER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||||
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
||||||
}
|
}
|
||||||
|
|||||||
-8
@@ -62,14 +62,6 @@ internal class KtFirPropertySetterSymbol(
|
|||||||
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val symbolKind: KtSymbolKind
|
|
||||||
get() = firRef.withFir { fir ->
|
|
||||||
when (fir.symbol.callableId.classId) {
|
|
||||||
null -> KtSymbolKind.TOP_LEVEL
|
|
||||||
else -> KtSymbolKind.MEMBER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val dispatchType: KtType? by cached {
|
override val dispatchType: KtType? by cached {
|
||||||
firRef.dispatchReceiverTypeAndAnnotations(builder)
|
firRef.dispatchReceiverTypeAndAnnotations(builder)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ KtFirPropertyGetterSymbol:
|
|||||||
isOverride: false
|
isOverride: false
|
||||||
modality: FINAL
|
modality: FINAL
|
||||||
origin: SOURCE
|
origin: SOURCE
|
||||||
symbolKind: TOP_LEVEL
|
symbolKind: ACCESSOR
|
||||||
visibility: Public
|
visibility: Public
|
||||||
|
|
||||||
KtFirKotlinPropertySymbol:
|
KtFirKotlinPropertySymbol:
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ KtFirPropertyGetterSymbol:
|
|||||||
isOverride: false
|
isOverride: false
|
||||||
modality: FINAL
|
modality: FINAL
|
||||||
origin: SOURCE
|
origin: SOURCE
|
||||||
symbolKind: TOP_LEVEL
|
symbolKind: ACCESSOR
|
||||||
visibility: Public
|
visibility: Public
|
||||||
|
|
||||||
KtFirKotlinPropertySymbol:
|
KtFirKotlinPropertySymbol:
|
||||||
|
|||||||
Reference in New Issue
Block a user