EA-214662: Support property accessors in UastLightIdentifier

This commit is contained in:
Yan Zhulanow
2020-01-14 21:21:27 +09:00
parent be99f44c4f
commit b1414fa477
11 changed files with 55 additions and 16 deletions
@@ -21,14 +21,12 @@ import com.intellij.psi.PsiCompiledElement
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNameIdentifierOwner
import com.intellij.psi.impl.light.LightIdentifier
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
open class KtLightIdentifier(
private val lightOwner: PsiElement,
private val ktDeclaration: KtNamedDeclaration?
private val ktDeclaration: KtDeclaration?
) : LightIdentifier(lightOwner.manager, ktDeclaration?.name ?: ""), PsiCompiledElement,
PsiElementWithOrigin<PsiElement> {
override val origin: PsiElement?
@@ -37,7 +35,9 @@ open class KtLightIdentifier(
is KtPrimaryConstructor -> ktDeclaration.getConstructorKeyword()
?: ktDeclaration.valueParameterList
?: ktDeclaration.containingClassOrObject?.nameIdentifier
else -> ktDeclaration?.nameIdentifier
is KtPropertyAccessor -> ktDeclaration.namePlaceholder
is KtNamedDeclaration -> ktDeclaration.nameIdentifier
else -> null
}
override fun getMirror() = ((lightOwner as? KtLightElement<*, *>)?.clsDelegate as? PsiNameIdentifierOwner)?.nameIdentifier