KtLightAnnotationForSourceEntry fix for smart-pointers creating
`LightElementValue` made PsiCompiledElement to make it properly anchorable when creating smartpointers, when still use `kotlinOrigin.containingFile` for it to be able to `registerProblem` on such elements. (refs KT-18054)
This commit is contained in:
committed by
Pavel Talanov
parent
b0fb3370e3
commit
be4b86e3d9
@@ -21,13 +21,12 @@ import com.intellij.testFramework.LightProjectDescriptor
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.uast.java.annotations
|
||||
|
||||
class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
fun testBooleanAnnotation() {
|
||||
fun testBooleanAnnotationDefaultValue() {
|
||||
myFixture.addClass("""
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
@@ -70,9 +69,10 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
""".trimIndent())
|
||||
myFixture.testHighlighting("Qualifier.java", "AnnotatedClass.kt")
|
||||
|
||||
val annotations = myFixture.findClass("AnnotatedClass").methods.first { it.name == "bar" }.parameterList.parameters.single()
|
||||
val annotation = myFixture.findClass("AnnotatedClass").methods.first { it.name == "bar" }.parameterList.parameters.single()
|
||||
.expectAnnotations(2).single { it.qualifiedName == "Qualifier" }
|
||||
val annotationAttributeVal = annotations.findAttributeValue("value") as PsiElement
|
||||
val annotationAttributeVal = annotation.findAttributeValue("value") as PsiElement
|
||||
TestCase.assertTrue(annotationAttributeVal.isPhysical)
|
||||
assertTextRangeAndValue("\"foo\"", "foo", annotationAttributeVal)
|
||||
}
|
||||
|
||||
@@ -372,6 +372,8 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
assertTextAndRange(expected, psiElement)
|
||||
val result = JavaPsiFacade.getInstance(project).constantEvaluationHelper.computeConstantExpression(psiElement)
|
||||
TestCase.assertEquals(value, result)
|
||||
val smartPointer = SmartPointerManager.getInstance(psiElement.project).createSmartPsiElementPointer(psiElement)
|
||||
assertTextAndRange(expected, smartPointer.element!!)
|
||||
}
|
||||
|
||||
private fun PsiModifierListOwner.expectAnnotations(number: Int): Array<PsiAnnotation> =
|
||||
|
||||
Reference in New Issue
Block a user