aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/JavaDocumentationBuilder.kt22
-rw-r--r--test/data/java/enumValues.java5
-rw-r--r--test/src/model/JavaTest.kt8
3 files changed, 32 insertions, 3 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 18fce4db..4b554584 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiEllipsisType
import com.intellij.psi.PsiField
import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiLiteralExpression
+import com.intellij.psi.PsiEnumConstant
public class JavaDocumentationBuilder(private val options: DocumentationOptions) {
fun appendFile(file: PsiJavaFile, module: DocumentationModule) {
@@ -100,7 +101,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
else -> DocumentationNode.Kind.Class
}
val node = DocumentationNode(this, kind)
- getExtendsListTypes().forEach { node.appendType(it, Kind.Supertype) }
+ getExtendsListTypes().filter { !ignoreSupertype(it) }.forEach { node.appendType(it, Kind.Supertype) }
getImplementsListTypes().forEach { node.appendType(it, Kind.Supertype) }
node.appendDetails(getTypeParameters()) { build() }
node.appendMembers(getMethods()) { build() }
@@ -109,9 +110,18 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
return node
}
+ fun ignoreSupertype(psiType: PsiClassType): Boolean {
+ if (psiType.getClassName() == "Enum") {
+ val psiClass = psiType.resolve()
+ if (psiClass?.getQualifiedName() == "java.lang.Enum") {
+ return true
+ }
+ }
+ return false
+ }
+
fun PsiField.build(): DocumentationNode {
- val node = DocumentationNode(this,
- if (hasModifierProperty(PsiModifier.STATIC)) DocumentationNode.Kind.ClassObjectProperty else DocumentationNode.Kind.Property)
+ val node = DocumentationNode(this, nodeKind())
if (!hasModifierProperty(PsiModifier.FINAL)) {
node.append(DocumentationNode("var", Content.Empty, Kind.Modifier), DocumentationReference.Kind.Detail)
}
@@ -119,6 +129,12 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
return node
}
+ private fun PsiField.nodeKind(): Kind = when {
+ this is PsiEnumConstant -> Kind.EnumItem
+ hasModifierProperty(PsiModifier.STATIC) -> Kind.ClassObjectProperty
+ else -> Kind.Property
+ }
+
fun PsiMethod.build(): DocumentationNode {
val node = DocumentationNode(this, nodeKind(),
if (isConstructor()) "<init>" else getName())
diff --git a/test/data/java/enumValues.java b/test/data/java/enumValues.java
new file mode 100644
index 00000000..0f622946
--- /dev/null
+++ b/test/data/java/enumValues.java
@@ -0,0 +1,5 @@
+package test;
+
+enum E {
+ Foo
+} \ No newline at end of file
diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt
index c727277a..6b3d7820 100644
--- a/test/src/model/JavaTest.kt
+++ b/test/src/model/JavaTest.kt
@@ -184,4 +184,12 @@ public class JavaTest {
assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name)
}
}
+
+ Test fun enumValues() {
+ verifyPackageMember("test/data/java/enumValues.java") { cls ->
+ val superTypes = cls.details(DocumentationNode.Kind.Supertype)
+ assertEquals(0, superTypes.size())
+ assertEquals(1, cls.members(DocumentationNode.Kind.EnumItem).size())
+ }
+ }
}