diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt index 793957a0b8a..e2bf0108261 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt @@ -93,11 +93,12 @@ class KtLightAnnotationForSourceEntry( override fun getReferences() = originalExpression?.references.orEmpty() override fun getLanguage() = KotlinLanguage.INSTANCE override fun getNavigationElement() = originalExpression - override fun isPhysical(): Boolean = originalExpression?.containingFile == kotlinOrigin.containingFile + override fun isPhysical(): Boolean = false override fun getTextRange() = originalExpression?.textRange ?: TextRange.EMPTY_RANGE override fun getParent() = parent override fun getText() = originalExpression?.text.orEmpty() - override fun getContainingFile(): PsiFile? = if (isPhysical) kotlinOrigin.containingFile else delegate.containingFile + override fun getContainingFile(): PsiFile? = if (originalExpression?.containingFile == kotlinOrigin.containingFile) + kotlinOrigin.containingFile else delegate.containingFile override fun replace(newElement: PsiElement): PsiElement { val value = (newElement as? PsiLiteral)?.value as? String ?: return this @@ -244,8 +245,6 @@ class KtLightAnnotationForSourceEntry( else -> LightElementValue(value, parent, ktOrigin) } - override fun isPhysical() = true - override fun getName() = null private fun wrapAnnotationValue(value: PsiAnnotationMemberValue): PsiAnnotationMemberValue = wrapAnnotationValue(value, this, { diff --git a/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt index 46e8c2e4a79..138efd09718 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt @@ -77,7 +77,6 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() { val annotation = myFixture.findClass("AnnotatedClass").methods.first { it.name == "bar" }.parameterList.parameters.single() .expectAnnotations(2).single { it.qualifiedName == "Qualifier" } val annotationAttributeVal = annotation.findAttributeValue("value") as PsiElement - TestCase.assertTrue(annotationAttributeVal.isPhysical) assertTextRangeAndValue("\"foo\"", "foo", annotationAttributeVal) } @@ -489,6 +488,7 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() { private fun assertTextAndRange(expected: String, psiElement: PsiElement) { TestCase.assertEquals("mismatch for $psiElement of ${psiElement.javaClass}", expected, psiElement.text) TestCase.assertEquals(expected, psiElement.textRange.substring(psiElement.containingFile.text)) + TestCase.assertEquals(psiElement, PsiAnchor.create(psiElement).retrieve()) } private fun assertTextRangeAndValue(expected: String, value: Any?, psiElement: PsiElement) {