From 9e25dfdd93bdc770cbaf2050e683dee2d12e6b31 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 3 May 2017 14:21:09 +0300 Subject: [PATCH] KtLightModifierList extends KtLightElementBase Fix getContainingFile always returning null --- .../asJava/elements/KtLightModifierList.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/KtLightModifierList.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/KtLightModifierList.kt index da055059d23..5a63e35211d 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/KtLightModifierList.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/KtLightModifierList.kt @@ -16,9 +16,10 @@ package org.jetbrains.kotlin.asJava.elements -import com.intellij.openapi.util.TextRange -import com.intellij.psi.* -import com.intellij.psi.impl.light.LightElement +import com.intellij.psi.PsiAnnotation +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiModifierList +import com.intellij.psi.PsiModifierListOwner import org.jetbrains.kotlin.asJava.LightClassGenerationSupport import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration import org.jetbrains.kotlin.asJava.classes.lazyPub @@ -28,7 +29,6 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget -import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.AnnotationChecker import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass @@ -36,27 +36,31 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.source.getPsi abstract class KtLightModifierList>(protected val owner: T) - : LightElement(owner.manager, KotlinLanguage.INSTANCE), PsiModifierList, KtLightElement { + : KtLightElementBase(owner), PsiModifierList, KtLightElement { override val clsDelegate by lazyPub { owner.clsDelegate.modifierList!! } private val _annotations by lazyPub { computeAnnotations(this) } + override val kotlinOrigin: KtModifierList? get() = owner.kotlinOrigin?.modifierList + override fun getParent() = owner + override fun hasExplicitModifier(name: String) = hasModifierProperty(name) override fun setModifierProperty(name: String, value: Boolean) = clsDelegate.setModifierProperty(name, value) override fun checkSetModifierProperty(name: String, value: Boolean) = clsDelegate.checkSetModifierProperty(name, value) override fun addAnnotation(qualifiedName: String) = clsDelegate.addAnnotation(qualifiedName) + override fun getApplicableAnnotations(): Array = annotations + override fun getAnnotations(): Array = _annotations.toTypedArray() override fun findAnnotation(qualifiedName: String) = _annotations.firstOrNull { it.fqNameMatches(qualifiedName) } - override fun getParent() = owner - override fun getText(): String? = "" - override fun getTextRange() = TextRange.EMPTY_RANGE - override fun getReferences() = PsiReference.EMPTY_ARRAY + override fun isEquivalentTo(another: PsiElement?) = another is KtLightModifierList<*> && owner == another.owner + override fun isWritable() = false + override fun toString() = "Light modifier list of $owner" }