FIR IDE: fix symbol pointer creation for KtAnonymousObjectSymbol
This commit is contained in:
+6
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||
|
||||
class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: SmartPsiElementPointer<out KtDeclaration>) : KtSymbolPointer<S>() {
|
||||
@@ -23,7 +24,11 @@ class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: SmartPsiElem
|
||||
companion object {
|
||||
fun <S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
|
||||
if (symbol.origin == KtSymbolOrigin.LIBRARY) return null
|
||||
val psi = symbol.psi as? KtDeclaration ?: return null
|
||||
val psi = when(val psi = symbol.psi) {
|
||||
is KtDeclaration -> psi
|
||||
is KtObjectLiteralExpression -> psi.objectDeclaration
|
||||
else -> null
|
||||
} ?: return null
|
||||
return KtPsiBasedSymbolPointer(psi.createSmartPointer())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user