From 972118bcffbdf13ebd3aefd495618c4670bdc7b3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 4 Nov 2015 19:10:38 +0100 Subject: generate @deprecated tags for javadoc --- src/Java/JavaPsiDocumentationBuilder.kt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/Java') 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 ?: ""): DocumentationNode { + fun nodeForElement(element: PsiNamedElement, + kind: Kind, + name: String = element.name ?: ""): 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) "" 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 -- cgit