[AA] KtPsiBasedSymbolPointer: add class type check
^KT-54311
This commit is contained in:
committed by
Space Team
parent
4dc7b6dddc
commit
fe93f49ff7
+2
-2
@@ -47,9 +47,9 @@ internal class KtFe10DescAnonymousFunctionSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.createContextReceivers(analysisContext) }
|
get() = withValidityAssertion { descriptor.createContextReceivers(analysisContext) }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtAnonymousFunctionSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtAnonymousFunctionSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtAnonymousFunctionSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
override fun hashCode(): Int = calculateHashCode()
|
override fun hashCode(): Int = calculateHashCode()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ internal class KtFe10DescAnonymousObjectSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.typeConstructor.supertypes.map { it.toKtType(analysisContext) } }
|
get() = withValidityAssertion { descriptor.typeConstructor.supertypes.map { it.toKtType(analysisContext) } }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtAnonymousObjectSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtAnonymousObjectSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtAnonymousObjectSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ internal class KtFe10DescConstructorSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtConstructorSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtConstructorSymbol> = withValidityAssertion {
|
||||||
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource<KtConstructorSymbol>(this)
|
||||||
if (pointerByPsi != null) {
|
if (pointerByPsi != null) {
|
||||||
return pointerByPsi
|
return pointerByPsi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ internal class KtFe10DescEnumEntrySymbol(
|
|||||||
get() = withValidityAssertion { descriptor.name }
|
get() = withValidityAssertion { descriptor.name }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtEnumEntrySymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtEnumEntrySymbol> = withValidityAssertion {
|
||||||
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource<KtEnumEntrySymbol>(this)
|
||||||
if (pointerByPsi != null) {
|
if (pointerByPsi != null) {
|
||||||
return pointerByPsi
|
return pointerByPsi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ internal class KtFe10DescFunctionSymbol private constructor(
|
|||||||
get() = withValidityAssertion { descriptor.typeParameters.map { KtFe10DescTypeParameterSymbol(it, analysisContext) } }
|
get() = withValidityAssertion { descriptor.typeParameters.map { KtFe10DescTypeParameterSymbol(it, analysisContext) } }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtFunctionSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtFunctionSymbol> = withValidityAssertion {
|
||||||
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource<KtFunctionSymbol>(this)
|
||||||
if (pointerByPsi != null) {
|
if (pointerByPsi != null) {
|
||||||
return pointerByPsi
|
return pointerByPsi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ internal class KtFe10DescJavaFieldSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.returnType.toKtType(analysisContext) }
|
get() = withValidityAssertion { descriptor.returnType.toKtType(analysisContext) }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtJavaFieldSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtJavaFieldSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtJavaFieldSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ internal class KtFe10DescKotlinPropertySymbol(
|
|||||||
get() = withValidityAssertion { descriptor.isDelegated }
|
get() = withValidityAssertion { descriptor.isDelegated }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtKotlinPropertySymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtKotlinPropertySymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtKotlinPropertySymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ internal class KtFe10DescLocalVariableSymbol(
|
|||||||
get() = withValidityAssertion { KtSymbolKind.LOCAL }
|
get() = withValidityAssertion { KtSymbolKind.LOCAL }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtLocalVariableSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtLocalVariableSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtLocalVariableSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ internal class KtFe10DescNamedClassOrObjectSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.declaredTypeParameters.map { KtFe10DescTypeParameterSymbol(it, analysisContext) } }
|
get() = withValidityAssertion { descriptor.declaredTypeParameters.map { KtFe10DescTypeParameterSymbol(it, analysisContext) } }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtNamedClassOrObjectSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtNamedClassOrObjectSymbol> = withValidityAssertion {
|
||||||
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource<KtNamedClassOrObjectSymbol>(this)
|
||||||
if (pointerByPsi != null) {
|
if (pointerByPsi != null) {
|
||||||
return pointerByPsi
|
return pointerByPsi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ internal class KtFe10DescPropertyGetterSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.extensionReceiverParameter?.type?.toKtType(analysisContext) }
|
get() = withValidityAssertion { descriptor.extensionReceiverParameter?.type?.toKtType(analysisContext) }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtPropertyGetterSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtPropertyGetterSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtPropertyGetterSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ internal class KtFe10DescPropertySetterSymbol(
|
|||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtPropertySetterSymbol> {
|
override fun createPointer(): KtSymbolPointer<KtPropertySetterSymbol> {
|
||||||
withValidityAssertion {
|
withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtPropertySetterSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ internal class KtFe10DescSamConstructorSymbol(
|
|||||||
|
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtSamConstructorSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtSamConstructorSymbol> = withValidityAssertion {
|
||||||
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
val pointerByPsi = KtPsiBasedSymbolPointer.createForSymbolFromSource<KtSamConstructorSymbol>(this)
|
||||||
if (pointerByPsi != null) {
|
if (pointerByPsi != null) {
|
||||||
return pointerByPsi
|
return pointerByPsi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ internal class KtFe10DescSyntheticJavaPropertySymbol(
|
|||||||
get() = withValidityAssertion { descriptor.typeParameters.map { it.toKtTypeParameter(analysisContext) } }
|
get() = withValidityAssertion { descriptor.typeParameters.map { it.toKtTypeParameter(analysisContext) } }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtSyntheticJavaPropertySymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtSyntheticJavaPropertySymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtSyntheticJavaPropertySymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ internal class KtFe10DescSyntheticJavaPropertySymbolForOverride(
|
|||||||
get() = withValidityAssertion { descriptor.typeParameters.map { it.toKtTypeParameter(analysisContext) } }
|
get() = withValidityAssertion { descriptor.typeParameters.map { it.toKtTypeParameter(analysisContext) } }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtSyntheticJavaPropertySymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtSyntheticJavaPropertySymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtSyntheticJavaPropertySymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ internal class KtFe10DescTypeAliasSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.classId }
|
get() = withValidityAssertion { descriptor.classId }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtTypeAliasSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtTypeAliasSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtTypeAliasSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ internal class KtFe10DescTypeParameterSymbol(
|
|||||||
get() = withValidityAssertion { descriptor.isReified }
|
get() = withValidityAssertion { descriptor.isReified }
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtTypeParameterSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtTypeParameterSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ internal class KtFe10DescValueParameterSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createPointer(): KtSymbolPointer<KtValueParameterSymbol> = withValidityAssertion {
|
override fun createPointer(): KtSymbolPointer<KtValueParameterSymbol> = withValidityAssertion {
|
||||||
return KtPsiBasedSymbolPointer.createForSymbolFromSource(this) ?: KtFe10NeverRestoringSymbolPointer()
|
return KtPsiBasedSymbolPointer.createForSymbolFromSource<KtValueParameterSymbol>(this) ?: KtFe10NeverRestoringSymbolPointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
override fun equals(other: Any?): Boolean = isEqualTo(other)
|
||||||
|
|||||||
+6
@@ -106,6 +106,12 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated ext
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primaryConstructorValueParameterAsProperty.kt")
|
||||||
|
public void testPrimaryConstructorValueParameterAsProperty() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameterAsProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyReceiverParameter.kt")
|
@TestMetadata("propertyReceiverParameter.kt")
|
||||||
public void testPropertyReceiverParameter() throws Exception {
|
public void testPropertyReceiverParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -106,6 +106,12 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated exte
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primaryConstructorValueParameterAsProperty.kt")
|
||||||
|
public void testPrimaryConstructorValueParameterAsProperty() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameterAsProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyReceiverParameter.kt")
|
@TestMetadata("propertyReceiverParameter.kt")
|
||||||
public void testPropertyReceiverParameter() throws Exception {
|
public void testPropertyReceiverParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -106,6 +106,12 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerat
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primaryConstructorValueParameterAsProperty.kt")
|
||||||
|
public void testPrimaryConstructorValueParameterAsProperty() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByReference/primaryConstructorValueParameterAsProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("propertyReceiverParameter.kt")
|
@TestMetadata("propertyReceiverParameter.kt")
|
||||||
public void testPropertyReceiverParameter() throws Exception {
|
public void testPropertyReceiverParameter() throws Exception {
|
||||||
|
|||||||
+27
-9
@@ -15,15 +15,17 @@ import org.jetbrains.kotlin.psi.KtElement
|
|||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(private val psiPointer: SmartPsiElementPointer<out KtElement>) :
|
public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(
|
||||||
KtSymbolPointer<S>() {
|
private val psiPointer: SmartPsiElementPointer<out KtElement>,
|
||||||
|
private val expectedClass: KClass<S>,
|
||||||
|
) : KtSymbolPointer<S>() {
|
||||||
@Deprecated("Consider using org.jetbrains.kotlin.analysis.api.KtAnalysisSession.restoreSymbol")
|
@Deprecated("Consider using org.jetbrains.kotlin.analysis.api.KtAnalysisSession.restoreSymbol")
|
||||||
override fun restoreSymbol(analysisSession: KtAnalysisSession): S? {
|
override fun restoreSymbol(analysisSession: KtAnalysisSession): S? {
|
||||||
val psi = psiPointer.element ?: return null
|
val psi = psiPointer.element ?: return null
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
val symbol: KtSymbol = with(analysisSession) {
|
||||||
return with(analysisSession) {
|
|
||||||
when (psi) {
|
when (psi) {
|
||||||
is KtDeclaration -> psi.getSymbol()
|
is KtDeclaration -> psi.getSymbol()
|
||||||
is KtFile -> psi.getFileSymbol()
|
is KtFile -> psi.getFileSymbol()
|
||||||
@@ -31,11 +33,22 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(private v
|
|||||||
error("Unexpected declaration to restore: ${psi::class}, text:\n ${psi.text}")
|
error("Unexpected declaration to restore: ${psi::class}, text:\n ${psi.text}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as S?
|
}
|
||||||
|
|
||||||
|
if (!expectedClass.isInstance(symbol)) return null
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return symbol as S
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public constructor(psi: KtElement, expectedClass: KClass<S>) : this(psi.createSmartPointer(), expectedClass)
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public fun <S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
|
public inline fun <reified S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
|
||||||
|
return createForSymbolFromSource(symbol, S::class)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <S : KtSymbol> createForSymbolFromSource(symbol: S, expectedClass: KClass<S>): KtPsiBasedSymbolPointer<S>? {
|
||||||
ifDisabled { return null }
|
ifDisabled { return null }
|
||||||
|
|
||||||
if (symbol.origin != KtSymbolOrigin.SOURCE) return null
|
if (symbol.origin != KtSymbolOrigin.SOURCE) return null
|
||||||
@@ -47,13 +60,18 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(private v
|
|||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return KtPsiBasedSymbolPointer(psi.createSmartPointer())
|
return KtPsiBasedSymbolPointer(psi, expectedClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun <S : KtSymbol> createForSymbolFromPsi(ktElement: KtElement): KtPsiBasedSymbolPointer<S>? {
|
|
||||||
|
public fun <S : KtSymbol> createForSymbolFromPsi(ktElement: KtElement, expectedClass: KClass<S>): KtPsiBasedSymbolPointer<S>? {
|
||||||
ifDisabled { return null }
|
ifDisabled { return null }
|
||||||
|
|
||||||
return KtPsiBasedSymbolPointer(ktElement.createSmartPointer())
|
return KtPsiBasedSymbolPointer(ktElement, expectedClass)
|
||||||
|
}
|
||||||
|
|
||||||
|
public inline fun <reified S : KtSymbol> createForSymbolFromPsi(ktElement: KtElement): KtPsiBasedSymbolPointer<S>? {
|
||||||
|
return createForSymbolFromPsi(ktElement, S::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
KtKotlinPropertySymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /A.abc
|
||||||
|
contextReceivers: []
|
||||||
|
getter: KtPropertyGetterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
hasBody: false
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isDefault: true
|
||||||
|
isExtension: false
|
||||||
|
isInline: false
|
||||||
|
isOverride: false
|
||||||
|
modality: FINAL
|
||||||
|
origin: SOURCE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
symbolKind: ACCESSOR
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): A
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
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: abc
|
||||||
|
origin: SOURCE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
setter: null
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): A
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
getterDeprecationStatus: null
|
||||||
|
javaGetterName: getAbc
|
||||||
|
javaSetterName: null
|
||||||
|
setterDeprecationStatus: null
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
// DO_NOT_CHECK_SYMBOL_RESTORE
|
||||||
|
|
||||||
|
class A(val abc: Int) {
|
||||||
|
fun check() {
|
||||||
|
a<caret>bc
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
val abc: kotlin.Int
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
KtKotlinPropertySymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /A.abc
|
||||||
|
contextReceivers: []
|
||||||
|
getter: KtPropertyGetterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
hasBody: false
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isDefault: true
|
||||||
|
isExtension: false
|
||||||
|
isInline: false
|
||||||
|
isOverride: false
|
||||||
|
modality: FINAL
|
||||||
|
origin: SOURCE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
symbolKind: ACCESSOR
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): A
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
hasBackingField: true
|
||||||
|
hasGetter: true
|
||||||
|
hasSetter: false
|
||||||
|
initializer: KtNonConstantInitializerValue(val abc: Int)
|
||||||
|
isConst: false
|
||||||
|
isDelegatedProperty: false
|
||||||
|
isExtension: false
|
||||||
|
isFromPrimaryConstructor: true
|
||||||
|
isLateInit: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isVal: true
|
||||||
|
modality: FINAL
|
||||||
|
name: abc
|
||||||
|
origin: SOURCE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
setter: null
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): A
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
getterDeprecationStatus: null
|
||||||
|
javaGetterName: getAbc
|
||||||
|
javaSetterName: null
|
||||||
|
setterDeprecationStatus: null
|
||||||
Reference in New Issue
Block a user