aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Formats/StructuredFormatService.kt9
-rw-r--r--src/Java/JavaPsiDocumentationBuilder.kt27
-rw-r--r--src/Kotlin/KotlinLanguageService.kt6
-rw-r--r--src/Model/DocumentationNode.kt8
4 files changed, 16 insertions, 34 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt
index 41ffc61d..6bc28522 100644
--- a/src/Formats/StructuredFormatService.kt
+++ b/src/Formats/StructuredFormatService.kt
@@ -308,14 +308,7 @@ abstract class StructuredFormatService(locationService: LocationService,
}
appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), node, to)
- appendSection(location, "Types", node.members.filter {
- it.kind in setOf(
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Enum,
- DocumentationNode.Kind.Object,
- DocumentationNode.Kind.AnnotationClass)
- }, node, to)
+ appendSection(location, "Types", node.members.filter { it.kind in DocumentationNode.Kind.classLike }, node, to)
appendSection(location, "Extensions for External Classes", node.members(DocumentationNode.Kind.ExternalClass), node, to)
appendSection(location, "Enum Values", node.members(DocumentationNode.Kind.EnumItem), node, to)
appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to)
diff --git a/src/Java/JavaPsiDocumentationBuilder.kt b/src/Java/JavaPsiDocumentationBuilder.kt
index a5ee891e..bdc6a368 100644
--- a/src/Java/JavaPsiDocumentationBuilder.kt
+++ b/src/Java/JavaPsiDocumentationBuilder.kt
@@ -186,14 +186,10 @@ private fun PsiType.typeSignature(): String = when(this) {
}
private fun mapTypeName(psiType: PsiType): String = when (psiType) {
- PsiType.VOID -> "Unit"
- is PsiPrimitiveType -> psiType.canonicalText.capitalize()
- is PsiClassType -> {
- val psiClass = psiType.resolve()
- if (psiClass?.qualifiedName == "java.lang.Object") "Any" else psiType.className
- }
+ is PsiPrimitiveType -> psiType.canonicalText
+ is PsiClassType -> psiType.className
is PsiEllipsisType -> mapTypeName(psiType.componentType)
- is PsiArrayType -> "Array"
+ is PsiArrayType -> mapTypeName(psiType.componentType) + "[]"
else -> psiType.canonicalText
}
@@ -236,6 +232,7 @@ class JavaPsiDocumentationBuilder(private val options: DocumentationOptions,
refGraph.link(qualifiedName, node, kind)
}
}
+
fun DocumentationNode(element: PsiNamedElement,
kind: Kind,
name: String = element.name ?: "<anonymous>"): DocumentationNode {
@@ -326,18 +323,15 @@ class JavaPsiDocumentationBuilder(private val options: DocumentationOptions,
fun PsiField.build(): DocumentationNode {
val node = DocumentationNode(this, nodeKind())
- if (!hasModifierProperty(PsiModifier.FINAL)) {
- node.appendTextNode("var", Kind.Modifier)
- }
node.appendType(type)
+ node.appendModifiers(this)
register(this, node)
return node
}
private fun PsiField.nodeKind(): Kind = when {
this is PsiEnumConstant -> Kind.EnumItem
- hasModifierProperty(PsiModifier.STATIC) -> Kind.CompanionObjectProperty
- else -> Kind.Property
+ else -> Kind.Field
}
fun PsiMethod.build(): DocumentationNode {
@@ -355,7 +349,6 @@ class JavaPsiDocumentationBuilder(private val options: DocumentationOptions,
private fun PsiMethod.nodeKind(): Kind = when {
isConstructor -> Kind.Constructor
- hasModifierProperty(PsiModifier.STATIC) -> Kind.CompanionObjectFunction
else -> Kind.Function
}
@@ -363,7 +356,7 @@ class JavaPsiDocumentationBuilder(private val options: DocumentationOptions,
val node = DocumentationNode(this, Kind.Parameter)
node.appendType(type)
if (type is PsiEllipsisType) {
- node.appendTextNode("vararg", Kind.Annotation, DocumentationReference.Kind.Annotation)
+ node.appendTextNode("vararg", Kind.Modifier, DocumentationReference.Kind.Detail)
}
return node
}
@@ -379,14 +372,10 @@ class JavaPsiDocumentationBuilder(private val options: DocumentationOptions,
val modifierList = element.modifierList ?: return
PsiModifier.MODIFIERS.forEach {
- if (it != "static" && modifierList.hasExplicitModifier(it)) {
+ if (modifierList.hasExplicitModifier(it)) {
appendTextNode(it, Kind.Modifier)
}
}
- if ((element is PsiClass || (element is PsiMethod && !element.isConstructor)) &&
- !element.hasModifierProperty(PsiModifier.FINAL)) {
- appendTextNode("open", Kind.Modifier)
- }
}
fun DocumentationNode.appendType(psiType: PsiType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) {
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index 3c4b974f..d07f4c09 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -12,11 +12,7 @@ class KotlinLanguageService : LanguageService {
return content {
when (node.kind) {
DocumentationNode.Kind.Package -> if (renderMode == RenderMode.FULL) renderPackage(node)
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Enum,
- DocumentationNode.Kind.AnnotationClass,
- DocumentationNode.Kind.Object -> renderClass(node, renderMode)
+ in DocumentationNode.Kind.classLike -> renderClass(node, renderMode)
DocumentationNode.Kind.EnumItem,
DocumentationNode.Kind.ExternalClass -> if (renderMode == RenderMode.FULL) identifier(node.name)
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index 44e9099e..52881f65 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -82,6 +82,7 @@ public open class DocumentationNode(val name: String,
Constructor,
Function,
Property,
+ Field,
CompanionObjectProperty,
CompanionObjectFunction,
@@ -112,9 +113,12 @@ public open class DocumentationNode(val name: String,
* A note which is rendered once on a page documenting a group of overloaded functions.
* Needs to be generated equally on all overloads.
*/
- OverloadGroupNote
- }
+ OverloadGroupNote;
+ companion object {
+ val classLike = setOf(Class, Interface, Enum, AnnotationClass, Object)
+ }
+ }
}
public class DocumentationModule(name: String, content: Content = Content.Empty)