[AA] KtSymbolPointer: introduce pointsToTheSameSymbolAs method

^KT-55191
This commit is contained in:
Dmitrii Gridin
2022-12-19 14:04:55 +01:00
committed by Space Team
parent 19a0a1fcd8
commit 13917887e0
34 changed files with 337 additions and 58 deletions
@@ -37,6 +37,11 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(
return symbol as S
}
override fun pointsToTheSameSymbolAs(other: KtSymbolPointer<KtSymbol>): Boolean = this === other ||
other is KtPsiBasedSymbolPointer &&
other.expectedClass == expectedClass &&
other.psiPointer == psiPointer
public constructor(psi: KtElement, expectedClass: KClass<S>) : this(psi.createSmartPointer(), expectedClass)
public companion object {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -31,6 +31,11 @@ public abstract class KtSymbolPointer<out S : KtSymbol> {
*/
@Deprecated("Consider using org.jetbrains.kotlin.analysis.api.KtAnalysisSession.restoreSymbol")
public abstract fun restoreSymbol(analysisSession: KtAnalysisSession): S?
/**
* @return **true** if [other] pointer should be restored to the same symbol
*/
public open fun pointsToTheSameSymbolAs(other: KtSymbolPointer<KtSymbol>): Boolean = this === other
}
public inline fun <S : KtSymbol> symbolPointer(crossinline getSymbol: (KtAnalysisSession) -> S?): KtSymbolPointer<S> =