[SLC] merge KtLightIdentifierBase with KtLightIdentifier
^KT-54051
This commit is contained in:
committed by
Space Team
parent
4bda3692aa
commit
c0097dd97e
+13
-17
@@ -7,28 +7,16 @@ package org.jetbrains.kotlin.asJava.elements
|
|||||||
|
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
import com.intellij.psi.impl.light.LightIdentifier
|
import com.intellij.psi.impl.light.LightIdentifier
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||||
|
|
||||||
abstract class KtLightIdentifierBase(
|
open class KtLightIdentifier @JvmOverloads constructor(
|
||||||
private val lightOwner: PsiElement,
|
private val lightOwner: PsiElement,
|
||||||
text: String?
|
private val ktDeclaration: KtDeclaration?,
|
||||||
) : LightIdentifier(lightOwner.manager, text), PsiElementWithOrigin<PsiElement> {
|
private val name: String? = ktDeclaration?.name,
|
||||||
override fun isPhysical() = true
|
) : LightIdentifier(lightOwner.manager, name), PsiElementWithOrigin<PsiElement> {
|
||||||
override fun getParent() = lightOwner
|
|
||||||
override fun getContainingFile() = lightOwner.containingFile
|
|
||||||
override fun getTextRange() = origin?.textRange ?: TextRange.EMPTY_RANGE
|
|
||||||
override fun getTextOffset(): Int = origin?.textOffset ?: -1
|
|
||||||
abstract override fun copy(): PsiElement
|
|
||||||
}
|
|
||||||
|
|
||||||
open class KtLightIdentifier(
|
|
||||||
lightOwner: PsiElement,
|
|
||||||
private val ktDeclaration: KtDeclaration?
|
|
||||||
) : KtLightIdentifierBase(lightOwner, ktDeclaration?.name) {
|
|
||||||
override fun copy(): PsiElement = KtLightIdentifier(parent, ktDeclaration)
|
|
||||||
|
|
||||||
override val origin: PsiElement?
|
override val origin: PsiElement?
|
||||||
get() = when (ktDeclaration) {
|
get() = when (ktDeclaration) {
|
||||||
is KtSecondaryConstructor -> ktDeclaration.getConstructorKeyword()
|
is KtSecondaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||||
@@ -40,4 +28,12 @@ open class KtLightIdentifier(
|
|||||||
is KtNamedDeclaration -> ktDeclaration.nameIdentifier
|
is KtNamedDeclaration -> ktDeclaration.nameIdentifier
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun copy(): PsiElement = KtLightIdentifier(parent, ktDeclaration, name)
|
||||||
|
override fun isPhysical(): Boolean = true
|
||||||
|
override fun getParent(): PsiElement = lightOwner
|
||||||
|
override fun getContainingFile(): PsiFile = lightOwner.containingFile
|
||||||
|
override fun getTextRange(): TextRange = origin?.textRange ?: TextRange.EMPTY_RANGE
|
||||||
|
|
||||||
|
override fun getTextOffset(): Int = origin?.textOffset ?: -1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user