aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-16 12:32:41 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-16 12:32:48 +0100
commit4a458963ff15d113d7833cebba55065a910b135c (patch)
tree71276d0a626d9520f1a092999af402540819a273
parent77effb4fa1e9263c30ef3594934e91d51df6bae3 (diff)
downloaddokka-4a458963ff15d113d7833cebba55065a910b135c.tar.gz
dokka-4a458963ff15d113d7833cebba55065a910b135c.tar.bz2
dokka-4a458963ff15d113d7833cebba55065a910b135c.zip
handle vararg types
-rw-r--r--src/Java/JavaDocumentationBuilder.kt5
-rw-r--r--test/data/java/varargs.java5
-rw-r--r--test/src/model/JavaTest.kt10
3 files changed, 20 insertions, 0 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index c76c4c33..9d8c85a9 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -17,6 +17,7 @@ import com.intellij.psi.PsiArrayType
import com.intellij.psi.PsiTypeParameter
import com.intellij.psi.javadoc.PsiDocTag
import com.intellij.psi.javadoc.PsiDocTagValue
+import com.intellij.psi.PsiEllipsisType
public class JavaDocumentationBuilder() {
fun appendFile(file: PsiJavaFile, module: DocumentationModule) {
@@ -107,6 +108,9 @@ public class JavaDocumentationBuilder() {
fun PsiParameter.build(): DocumentationNode {
val node = DocumentationNode(this, Kind.Parameter)
node.appendType(getType())
+ if (getType() is PsiEllipsisType) {
+ node.append(DocumentationNode("vararg", Content.Empty, Kind.Annotation), DocumentationReference.Kind.Annotation)
+ }
return node
}
@@ -150,6 +154,7 @@ public class JavaDocumentationBuilder() {
PsiType.VOID -> "Unit"
is PsiPrimitiveType -> psiType.getCanonicalText().capitalize()
is PsiClassType -> psiType.getClassName()
+ is PsiEllipsisType -> mapTypeName(psiType.getComponentType())
is PsiArrayType -> "Array<${mapTypeName(psiType.getComponentType())}>"
else -> psiType.getCanonicalText()
}
diff --git a/test/data/java/varargs.java b/test/data/java/varargs.java
new file mode 100644
index 00000000..a6af6a8d
--- /dev/null
+++ b/test/data/java/varargs.java
@@ -0,0 +1,5 @@
+package test
+
+class Foo {
+ public void bar(String... x);
+}
diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt
index fe4fd322..e339f939 100644
--- a/test/src/model/JavaTest.kt
+++ b/test/src/model/JavaTest.kt
@@ -107,4 +107,14 @@ public class JavaTest {
assertEquals("D", innerClass.name)
}
}
+
+ Test fun varargs() {
+ verifyPackageMember("test/data/java/varargs.java") { cls ->
+ val fn = cls.members(DocumentationNode.Kind.Function).single()
+ val param = fn.detail(DocumentationNode.Kind.Parameter)
+ assertEquals("vararg", param.annotations.first().name)
+ val psiType = param.detail(DocumentationNode.Kind.Type)
+ assertEquals("String", psiType.name)
+ }
+ }
}