[Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations

This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
This commit is contained in:
Dmitrii Gridin
2023-10-18 20:11:46 +02:00
committed by Space Team
parent d689c1a38f
commit 17ab005668
23 changed files with 1389 additions and 27 deletions
@@ -0,0 +1,16 @@
fun foo() = 42
val prop = 42
class Bar {
fun member() {
}
val memberProperty: String
get() {
fun b() = "sre"
return b()
}
}
foo()
@@ -0,0 +1,5 @@
fun foo() {
`$$res<caret>ult`
}
42
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: <script-ScriptResult.kts>) val `$$result`: kotlin.Int
@@ -0,0 +1,17 @@
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE
fun foo() {
}
val b = 42
class C {
fun member() {
}
val prop = foo()
}
foo()
@@ -0,0 +1 @@
@@ -0,0 +1,266 @@
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /foo
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: foo
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: TOP_LEVEL
typeParameters: []
valueParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/b)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: LOCAL
typeParameters: []
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
callableIdIfNonLocal: /b
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: false
initializer: KtConstantInitializerValue(42)
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: FINAL
name: b
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
setter: null
symbolKind: TOP_LEVEL
typeParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getB
javaSetterName: null
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /C.member
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: member
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: C
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/C.prop)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: LOCAL
typeParameters: []
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
callableIdIfNonLocal: /C.prop
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: C
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: false
initializer: KtNonConstantInitializerValue(foo())
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: FINAL
name: prop
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
setter: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: C
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getProp
javaSetterName: null
setterDeprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: C
classKind: CLASS
companionObject: null
contextReceivers: []
isActual: false
isData: false
isExpect: false
isExternal: false
isFun: false
isInline: false
isInner: false
modality: FINAL
name: C
origin: SOURCE
superTypes: [
KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Any
]
symbolKind: TOP_LEVEL
typeParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script script.kts"
annotationApplicableTargets: null
deprecationStatus: null
KtScriptSymbol:
annotationsList: []
name: <script-script.kts>
origin: SOURCE
typeParameters: []
getContainingModule: KtScriptModule "Script script.kts"
deprecationStatus: null
@@ -0,0 +1,7 @@
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE
fun foo() {
`$$res<caret>ult`
}
42
@@ -0,0 +1 @@
val `$$result`: kotlin.Int
@@ -0,0 +1,60 @@
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: null
callableIdIfNonLocal: null
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: PLUGIN
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script scriptResult.kts"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: false
initializer: KtConstantInitializerValue(42)
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: FINAL
name: $$result
origin: PLUGIN
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
setter: null
symbolKind: TOP_LEVEL
typeParameters: []
visibility: Public
getContainingModule: KtScriptModule "Script scriptResult.kts"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: get$$result
javaSetterName: null
setterDeprecationStatus: null