FIR IDE: API to indicate delegated property
This commit is contained in:
committed by
Ilya Kirillov
parent
96fbbb6f69
commit
b52912162f
+4
-1
@@ -96,7 +96,10 @@ internal class KtFe10DescKotlinPropertySymbol(
|
||||
return bindingContext[BindingContext.BACKING_FIELD_REQUIRED, descriptor] == true
|
||||
}
|
||||
|
||||
override val isDelegatedProperty: Boolean
|
||||
get() = withValidityAssertion { descriptor.delegateField != null }
|
||||
|
||||
override fun createPointer(): KtSymbolPointer<KtKotlinPropertySymbol> = withValidityAssertion {
|
||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -74,6 +74,11 @@ internal class KtFe10PsiKotlinPropertySymbol(
|
||||
bindingContext[BindingContext.BACKING_FIELD_REQUIRED, descriptor] == true
|
||||
}
|
||||
|
||||
override val isDelegatedProperty: Boolean
|
||||
get() = withValidityAssertion {
|
||||
psi.hasDelegate()
|
||||
}
|
||||
|
||||
override val isFromPrimaryConstructor: Boolean
|
||||
get() = withValidityAssertion { false }
|
||||
|
||||
@@ -131,4 +136,4 @@ internal class KtFe10PsiKotlinPropertySymbol(
|
||||
override fun createPointer(): KtSymbolPointer<KtKotlinPropertySymbol> = withValidityAssertion {
|
||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -101,6 +101,8 @@ internal class KtFirKotlinPropertySymbol(
|
||||
// NB: `field` in accessors indicates the property should have a backing field. To see that, though, we need BODY_RESOLVE.
|
||||
override val hasBackingField: Boolean get() = firRef.withFir(FirResolvePhase.BODY_RESOLVE) { it.hasBackingField }
|
||||
|
||||
override val isDelegatedProperty: Boolean get() = firRef.withFir { it.delegateFieldSymbol != null }
|
||||
|
||||
override val isLateInit: Boolean get() = firRef.withFir { it.isLateInit }
|
||||
|
||||
override val isConst: Boolean get() = firRef.withFir { it.isConst }
|
||||
|
||||
+6
@@ -78,6 +78,12 @@ public class FirSymbolByPsiTestGenerated extends AbstractFirSymbolByPsiTest {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/classWithTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateField.kt")
|
||||
public void testDelegateField() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/delegateField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
|
||||
+2
@@ -90,6 +90,7 @@ public sealed class KtPropertySymbol : KtVariableSymbol(),
|
||||
|
||||
public abstract val hasBackingField: Boolean
|
||||
|
||||
public abstract val isDelegatedProperty: Boolean
|
||||
public abstract val isFromPrimaryConstructor: Boolean
|
||||
public abstract val isOverride: Boolean
|
||||
public abstract val isStatic: Boolean
|
||||
@@ -109,6 +110,7 @@ public abstract class KtKotlinPropertySymbol : KtPropertySymbol() {
|
||||
|
||||
public abstract class KtSyntheticJavaPropertySymbol : KtPropertySymbol() {
|
||||
final override val hasBackingField: Boolean get() = true
|
||||
final override val isDelegatedProperty: Boolean get() = false
|
||||
final override val hasGetter: Boolean get() = true
|
||||
final override val symbolKind: KtSymbolKind get() = KtSymbolKind.CLASS_MEMBER
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 2
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -546,6 +546,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -76,6 +76,7 @@ KtSyntheticJavaPropertySymbol:
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isOverride: false
|
||||
|
||||
@@ -35,6 +35,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 123
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -79,6 +80,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: KtUnsupportedConstantValue
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -67,6 +67,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: true
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -10,6 +10,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -10,6 +10,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 10
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
class MyColor(val x: Int, val y: Int, val z: Int)
|
||||
|
||||
class Some {
|
||||
val delegate by lazy { MyColor(0x12 /* constant = 18 */, 2, 3) }
|
||||
|
||||
val lambda = lazy { MyColor(1, 2, 3) }
|
||||
|
||||
val nonLazy = MyColor(1, 2, 3)
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
KtValueParameterSymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: x
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
deprecationStatus: null
|
||||
|
||||
KtValueParameterSymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: y
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
deprecationStatus: null
|
||||
|
||||
KtValueParameterSymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: z
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
deprecationStatus: null
|
||||
|
||||
KtConstructorSymbol:
|
||||
annotatedType: [] MyColor
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
containingClassIdIfNonLocal: MyColor
|
||||
dispatchType: null
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
isPrimary: true
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: [
|
||||
KtValueParameterSymbol(x)
|
||||
KtValueParameterSymbol(y)
|
||||
KtValueParameterSymbol(z)
|
||||
]
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
|
||||
KtNamedClassOrObjectSymbol:
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
classIdIfNonLocal: MyColor
|
||||
classKind: CLASS
|
||||
companionObject: null
|
||||
isData: false
|
||||
isExternal: false
|
||||
isFun: false
|
||||
isInline: false
|
||||
isInner: false
|
||||
modality: FINAL
|
||||
name: MyColor
|
||||
origin: SOURCE
|
||||
superTypes: [
|
||||
[] kotlin/Any
|
||||
]
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
|
||||
KtAnonymousFunctionSymbol:
|
||||
annotatedType: [] MyColor
|
||||
callableIdIfNonLocal: null
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
valueParameters: []
|
||||
deprecationStatus: null
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotatedType: [] MyColor
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /Some.delegate
|
||||
dispatchType: Some
|
||||
getter: KtPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: false
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: true
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: FINAL
|
||||
name: delegate
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: CLASS_MEMBER
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
getterDeprecationStatus: null
|
||||
javaGetterName: getDelegate
|
||||
javaSetterName: null
|
||||
setterDeprecationStatus: null
|
||||
|
||||
KtAnonymousFunctionSymbol:
|
||||
annotatedType: [] MyColor
|
||||
callableIdIfNonLocal: null
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
valueParameters: []
|
||||
deprecationStatus: null
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/Lazy<MyColor>
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /Some.lambda
|
||||
dispatchType: Some
|
||||
getter: KtPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: true
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: FINAL
|
||||
name: lambda
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: CLASS_MEMBER
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
getterDeprecationStatus: null
|
||||
javaGetterName: getLambda
|
||||
javaSetterName: null
|
||||
setterDeprecationStatus: null
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotatedType: [] MyColor
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /Some.nonLazy
|
||||
dispatchType: Some
|
||||
getter: KtPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: true
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: FINAL
|
||||
name: nonLazy
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: CLASS_MEMBER
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
getterDeprecationStatus: null
|
||||
javaGetterName: getNonLazy
|
||||
javaSetterName: null
|
||||
setterDeprecationStatus: null
|
||||
|
||||
KtNamedClassOrObjectSymbol:
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
classIdIfNonLocal: Some
|
||||
classKind: CLASS
|
||||
companionObject: null
|
||||
isData: false
|
||||
isExternal: false
|
||||
isFun: false
|
||||
isInline: false
|
||||
isInner: false
|
||||
modality: FINAL
|
||||
name: Some
|
||||
origin: SOURCE
|
||||
superTypes: [
|
||||
[] kotlin/Any
|
||||
]
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
@@ -15,6 +15,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 1
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -46,6 +47,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 1
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -77,6 +79,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: true
|
||||
initializer: 1
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -108,6 +111,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: true
|
||||
initializer: 1
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -201,6 +205,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 1
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -289,6 +294,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 2
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -325,6 +331,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 2
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -361,6 +368,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 2
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -64,6 +64,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -106,6 +107,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -10,6 +10,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: true
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -108,6 +109,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: true
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -10,6 +10,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 10
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -61,6 +62,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: true
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -10,6 +10,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: 10
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
@@ -61,6 +62,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: true
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
@@ -190,6 +190,7 @@ KtKotlinPropertySymbol:
|
||||
hasSetter: false
|
||||
initializer: KtUnsupportedConstantValue
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
|
||||
Reference in New Issue
Block a user