aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-13 17:04:58 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-13 17:04:58 +0100
commitaa3f05136ca743eac15a9f8deb939f69cff6eb70 (patch)
treef29f96f66e4e275c809188e8633250bb9711b79a /src/Java
parent7d0e2ec29213906a9c4deb9db7f8d9131fb4c2e1 (diff)
downloaddokka-aa3f05136ca743eac15a9f8deb939f69cff6eb70.tar.gz
dokka-aa3f05136ca743eac15a9f8deb939f69cff6eb70.tar.bz2
dokka-aa3f05136ca743eac15a9f8deb939f69cff6eb70.zip
import Java type parameters into documentation model
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/JavaDocumentationBuilder.kt31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 760a9a3a..879c0b2c 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiPrimitiveType
import com.intellij.psi.PsiModifierListOwner
import com.intellij.psi.PsiModifier
import com.intellij.psi.PsiArrayType
+import com.intellij.psi.PsiTypeParameter
public class JavaDocumentationBuilder() {
fun appendFile(file: PsiJavaFile, module: DocumentationModule) {
@@ -48,6 +49,12 @@ public class JavaDocumentationBuilder() {
}
}
+ fun DocumentationNode.appendMembers<T>(elements: Array<T>, buildFn: T.() -> DocumentationNode) =
+ appendChildren(elements, DocumentationReference.Kind.Member, buildFn)
+
+ fun DocumentationNode.appendDetails<T>(elements: Array<T>, buildFn: T.() -> DocumentationNode) =
+ appendChildren(elements, DocumentationReference.Kind.Detail, buildFn)
+
fun PsiClass.build(): DocumentationNode {
val kind = when {
isInterface() -> DocumentationNode.Kind.Interface
@@ -58,14 +65,16 @@ public class JavaDocumentationBuilder() {
val node = DocumentationNode(this, kind)
getExtendsListTypes().forEach { node.appendType(it, Kind.Supertype) }
getImplementsListTypes().forEach { node.appendType(it, Kind.Supertype) }
- node.appendChildren(getMethods()) { build() }
+ node.appendDetails(getTypeParameters()) { build() }
+ node.appendMembers(getMethods()) { build() }
return node
}
fun PsiMethod.build(): DocumentationNode {
val node = DocumentationNode(this, Kind.Function)
node.appendType(getReturnType())
- node.appendChildren(getParameterList().getParameters(), DocumentationReference.Kind.Detail) { build() }
+ node.appendDetails(getParameterList().getParameters()) { build() }
+ node.appendDetails(getTypeParameters()) { build() }
return node
}
@@ -75,6 +84,13 @@ public class JavaDocumentationBuilder() {
return node
}
+ fun PsiTypeParameter.build(): DocumentationNode {
+ val node = DocumentationNode(this, Kind.TypeParameter)
+ getExtendsListTypes().forEach { node.appendType(it, Kind.UpperBound) }
+ getImplementsListTypes().forEach { node.appendType(it, Kind.UpperBound) }
+ return node
+ }
+
fun DocumentationNode.appendModifiers(element: PsiModifierListOwner) {
val modifierList = element.getModifierList()
if (modifierList == null) {
@@ -92,9 +108,16 @@ public class JavaDocumentationBuilder() {
if (psiType == null) {
return
}
- val name = mapTypeName(psiType)
+ append(psiType.build(kind), DocumentationReference.Kind.Detail)
+ }
+
+ fun PsiType.build(kind: DocumentationNode.Kind = DocumentationNode.Kind.Type): DocumentationNode {
+ val name = mapTypeName(this)
val node = DocumentationNode(name, Content.Empty, kind)
- append(node, DocumentationReference.Kind.Detail)
+ if (this is PsiClassType) {
+ node.appendDetails(getParameters()) { build(Kind.TypeParameter) }
+ }
+ return node
}
private fun mapTypeName(psiType: PsiType): String = when (psiType) {