diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-08-03 15:07:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-03 15:07:57 +0200 |
commit | 256740ae75f30be7bd4f326b380f8ef2efd5d53c (patch) | |
tree | 953b061ca787e17f5274c227e4f65b8f97cc3efc /plugins/base/src/test/kotlin/translators | |
parent | 3994c42f2f2366d2e551e62412518a210581cb3a (diff) | |
download | dokka-256740ae75f30be7bd4f326b380f8ef2efd5d53c.tar.gz dokka-256740ae75f30be7bd4f326b380f8ef2efd5d53c.tar.bz2 dokka-256740ae75f30be7bd4f326b380f8ef2efd5d53c.zip |
Fix parsing of static imports in java annotation params (#2593)
Fixes #2580
Diffstat (limited to 'plugins/base/src/test/kotlin/translators')
-rw-r--r-- | plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt index 1ac54ae2..3f34f020 100644 --- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt +++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt @@ -198,6 +198,70 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() { } } + @Test + fun `should resolve static imports used as annotation param values as literal values`() { + testInline( + """ + |/src/main/java/test/JavaClassUsingAnnotation.java + |package test; + | + |import static test.JavaConstants.STRING; + |import static test.JavaConstants.INTEGER; + |import static test.JavaConstants.LONG; + |import static test.JavaConstants.BOOLEAN; + |import static test.JavaConstants.DOUBLE; + |import static test.JavaConstants.FLOAT; + | + |@JavaAnnotation( + | stringValue = STRING, intValue = INTEGER, longValue = LONG, + | booleanValue = BOOLEAN, doubleValue = DOUBLE, floatValue = FLOAT + |) + |public class JavaClassUsingAnnotation { + |} + | + |/src/main/java/test/JavaAnnotation.java + |package test; + |@Documented + |public @interface JavaAnnotation { + | String stringValue(); + | int intValue(); + | long longValue(); + | boolean booleanValue(); + | double doubleValue(); + | float floatValue(); + |} + | + |/src/main/java/test/JavaConstants.java + |package test; + |public class JavaConstants { + | public static final String STRING = "STRING_CONSTANT_VALUE"; + | public static final int INTEGER = 5; + | public static final long LONG = 6L; + | public static final boolean BOOLEAN = true; + | public static final double DOUBLE = 7.0d; + | public static final float FLOAT = 8.0f; + |} + """.trimIndent(), + configuration + ) { + documentablesMergingStage = { module -> + val testedClass = module.packages.single().classlikes.single { it.name == "JavaClassUsingAnnotation" } + + val annotation = (testedClass as DClass).extra[Annotations]?.directAnnotations?.values?.single()?.single() + checkNotNull(annotation) + + assertEquals("JavaAnnotation", annotation.dri.classNames) + assertEquals(StringValue("STRING_CONSTANT_VALUE"), annotation.params["stringValue"]) + + assertEquals(IntValue(5), annotation.params["intValue"]) + assertEquals(LongValue(6), annotation.params["longValue"]) + assertEquals(BooleanValue(true), annotation.params["booleanValue"]) + assertEquals(DoubleValue(7.0), annotation.params["doubleValue"]) + assertEquals(FloatValue(8.0f), annotation.params["floatValue"]) + } + } + } + class OnlyPsiPlugin : DokkaPlugin() { private val dokkaBase by lazy { plugin<DokkaBase>() } |