From 26a63a45ee16e5d5b12ce908fd399918a573ca63 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 18 Mar 2020 15:34:47 +0300 Subject: [PATCH] Introduce FirSourceElement.elementType --- .../org/jetbrains/kotlin/fir/FirSourceElement.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt index 234d4479a74..62519f6308e 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt @@ -8,14 +8,24 @@ package org.jetbrains.kotlin.fir import com.intellij.lang.LighterASTNode import com.intellij.openapi.util.Ref import com.intellij.psi.PsiElement +import com.intellij.psi.tree.IElementType import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.psi.KtModifierListOwner -sealed class FirSourceElement +sealed class FirSourceElement { + abstract val elementType: IElementType +} -class FirPsiSourceElement(val psi: PsiElement) : FirSourceElement() -class FirLightSourceElement(val element: LighterASTNode, val tree: FlyweightCapableTreeStructure) : FirSourceElement() +class FirPsiSourceElement(val psi: PsiElement) : FirSourceElement() { + override val elementType: IElementType + get() = psi.node.elementType +} + +class FirLightSourceElement(val element: LighterASTNode, val tree: FlyweightCapableTreeStructure) : FirSourceElement() { + override val elementType: IElementType + get() = element.tokenType +} val FirSourceElement?.psi: PsiElement? get() = (this as? FirPsiSourceElement)?.psi