aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Java/JavaDocumentationBuilder.kt10
-rw-r--r--src/Languages/JavaLanguageService.kt12
-rw-r--r--src/Model/Content.kt7
-rw-r--r--src/Model/DocumentationNode.kt5
-rw-r--r--src/Utilities/Path.kt5
5 files changed, 28 insertions, 11 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 01ecb478..88c13d38 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -108,8 +108,11 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
}
private fun MutableContent.convertSeeTag(tag: PsiDocTag) {
- val linkElement = tag.linkElement() ?: return
- val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null)
+ val linkElement = tag.linkElement()
+ if (linkElement == null) {
+ return
+ }
+ val seeSection = findSectionByTag(ContentTags.SeeAlso) ?: addSection(ContentTags.SeeAlso, null)
val linkSignature = resolveLink(linkElement)
val text = ContentText(linkElement.text)
if (linkSignature != null) {
@@ -189,7 +192,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
is PsiField -> element.containingClass!!.qualifiedName + "#" + element.name
is PsiMethod ->
element.containingClass!!.qualifiedName + "#" + element.name + "(" +
- element.parameterList.parameters.map { it.type.typeSignature() }.joinToString(",") + ")"
+ element.parameterList.parameters.map { it.type.typeSignature() }.join(",") + ")"
else -> null
}
@@ -339,6 +342,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
fun DocumentationNode.appendModifiers(element: PsiModifierListOwner) {
val modifierList = element.modifierList ?: return
+
PsiModifier.MODIFIERS.forEach {
if (it != "static" && modifierList.hasExplicitModifier(it)) {
appendTextNode(it, Kind.Modifier)
diff --git a/src/Languages/JavaLanguageService.kt b/src/Languages/JavaLanguageService.kt
index 8648448e..5750588e 100644
--- a/src/Languages/JavaLanguageService.kt
+++ b/src/Languages/JavaLanguageService.kt
@@ -48,6 +48,18 @@ public class JavaLanguageService : LanguageService {
}
}
+ public fun getArrayElementType(node: DocumentationNode): DocumentationNode? = when (node.name) {
+ "Array" -> node.details(Kind.Type).singleOrNull()?.let { et -> getArrayElementType(et) ?: et } ?: DocumentationNode("Object", node.content, DocumentationNode.Kind.ExternalClass)
+ "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> DocumentationNode(node.name.removeSuffix("Array").toLowerCase(), node.content, DocumentationNode.Kind.Type)
+ else -> null
+ }
+
+ public fun getArrayDimension(node: DocumentationNode): Int = when (node.name) {
+ "Array" -> 1 + (node.details(DocumentationNode.Kind.Type).singleOrNull()?.let { getArrayDimension(it) } ?: 0)
+ "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> 1
+ else -> 0
+ }
+
public fun renderType(node: DocumentationNode): String {
return when (node.name) {
"Unit" -> "void"
diff --git a/src/Model/Content.kt b/src/Model/Content.kt
index e7dfc241..45d42a2d 100644
--- a/src/Model/Content.kt
+++ b/src/Model/Content.kt
@@ -126,6 +126,11 @@ public class ContentSection(public val tag: String, public val subjectName: Stri
children.hashCode() * 31 * 31 + tag.hashCode() * 31 + (subjectName?.hashCode() ?: 0)
}
+public object ContentTags {
+ val Description = "Description"
+ val SeeAlso = "See Also"
+}
+
fun content(body: ContentBlock.() -> Unit): ContentBlock {
val block = ContentBlock()
block.body()
@@ -189,7 +194,7 @@ public open class MutableContent() : Content() {
if (descriptionNodes.isEmpty()) {
ContentEmpty
} else {
- val result = ContentSection("Description", null)
+ val result = ContentSection(ContentTags.Description, null)
result.children.addAll(descriptionNodes)
result
}
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index 468cb878..4a77f761 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -123,9 +123,7 @@ public class DocumentationModule(name: String, content: Content = Content.Empty)
val DocumentationNode.path: List<DocumentationNode>
get() {
- val parent = owner
- if (parent == null)
- return listOf(this)
+ val parent = owner ?: return listOf(this)
return parent.path + this
}
@@ -143,6 +141,7 @@ fun DocumentationNode.findOrCreatePackageNode(packageName: String, packageConten
fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationReference.Kind) {
addReferenceTo(child, kind)
+ @suppress("NON_EXHAUSTIVE_WHEN")
when (kind) {
DocumentationReference.Kind.Detail -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
DocumentationReference.Kind.Member -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
diff --git a/src/Utilities/Path.kt b/src/Utilities/Path.kt
index 292b0eed..36277d9f 100644
--- a/src/Utilities/Path.kt
+++ b/src/Utilities/Path.kt
@@ -4,10 +4,7 @@ import java.io.File
import java.io.IOException
fun File.getRelativePath(name: File): File {
- val parent = parentFile
-
- if (parent == null)
- throw IOException("No common directory");
+ val parent = parentFile ?: throw IOException("No common directory")
val basePath = canonicalPath + File.separator;
val targetPath = name.canonicalPath;