aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Java/JavaDocumentationBuilder.kt9
-rw-r--r--src/Kotlin/DocumentationBuilder.kt21
-rw-r--r--src/Model/DocumentationNode.kt6
3 files changed, 18 insertions, 18 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 4b554584..f6e01a75 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -123,7 +123,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
fun PsiField.build(): DocumentationNode {
val node = DocumentationNode(this, nodeKind())
if (!hasModifierProperty(PsiModifier.FINAL)) {
- node.append(DocumentationNode("var", Content.Empty, Kind.Modifier), DocumentationReference.Kind.Detail)
+ node.appendTextNode("var", Kind.Modifier)
}
node.appendType(getType())
return node
@@ -157,7 +157,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
val node = DocumentationNode(this, Kind.Parameter)
node.appendType(getType())
if (getType() is PsiEllipsisType) {
- node.append(DocumentationNode("vararg", Content.Empty, Kind.Annotation), DocumentationReference.Kind.Annotation)
+ node.appendTextNode("vararg", Kind.Annotation, DocumentationReference.Kind.Annotation)
}
return node
}
@@ -176,12 +176,11 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions)
}
PsiModifier.MODIFIERS.forEach {
if (it != "static" && modifierList.hasExplicitModifier(it)) {
- val modifierNode = DocumentationNode(it, Content.Empty, Kind.Modifier)
- append(modifierNode, DocumentationReference.Kind.Detail)
+ appendTextNode(it, Kind.Modifier)
}
}
if ((element is PsiClass || element is PsiMethod) && !element.hasModifierProperty(PsiModifier.FINAL)) {
- append(DocumentationNode("open", Content.Empty, Kind.Modifier), DocumentationReference.Kind.Detail)
+ appendTextNode("open", Kind.Modifier)
}
}
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 775c959a..e77f97c9 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -120,14 +120,12 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
}
val modifier = modality.name().toLowerCase()
- val node = DocumentationNode(modifier, Content.Empty, DocumentationNode.Kind.Modifier)
- append(node, DocumentationReference.Kind.Detail)
+ appendTextNode(modifier, DocumentationNode.Kind.Modifier)
}
fun DocumentationNode.appendVisibility(descriptor: DeclarationDescriptorWithVisibility) {
val modifier = descriptor.getVisibility().toString()
- val node = DocumentationNode(modifier, Content.Empty, DocumentationNode.Kind.Modifier)
- append(node, DocumentationReference.Kind.Detail)
+ appendTextNode(modifier, DocumentationNode.Kind.Modifier)
}
fun DocumentationNode.appendSupertypes(descriptor: ClassDescriptor) {
@@ -261,7 +259,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
val node = DocumentationNode(this, kind)
if (isInner()) {
- node.append(DocumentationNode("inner", Content.Empty, Kind.Modifier), DocumentationReference.Kind.Detail)
+ node.appendTextNode("inner", Kind.Modifier)
}
node.appendSupertypes(this)
if (getKind() != ClassKind.OBJECT && getKind() != ClassKind.ENUM_ENTRY) {
@@ -337,8 +335,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
node.appendAnnotations(this)
node.appendSourceLink(getSource())
if (isVar()) {
- node.append(DocumentationNode("var", Content.Empty, DocumentationNode.Kind.Modifier),
- DocumentationReference.Kind.Detail)
+ node.appendTextNode("var", DocumentationNode.Kind.Modifier)
}
getGetter()?.let {
if (!it.isDefault())
@@ -357,7 +354,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
val node = DocumentationNode(this, Kind.Parameter)
val varargType = getVarargElementType()
if (varargType != null) {
- node.append(DocumentationNode("vararg", Content.Empty, Kind.Annotation), DocumentationReference.Kind.Annotation)
+ node.appendTextNode("vararg", Kind.Annotation, DocumentationReference.Kind.Annotation)
node.appendType(varargType)
} else {
node.appendType(getType())
@@ -367,7 +364,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
if (psi != null) {
val defaultValueText = psi.getDefaultValue()?.getText()
if (defaultValueText != null) {
- node.append(DocumentationNode(defaultValueText, Content.Empty, Kind.Value), DocumentationReference.Kind.Detail)
+ node.appendTextNode(defaultValueText, Kind.Value)
}
}
}
@@ -391,15 +388,13 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
for (constraint in getUpperBounds()) {
if (constraint == builtIns.getDefaultBound())
continue
- val constraintNode = DocumentationNode(constraint.toString(), Content.Empty, DocumentationNode.Kind.UpperBound)
- node.append(constraintNode, DocumentationReference.Kind.Detail)
+ node.appendTextNode(constraint.toString(), DocumentationNode.Kind.UpperBound)
}
for (constraint in getLowerBounds()) {
if (KotlinBuiltIns.isNothing(constraint))
continue
- val constraintNode = DocumentationNode(constraint.toString(), Content.Empty, DocumentationNode.Kind.LowerBound)
- node.append(constraintNode, DocumentationReference.Kind.Detail)
+ node.appendTextNode(constraint.toString(), DocumentationNode.Kind.LowerBound)
}
return node
}
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index 64a854a8..ee948a87 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -121,3 +121,9 @@ fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationRefere
DocumentationReference.Kind.Owner -> child.addReferenceTo(this, DocumentationReference.Kind.Member)
}
}
+
+fun DocumentationNode.appendTextNode(text: String,
+ kind: DocumentationNode.Kind,
+ refKind: DocumentationReference.Kind = DocumentationReference.Kind.Detail) {
+ append(DocumentationNode(text, Content.Empty, kind), refKind)
+}