aboutsummaryrefslogtreecommitdiff
path: root/src/Java/JavaDocumentationBuilder.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/JavaDocumentationBuilder.kt')
-rw-r--r--src/Java/JavaDocumentationBuilder.kt22
1 files changed, 19 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())