diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/JavaPsiDocumentationBuilder.kt | 20 | ||||
-rw-r--r-- | src/Model/Content.kt | 8 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/Java/JavaPsiDocumentationBuilder.kt b/src/Java/JavaPsiDocumentationBuilder.kt index fc60450a..72f398ce 100644 --- a/src/Java/JavaPsiDocumentationBuilder.kt +++ b/src/Java/JavaPsiDocumentationBuilder.kt @@ -80,9 +80,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } } - fun DocumentationNode(element: PsiNamedElement, - kind: Kind, - name: String = element.name ?: "<anonymous>"): DocumentationNode { + fun nodeForElement(element: PsiNamedElement, + kind: Kind, + name: String = element.name ?: "<anonymous>"): DocumentationNode { val (docComment, deprecatedContent) = docParser.parseDocumentation(element) val node = DocumentationNode(name, docComment, kind) if (element is PsiModifierListOwner) { @@ -100,6 +100,10 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { val deprecationNode = DocumentationNode("", deprecatedContent, Kind.Modifier) node.append(deprecationNode, DocumentationReference.Kind.Deprecation) } + if (element is PsiDocCommentOwner && element.isDeprecated && node.deprecation == null) { + val deprecationNode = DocumentationNode("", Content.of(ContentText("Deprecated")), Kind.Modifier) + node.append(deprecationNode, DocumentationReference.Kind.Deprecation) + } return node } @@ -140,7 +144,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { isAnnotationType -> DocumentationNode.Kind.AnnotationClass else -> DocumentationNode.Kind.Class } - val node = DocumentationNode(this, kind) + val node = nodeForElement(this, kind) superTypes.filter { !ignoreSupertype(it) }.forEach { node.appendType(it, Kind.Supertype) val superClass = it.resolve() @@ -169,7 +173,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } fun PsiField.build(): DocumentationNode { - val node = DocumentationNode(this, nodeKind()) + val node = nodeForElement(this, nodeKind()) node.appendType(type) node.appendModifiers(this) register(this, node) @@ -182,7 +186,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } fun PsiMethod.build(): DocumentationNode { - val node = DocumentationNode(this, nodeKind(), + val node = nodeForElement(this, nodeKind(), if (isConstructor) "<init>" else name) if (!isConstructor) { @@ -200,7 +204,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } fun PsiParameter.build(): DocumentationNode { - val node = DocumentationNode(this, Kind.Parameter) + val node = nodeForElement(this, Kind.Parameter) node.appendType(type) if (type is PsiEllipsisType) { node.appendTextNode("vararg", Kind.Modifier, DocumentationReference.Kind.Detail) @@ -209,7 +213,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } fun PsiTypeParameter.build(): DocumentationNode { - val node = DocumentationNode(this, Kind.TypeParameter) + val node = nodeForElement(this, Kind.TypeParameter) extendsListTypes.forEach { node.appendType(it, Kind.UpperBound) } implementsListTypes.forEach { node.appendType(it, Kind.UpperBound) } return node diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 45d42a2d..6556b09e 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -11,7 +11,7 @@ public object ContentEmpty : ContentNode { public open class ContentBlock() : ContentNode { val children = arrayListOf<ContentNode>() - fun append(node : ContentNode) { + fun append(node: ContentNode) { children.add(node) } @@ -173,6 +173,12 @@ public open class Content(): ContentBlock() { companion object { val Empty = Content() + + fun of(vararg child: ContentNode): Content { + val result = MutableContent() + child.forEach { result.append(it) } + return result + } } } |