aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/JavaDocumentationBuilder.kt10
-rw-r--r--test/data/java/deprecation.java5
-rw-r--r--test/src/model/JavaTest.kt17
3 files changed, 30 insertions, 2 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index f3cc38f7..18fce4db 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -20,6 +20,7 @@ import com.intellij.psi.javadoc.PsiDocTagValue
import com.intellij.psi.PsiEllipsisType
import com.intellij.psi.PsiField
import com.intellij.psi.PsiAnnotation
+import com.intellij.psi.PsiLiteralExpression
public class JavaDocumentationBuilder(private val options: DocumentationOptions) {
fun appendFile(file: PsiJavaFile, module: DocumentationModule) {
@@ -62,7 +63,11 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
node.appendModifiers(element)
val modifierList = element.getModifierList()
if (modifierList != null) {
- node.appendChildren(modifierList.getAnnotations(), DocumentationReference.Kind.Annotation) { build() }
+ modifierList.getAnnotations().forEach {
+ val annotation = it.build()
+ node.append(annotation,
+ if (it.getQualifiedName() == "java.lang.Deprecated") DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation)
+ }
}
}
return node
@@ -201,7 +206,8 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
val parameter = DocumentationNode(it.getName() ?: "value", Content.Empty, DocumentationNode.Kind.Parameter)
val value = it.getValue()
if (value != null) {
- val valueNode = DocumentationNode(value.getText(), Content.Empty, DocumentationNode.Kind.Value)
+ val valueText = (value as? PsiLiteralExpression)?.getValue() as? String ?: value.getText()
+ val valueNode = DocumentationNode(valueText, Content.Empty, DocumentationNode.Kind.Value)
parameter.append(valueNode, DocumentationReference.Kind.Detail)
}
node.append(parameter, DocumentationReference.Kind.Detail)
diff --git a/test/data/java/deprecation.java b/test/data/java/deprecation.java
new file mode 100644
index 00000000..07cbd901
--- /dev/null
+++ b/test/data/java/deprecation.java
@@ -0,0 +1,5 @@
+package test;
+
+class C {
+ @Deprecated("This should no longer be used") void fn() {}
+} \ No newline at end of file
diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt
index cdb0ba44..c727277a 100644
--- a/test/src/model/JavaTest.kt
+++ b/test/src/model/JavaTest.kt
@@ -161,6 +161,23 @@ public class JavaTest {
}
}
+ Test fun deprecation() {
+ verifyPackageMember("test/data/java/deprecation.java") { cls ->
+ val fn = cls.members(DocumentationNode.Kind.Function).single()
+ with(fn.deprecation!!) {
+ assertEquals(1, details.count())
+ with(details[0]) {
+ assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(1, details.count())
+ with(details[0]) {
+ assertEquals(DocumentationNode.Kind.Value, kind)
+ assertEquals("This should no longer be used", name)
+ }
+ }
+ }
+ }
+ }
+
Test fun javaLangObject() {
verifyPackageMember("test/data/java/javaLangObject.java") { cls ->
val fn = cls.members(DocumentationNode.Kind.Function).single()