diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedComplex/annotations.txt b/plugins/annotation-collector/testData/collectToFile/inheritedComplex/annotations.txt new file mode 100644 index 00000000000..9f30e337af5 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedComplex/annotations.txt @@ -0,0 +1,18 @@ +p org.test 0 +d 0/Ann1 +a java.lang.annotation.Inherited 0 +c 0 0/Ann1 +a java.lang.annotation.Retention 1 +c 1 0/Ann1 +d 0/Ann2 +c 0 0/Ann2 +c 1 0/Ann2 +d 0/A +a org.test.Ann1 2 +c 2 0/A +d 0/A$DefaultImpls +d 0/B +a org.test.Ann2 3 +c 3 0/B +d 0/C +d 0/D diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedComplex/inheritedComplex.kt b/plugins/annotation-collector/testData/collectToFile/inheritedComplex/inheritedComplex.kt new file mode 100644 index 00000000000..087139a9c68 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedComplex/inheritedComplex.kt @@ -0,0 +1,19 @@ +package org.test + +import java.lang.annotation.Inherited + +@Inherited +annotation class Ann1 + +@Inherited +annotation class Ann2 + +@Ann1 +interface A + +@Ann2 +open class B : A + +open class C : B() + +class D : C() \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt index 34f1a11569e..cb693ad85f5 100644 --- a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt @@ -1,4 +1,11 @@ p org.test 0 -d 0/SomeInterface -d 0/SomeInterface$DefaultImpls -d 0/SomeClass +d 0/Ann +a java.lang.annotation.Inherited 0 +c 0 0/Ann +a java.lang.annotation.Retention 1 +c 1 0/Ann +d 0/A +a org.test.Ann 2 +c 2 0/A +d 0/A$DefaultImpls +d 0/B diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt index 4ffaa0a8b8b..0d28deac85a 100644 --- a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt +++ b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt @@ -1,5 +1,11 @@ package org.test -public interface SomeInterface +import java.lang.annotation.Inherited -public class SomeClass \ No newline at end of file +@Inherited +annotation class Ann + +@Ann +interface A + +class B : A \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/localFunctions/annotations.txt b/plugins/annotation-collector/testData/collectToFile/localFunctions/annotations.txt new file mode 100644 index 00000000000..4fff5a30d91 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/localFunctions/annotations.txt @@ -0,0 +1,4 @@ +a java.lang.Deprecated 0 +p org.test 0 +m 0 0/Class$method$1 invoke +m 0 0/LocalFunctionsKt$function$1 invoke diff --git a/plugins/annotation-collector/testData/collectToFile/localFunctions/localFunctions.kt b/plugins/annotation-collector/testData/collectToFile/localFunctions/localFunctions.kt new file mode 100644 index 00000000000..b5712d2e872 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/localFunctions/localFunctions.kt @@ -0,0 +1,11 @@ +package org.test + +class Class { + fun method() { + @java.lang.Deprecated fun localFunctionInsideMethod() {} + } +} + +fun function() { + @java.lang.Deprecated fun localFunctionInsideFunction() {} +} \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/methodAnnotations/annotations.txt b/plugins/annotation-collector/testData/collectToFile/methodAnnotations/annotations.txt index 293673eb739..605acbe21b8 100644 --- a/plugins/annotation-collector/testData/collectToFile/methodAnnotations/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/methodAnnotations/annotations.txt @@ -1,3 +1,8 @@ -a java.lang.Deprecated 0 +a java.lang.annotation.Retention 0 p org.test 0 -m 0 0/SomeClass$annotatedFunction$1 invoke +c 0 0/Ann +a org.test.Ann 1 +m 1 0/Parent overridenWithoutAnnotation +m 1 0/Parent notOverriden +m 1 0/Child overridenWithAnnotation +m 1 0/Child childMethod diff --git a/plugins/annotation-collector/testData/collectToFile/methodAnnotations/methodAnnotations.kt b/plugins/annotation-collector/testData/collectToFile/methodAnnotations/methodAnnotations.kt index 1f50f1217be..b5d33f19d52 100644 --- a/plugins/annotation-collector/testData/collectToFile/methodAnnotations/methodAnnotations.kt +++ b/plugins/annotation-collector/testData/collectToFile/methodAnnotations/methodAnnotations.kt @@ -1,13 +1,25 @@ package org.test -public class SomeClass { +annotation class Ann - public fun annotatedFunction() { +open class Parent { + @Ann + open fun overridenWithoutAnnotation() {} - @java.lang.Deprecated fun localFunction() { + open fun overridenWithAnnotation() {} - } + @Ann + fun notOverriden() {} - } + open fun notAnnotated() {} +} +class Child : Parent() { + override fun overridenWithoutAnnotation() {} + + @Ann + override fun overridenWithAnnotation() {} + + @Ann + fun childMethod() {} } \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/Ann.kt b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/Ann.kt new file mode 100644 index 00000000000..9ffea1300a4 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/Ann.kt @@ -0,0 +1,3 @@ +package org.test + +annotation class Ann \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/annotations.txt b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/annotations.txt new file mode 100644 index 00000000000..5b751309340 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/annotations.txt @@ -0,0 +1,10 @@ +a org.test.Ann 0 +p org.test 0 +m 0 0/TestFacade__PartAKt funA +m 0 0/TestFacade__PartAKt valA$annotations +m 0 0/TestFacade__PartBKt funB +m 0 0/TestFacade__PartBKt valB$annotations +m 0 0/TestFacade funA +m 0 0/TestFacade funB +a java.lang.annotation.Retention 1 +c 1 0/Ann diff --git a/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partA.kt b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partA.kt new file mode 100644 index 00000000000..663d7df0bbd --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partA.kt @@ -0,0 +1,10 @@ +@file:JvmMultifileClass +@file:JvmName("TestFacade") + +package org.test + +@Ann +fun funA() {} + +@Ann +val valA = 4 \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partB.kt b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partB.kt new file mode 100644 index 00000000000..adfb2728d1a --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/partB.kt @@ -0,0 +1,10 @@ +@file:JvmMultifileClass +@file:JvmName("TestFacade") + +package org.test + +@Ann +fun funB() {} + +@Ann +val valB = 4 \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/annotations.txt b/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/annotations.txt new file mode 100644 index 00000000000..6fdc9dc8866 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/annotations.txt @@ -0,0 +1,6 @@ +a java.lang.annotation.Retention 0 +p org.test 0 +c 0 0/Ann +a org.test.Ann 1 +m 1 0/TopLevelAnnotatedKt someAnnotatedFunction +m 1 0/TopLevelAnnotatedKt someAnnotatedValue$annotations diff --git a/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/topLevelAnnotated.kt b/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/topLevelAnnotated.kt new file mode 100644 index 00000000000..3b3bb012338 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/topLevelAnnotated.kt @@ -0,0 +1,9 @@ +package org.test + +annotation class Ann + +@Ann +fun someAnnotatedFunction() {} + +@Ann +val someAnnotatedValue = 4 \ No newline at end of file diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt index 05eba6850b4..9efcb048693 100644 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt @@ -31,11 +31,12 @@ import java.io.StringWriter abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() { override fun doTest(path: String) { val testName = getTestName(true) - val fileName = path + testName + ".kt" + val ktFiles = File(path).listFiles { file -> file.isFile && file.extension.toLowerCase() == "kt" } + val testFiles = ktFiles.map { TestFile(it.name, it.readText()) } val supportInheritedAnnotations = testName.startsWith("inherited") val collectorExtension = createTestEnvironment(supportInheritedAnnotations) - loadFileByFullPath(fileName) + loadMultiFiles(testFiles) CodegenTestUtil.generateFiles(myEnvironment, myFiles) val actualAnnotations = KotlinTestUtils.replaceHashWithStar(collectorExtension.stringWriter.toString()) diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java index eaa44d6622c..5fe4e59761e 100644 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java @@ -77,9 +77,9 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce doTest(fileName); } - @TestMetadata("inheritedSimple") - public void testInheritedSimple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedSimple/"); + @TestMetadata("inheritedComplex") + public void testInheritedComplex() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedComplex/"); doTest(fileName); } @@ -95,12 +95,24 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce doTest(fileName); } + @TestMetadata("localFunctions") + public void testLocalFunctions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/localFunctions/"); + doTest(fileName); + } + @TestMetadata("methodAnnotations") public void testMethodAnnotations() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/methodAnnotations/"); doTest(fileName); } + @TestMetadata("multiFileTopLevelAnnotated") + public void testMultiFileTopLevelAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/"); + doTest(fileName); + } + @TestMetadata("nestedClasses") public void testNestedClasses() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/nestedClasses/"); @@ -112,4 +124,10 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/platformStatic/"); doTest(fileName); } + + @TestMetadata("topLevelAnnotated") + public void testTopLevelAnnotated() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/"); + doTest(fileName); + } }