[FIR-IDE] Add DestructuringDeclarationEntry to SymbolProvider
This commit is contained in:
committed by
Ilya Kirillov
parent
b6371a5b9a
commit
3af0e57406
+9
@@ -30,6 +30,7 @@ public abstract class KtSymbolProvider : KtAnalysisSessionComponent() {
|
||||
}
|
||||
is KtPropertyAccessor -> getPropertyAccessorSymbol(psi)
|
||||
is KtClassInitializer -> getClassInitializerSymbol(psi)
|
||||
is KtDestructuringDeclarationEntry -> getDestructuringDeclarationEntrySymbol(psi)
|
||||
else -> error("Cannot build symbol for ${psi::class}")
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ public abstract class KtSymbolProvider : KtAnalysisSessionComponent() {
|
||||
public abstract fun getNamedClassOrObjectSymbol(psi: KtClassOrObject): KtNamedClassOrObjectSymbol?
|
||||
public abstract fun getPropertyAccessorSymbol(psi: KtPropertyAccessor): KtPropertyAccessorSymbol
|
||||
public abstract fun getClassInitializerSymbol(psi: KtClassInitializer): KtClassInitializerSymbol
|
||||
public abstract fun getDestructuringDeclarationEntrySymbol(psi: KtDestructuringDeclarationEntry): KtLocalVariableSymbol
|
||||
|
||||
public abstract fun getClassOrObjectSymbolByClassId(classId: ClassId): KtClassOrObjectSymbol?
|
||||
|
||||
@@ -133,6 +135,13 @@ public interface KtSymbolProviderMixIn : KtAnalysisSessionMixIn {
|
||||
public fun FqName.getContainingCallableSymbolsWithName(name: Name): Sequence<KtSymbol> =
|
||||
withValidityAssertion { analysisSession.symbolProvider.getTopLevelCallableSymbols(this, name) }
|
||||
|
||||
/**
|
||||
* @return symbol corresponding to the local variable introduced by individual destructuring declaration entries.
|
||||
* E.g. `val (x, y) = p` has two declaration entries, one corresponding to `x`, one to `y`.
|
||||
*/
|
||||
public fun KtDestructuringDeclarationEntry.getDestructuringDeclarationEntrySymbol(): KtLocalVariableSymbol =
|
||||
analysisSession.symbolProvider.getDestructuringDeclarationEntrySymbol(this)
|
||||
|
||||
@Suppress("PropertyName")
|
||||
public val ROOT_PACKAGE_SYMBOL: KtPackageSymbol
|
||||
get() = withValidityAssertion { analysisSession.symbolProvider.ROOT_PACKAGE_SYMBOL }
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
fun destruct(): kotlin.Int
|
||||
|
||||
data class P {
|
||||
constructor(x: kotlin.Int, y: kotlin.Int)
|
||||
|
||||
val x: kotlin.Int
|
||||
|
||||
val y: kotlin.Int
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
data class P(val x: Int, val y: Int)
|
||||
|
||||
fun destruct(): Int {
|
||||
val (l, r) = P(1, 2)
|
||||
return l + r
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun destruct(): kotlin.Int
|
||||
|
||||
class P {
|
||||
constructor(x: kotlin.Int, y: kotlin.Int)
|
||||
|
||||
val x: kotlin.Int
|
||||
|
||||
val y: kotlin.Int
|
||||
|
||||
operator fun component1(): kotlin.Int
|
||||
|
||||
operator fun component2(): kotlin.Int
|
||||
|
||||
fun copy(x: kotlin.Int = ..., y: kotlin.Int = ...): P
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
KtValueParameterSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
generatedPrimaryConstructorProperty: KtKotlinPropertySymbol(/P.x)
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isImplicitLambdaParameter: false
|
||||
isVararg: false
|
||||
name: x
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: LOCAL
|
||||
typeParameters: []
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtValueParameterSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
generatedPrimaryConstructorProperty: KtKotlinPropertySymbol(/P.y)
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isImplicitLambdaParameter: false
|
||||
isVararg: false
|
||||
name: y
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: LOCAL
|
||||
typeParameters: []
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtConstructorSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
containingClassIdIfNonLocal: P
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
isPrimary: true
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: P
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: [
|
||||
KtValueParameterSymbol(x)
|
||||
KtValueParameterSymbol(y)
|
||||
]
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtNamedClassOrObjectSymbol:
|
||||
annotationsList: []
|
||||
classIdIfNonLocal: P
|
||||
classKind: CLASS
|
||||
companionObject: null
|
||||
isData: true
|
||||
isExternal: false
|
||||
isFun: false
|
||||
isInline: false
|
||||
isInner: false
|
||||
modality: FINAL
|
||||
name: P
|
||||
origin: SOURCE
|
||||
superTypes: [
|
||||
kotlin/Any
|
||||
]
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtLocalVariableSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
isExtension: false
|
||||
isVal: true
|
||||
name: l
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: LOCAL
|
||||
typeParameters: []
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtLocalVariableSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
isExtension: false
|
||||
isVal: true
|
||||
name: r
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: LOCAL
|
||||
typeParameters: []
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: /destruct
|
||||
hasStableParameterNames: true
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
isInline: false
|
||||
isOperator: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isSuspend: false
|
||||
modality: FINAL
|
||||
name: destruct
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
Reference in New Issue
Block a user