[ULC] Fix annotations invalid parents
Fixed #KT-45287
This commit is contained in:
+5
-1
@@ -23,12 +23,16 @@ import com.intellij.psi.impl.light.LightElement
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
abstract class KtLightElementBase(private val parent: PsiElement) : LightElement(parent.manager, KotlinLanguage.INSTANCE) {
|
||||
abstract class KtLightElementBase(private var parent: PsiElement) : LightElement(parent.manager, KotlinLanguage.INSTANCE) {
|
||||
override fun toString() = "${this.javaClass.simpleName} of $parent"
|
||||
override fun getParent(): PsiElement = parent
|
||||
|
||||
abstract val kotlinOrigin: KtElement?
|
||||
|
||||
internal fun setParent(newParent: PsiElement) {
|
||||
parent = newParent
|
||||
}
|
||||
|
||||
override fun getText() = kotlinOrigin?.text ?: ""
|
||||
override fun getTextRange() = kotlinOrigin?.textRange ?: TextRange.EMPTY_RANGE
|
||||
override fun getTextOffset() = kotlinOrigin?.textOffset ?: 0
|
||||
|
||||
@@ -61,6 +61,10 @@ abstract class KtLightModifierList<out T : KtLightElement<KtModifierListOwner, P
|
||||
|
||||
private fun computeAnnotations(): List<KtLightAbstractAnnotation> {
|
||||
val annotationsForEntries = owner.givenAnnotations ?: lightAnnotationsForEntries(this)
|
||||
//TODO: Hacky way to update wrong parents for annotations
|
||||
annotationsForEntries.forEach {
|
||||
it.parent = this
|
||||
}
|
||||
val modifierListOwner = parent
|
||||
if (modifierListOwner is KtLightClassForSourceDeclaration && modifierListOwner.isAnnotationType) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user