Test no exact delegates were constructed during annotated element search
Add test case for aliased import
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
import java.lang.Deprecated as D
|
||||||
|
|
||||||
|
@D class TestClass1 {}
|
||||||
|
|
||||||
|
|
||||||
|
@D fun f()
|
||||||
|
|
||||||
|
class TestClass5 {
|
||||||
|
@D fun g() {}
|
||||||
|
|
||||||
|
@D class innerTestClass() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ANNOTATION: java.lang.Deprecated
|
||||||
|
// SEARCH: class:TestClass1, class:innerTestClass, method:f, method:g
|
||||||
@@ -17,13 +17,20 @@
|
|||||||
package org.jetbrains.kotlin.search
|
package org.jetbrains.kotlin.search
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
|
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
|
||||||
import com.intellij.psi.search.searches.AnnotatedMembersSearch
|
import com.intellij.psi.search.searches.AnnotatedMembersSearch
|
||||||
import com.intellij.testFramework.LightProjectDescriptor
|
import com.intellij.testFramework.LightProjectDescriptor
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
|
import org.jetbrains.kotlin.asJava.builder.LightClassConstructionContext
|
||||||
|
import org.jetbrains.kotlin.asJava.builder.StubComputationTracker
|
||||||
|
import org.jetbrains.kotlin.idea.caches.resolve.lightClasses.IDELightClassConstructionContext
|
||||||
|
import org.jetbrains.kotlin.idea.caches.resolve.lightClasses.IDELightClassConstructionContext.Mode.EXACT
|
||||||
|
import org.jetbrains.kotlin.idea.completion.test.withServiceRegistered
|
||||||
import org.jetbrains.kotlin.idea.search.PsiBasedClassResolver
|
import org.jetbrains.kotlin.idea.search.PsiBasedClassResolver
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
|
import org.junit.Assert
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class AbstractAnnotatedMembersSearchTest : AbstractSearcherTest() {
|
abstract class AbstractAnnotatedMembersSearchTest : AbstractSearcherTest() {
|
||||||
@@ -39,6 +46,7 @@ abstract class AbstractAnnotatedMembersSearchTest : AbstractSearcherTest() {
|
|||||||
TestCase.assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty())
|
TestCase.assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty())
|
||||||
|
|
||||||
val annotationClassName = directives.first()
|
val annotationClassName = directives.first()
|
||||||
|
project.withServiceRegistered<StubComputationTracker, Unit>(NoRealDelegatesComputed) {
|
||||||
val psiClass = getPsiClass(annotationClassName)
|
val psiClass = getPsiClass(annotationClassName)
|
||||||
PsiBasedClassResolver.trueHits.set(0)
|
PsiBasedClassResolver.trueHits.set(0)
|
||||||
PsiBasedClassResolver.falseHits.set(0)
|
PsiBasedClassResolver.falseHits.set(0)
|
||||||
@@ -55,8 +63,17 @@ abstract class AbstractAnnotatedMembersSearchTest : AbstractSearcherTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun getTestDataPath(): String {
|
override fun getTestDataPath(): String {
|
||||||
return File(PluginTestCaseBase.getTestDataPathBase(), "/search/annotations").path + File.separator
|
return File(PluginTestCaseBase.getTestDataPathBase(), "/search/annotations").path + File.separator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object NoRealDelegatesComputed : StubComputationTracker {
|
||||||
|
override fun onStubComputed(javaFileStub: PsiJavaFileStub, context: LightClassConstructionContext) {
|
||||||
|
if ((context as IDELightClassConstructionContext).mode == EXACT) {
|
||||||
|
Assert.fail("Should not have computed exact delegate for ${javaFileStub.classes.single().qualifiedName}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ public class AnnotatedMembersSearchTestGenerated extends AbstractAnnotatedMember
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/search/annotations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/search/annotations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotationAliased.kt")
|
||||||
|
public void testAnnotationAliased() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/search/annotations/annotationAliased.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("testAmbiguousNestedNonAnnotationClass.kt")
|
@TestMetadata("testAmbiguousNestedNonAnnotationClass.kt")
|
||||||
public void testTestAmbiguousNestedNonAnnotationClass() throws Exception {
|
public void testTestAmbiguousNestedNonAnnotationClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/search/annotations/testAmbiguousNestedNonAnnotationClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/search/annotations/testAmbiguousNestedNonAnnotationClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user