aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-01-04 20:08:39 +0100
committerDmitry Jemerov <yole@jetbrains.com>2016-01-04 20:08:39 +0100
commit2e77e004919664512f88d3ce8d28697c26f9c521 (patch)
treedc278a37e2152bac89fc3e0582eb1e7fd69eeeb3
parentfc13de8cedb956107b624ebb0a7e4c3544a504ca (diff)
downloaddokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.gz
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.bz2
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.zip
cleanup: DocumentationNode.Kind -> NodeKind, DocumentationReference.Kind -> RefKind
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt78
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt79
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt4
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt125
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt112
-rw-r--r--core/src/main/kotlin/Languages/JavaLanguageService.kt63
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt166
-rw-r--r--core/src/main/kotlin/Model/DocumentationReference.kt41
-rw-r--r--core/src/main/kotlin/Model/SourceLinks.kt10
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt170
-rw-r--r--core/src/main/kotlin/javadoc/source-position.kt3
-rw-r--r--core/src/main/kotlin/javadoc/tags.kt4
-rw-r--r--core/src/test/kotlin/model/ClassTest.kt70
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt46
-rw-r--r--core/src/test/kotlin/model/JavaTest.kt92
-rw-r--r--core/src/test/kotlin/model/KotlinAsJavaTest.kt8
-rw-r--r--core/src/test/kotlin/model/LinkTest.kt8
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt14
-rw-r--r--core/src/test/kotlin/model/PropertyTest.kt30
19 files changed, 561 insertions, 562 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 324f156a..941ee899 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -103,7 +103,7 @@ abstract class StructuredFormatService(locationService: LocationService,
}
fun locationHref(from: Location, to: DocumentationNode): String {
- val topLevelPage = to.references(DocumentationReference.Kind.TopLevelPage).singleOrNull()?.to
+ val topLevelPage = to.references(RefKind.TopLevelPage).singleOrNull()?.to
if (topLevelPage != null) {
return from.relativePathTo(locationService.location(topLevelPage), to.name)
}
@@ -137,7 +137,7 @@ abstract class StructuredFormatService(locationService: LocationService,
}
// All items have exactly the same documentation, so we can use any item to render it
val item = items.first()
- item.details(DocumentationNode.Kind.OverloadGroupNote).forEach {
+ item.details(NodeKind.OverloadGroupNote).forEach {
to.append(formatText(location, it.content))
}
to.append(formatText(location, item.content.summary))
@@ -147,7 +147,7 @@ abstract class StructuredFormatService(locationService: LocationService,
}
private fun DocumentationNode.isModuleOrPackage(): Boolean =
- kind == DocumentationNode.Kind.Module || kind == DocumentationNode.Kind.Package
+ kind == NodeKind.Module || kind == NodeKind.Package
protected open fun appendAsSignature(to: StringBuilder, node: ContentNode, block: () -> Unit) {
block()
@@ -198,8 +198,8 @@ abstract class StructuredFormatService(locationService: LocationService,
private fun DocumentationNode.appendDeprecation(location: Location, to: StringBuilder) {
if (deprecation != null) {
- val deprecationParameter = deprecation!!.details(DocumentationNode.Kind.Parameter).firstOrNull()
- val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull()
+ val deprecationParameter = deprecation!!.details(NodeKind.Parameter).firstOrNull()
+ val deprecationValue = deprecationParameter?.details(NodeKind.Value)?.firstOrNull()
if (deprecationValue != null) {
to.append(formatStrong("Deprecated:")).append(" ")
appendLine(to, formatText(deprecationValue.name.removeSurrounding("\"")))
@@ -215,7 +215,7 @@ abstract class StructuredFormatService(locationService: LocationService,
}
private fun DocumentationNode.appendSourceLink(to: StringBuilder) {
- val sourceUrl = details(DocumentationNode.Kind.SourceUrl).firstOrNull()
+ val sourceUrl = details(NodeKind.SourceUrl).firstOrNull()
if (sourceUrl != null) {
to.append(" ")
appendLine(to, formatLink("(source)", sourceUrl.name))
@@ -227,7 +227,7 @@ abstract class StructuredFormatService(locationService: LocationService,
fun appendLocation(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
val singleNode = nodes.singleOrNull()
if (singleNode != null && singleNode.isModuleOrPackage()) {
- if (singleNode.kind == DocumentationNode.Kind.Package) {
+ if (singleNode.kind == NodeKind.Package) {
appendHeader(to, "Package " + formatText(singleNode.name), 2)
}
to.append(formatText(location, singleNode.content))
@@ -307,51 +307,51 @@ abstract class StructuredFormatService(locationService: LocationService,
for ((breadcrumbs, items) in breakdownByLocation) {
appendLine(to, breadcrumbs)
appendLine(to)
- appendLocation(location, to, items.filter { it.kind != DocumentationNode.Kind.ExternalClass })
+ appendLocation(location, to, items.filter { it.kind != NodeKind.ExternalClass })
}
for (node in nodes) {
- if (node.kind == DocumentationNode.Kind.ExternalClass) {
+ if (node.kind == NodeKind.ExternalClass) {
appendSection(location, "Extensions for ${node.name}", node.members, node, to)
continue
}
- appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), 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)
- appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to)
- appendSection(location, "Inherited Properties", node.inheritedMembers(DocumentationNode.Kind.Property), node, to)
- appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to)
- appendSection(location, "Inherited Functions", node.inheritedMembers(DocumentationNode.Kind.Function), node, to)
- appendSection(location, "Companion Object Properties", node.members(DocumentationNode.Kind.CompanionObjectProperty), node, to)
- appendSection(location, "Companion Object Functions", node.members(DocumentationNode.Kind.CompanionObjectFunction), node, to)
+ appendSection(location, "Packages", node.members(NodeKind.Package), node, to)
+ appendSection(location, "Types", node.members.filter { it.kind in NodeKind.classLike }, node, to)
+ appendSection(location, "Extensions for External Classes", node.members(NodeKind.ExternalClass), node, to)
+ appendSection(location, "Enum Values", node.members(NodeKind.EnumItem), node, to)
+ appendSection(location, "Constructors", node.members(NodeKind.Constructor), node, to)
+ appendSection(location, "Properties", node.members(NodeKind.Property), node, to)
+ appendSection(location, "Inherited Properties", node.inheritedMembers(NodeKind.Property), node, to)
+ appendSection(location, "Functions", node.members(NodeKind.Function), node, to)
+ appendSection(location, "Inherited Functions", node.inheritedMembers(NodeKind.Function), node, to)
+ appendSection(location, "Companion Object Properties", node.members(NodeKind.CompanionObjectProperty), node, to)
+ appendSection(location, "Companion Object Functions", node.members(NodeKind.CompanionObjectFunction), node, to)
appendSection(location, "Other members", node.members.filter {
it.kind !in setOf(
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Enum,
- DocumentationNode.Kind.Object,
- DocumentationNode.Kind.AnnotationClass,
- DocumentationNode.Kind.Constructor,
- DocumentationNode.Kind.Property,
- DocumentationNode.Kind.Package,
- DocumentationNode.Kind.Function,
- DocumentationNode.Kind.CompanionObjectProperty,
- DocumentationNode.Kind.CompanionObjectFunction,
- DocumentationNode.Kind.ExternalClass,
- DocumentationNode.Kind.EnumItem
+ NodeKind.Class,
+ NodeKind.Interface,
+ NodeKind.Enum,
+ NodeKind.Object,
+ NodeKind.AnnotationClass,
+ NodeKind.Constructor,
+ NodeKind.Property,
+ NodeKind.Package,
+ NodeKind.Function,
+ NodeKind.CompanionObjectProperty,
+ NodeKind.CompanionObjectFunction,
+ NodeKind.ExternalClass,
+ NodeKind.EnumItem
)
}, node, to)
val allExtensions = collectAllExtensions(node)
- appendSection(location, "Extension Properties", allExtensions.filter { it.kind == DocumentationNode.Kind.Property }, node, to)
- appendSection(location, "Extension Functions", allExtensions.filter { it.kind == DocumentationNode.Kind.Function }, node, to)
- appendSection(location, "Companion Object Extension Properties", allExtensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty }, node, to)
- appendSection(location, "Companion Object Extension Functions", allExtensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectFunction }, node, to)
+ appendSection(location, "Extension Properties", allExtensions.filter { it.kind == NodeKind.Property }, node, to)
+ appendSection(location, "Extension Functions", allExtensions.filter { it.kind == NodeKind.Function }, node, to)
+ appendSection(location, "Companion Object Extension Properties", allExtensions.filter { it.kind == NodeKind.CompanionObjectProperty }, node, to)
+ appendSection(location, "Companion Object Extension Functions", allExtensions.filter { it.kind == NodeKind.CompanionObjectFunction }, node, to)
appendSection(location, "Inheritors",
- node.inheritors.filter { it.kind != DocumentationNode.Kind.EnumItem }, node, to)
+ node.inheritors.filter { it.kind != NodeKind.EnumItem }, node, to)
appendSection(location, "Links", node.links, node, to)
}
@@ -364,7 +364,7 @@ abstract class StructuredFormatService(locationService: LocationService,
fun collect(node: DocumentationNode) {
if (!visited.add(node)) return
result.addAll(node.extensions)
- node.references(DocumentationReference.Kind.Superclass).forEach { collect(it.to) }
+ node.references(RefKind.Superclass).forEach { collect(it.to) }
}
collect(node)
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index 3c9875cd..c16e66c6 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -2,7 +2,6 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.intellij.psi.*
-import org.jetbrains.dokka.DocumentationNode.Kind
fun getSignature(element: PsiElement?) = when(element) {
is PsiClass -> element.qualifiedName
@@ -69,11 +68,11 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
fun link(node: DocumentationNode, element: PsiElement?) {
val qualifiedName = getSignature(element)
if (qualifiedName != null) {
- refGraph.link(node, qualifiedName, DocumentationReference.Kind.Link)
+ refGraph.link(node, qualifiedName, RefKind.Link)
}
}
- fun link(element: PsiElement?, node: DocumentationNode, kind: DocumentationReference.Kind) {
+ fun link(element: PsiElement?, node: DocumentationNode, kind: RefKind) {
val qualifiedName = getSignature(element)
if (qualifiedName != null) {
refGraph.link(qualifiedName, node, kind)
@@ -81,7 +80,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
fun nodeForElement(element: PsiNamedElement,
- kind: Kind,
+ kind: NodeKind,
name: String = element.name ?: "<anonymous>"): DocumentationNode {
val (docComment, deprecatedContent) = docParser.parseDocumentation(element)
val node = DocumentationNode(name, docComment, kind)
@@ -92,17 +91,17 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
modifierList.annotations.filter { !ignoreAnnotation(it) }.forEach {
val annotation = it.build()
node.append(annotation,
- if (it.qualifiedName == "java.lang.Deprecated") DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation)
+ if (it.qualifiedName == "java.lang.Deprecated") RefKind.Deprecation else RefKind.Annotation)
}
}
}
if (deprecatedContent != null) {
- val deprecationNode = DocumentationNode("", deprecatedContent, Kind.Modifier)
- node.append(deprecationNode, DocumentationReference.Kind.Deprecation)
+ val deprecationNode = DocumentationNode("", deprecatedContent, NodeKind.Modifier)
+ node.append(deprecationNode, RefKind.Deprecation)
}
if (element is PsiDocCommentOwner && element.isDeprecated && node.deprecation == null) {
- val deprecationNode = DocumentationNode("", Content.of(ContentText("Deprecated")), Kind.Modifier)
- node.append(deprecationNode, DocumentationReference.Kind.Deprecation)
+ val deprecationNode = DocumentationNode("", Content.of(ContentText("Deprecated")), NodeKind.Modifier)
+ node.append(deprecationNode, RefKind.Deprecation)
}
return node
}
@@ -113,7 +112,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
fun <T : Any> DocumentationNode.appendChildren(elements: Array<T>,
- kind: DocumentationReference.Kind = DocumentationReference.Kind.Member,
+ kind: RefKind = RefKind.Member,
buildFn: T.() -> DocumentationNode) {
elements.forEach {
if (!skipElement(it)) {
@@ -132,24 +131,24 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
element is PsiDocCommentOwner && element.docComment?.let { it.findTagByName("suppress") != null } ?: false
fun <T : Any> DocumentationNode.appendMembers(elements: Array<T>, buildFn: T.() -> DocumentationNode) =
- appendChildren(elements, DocumentationReference.Kind.Member, buildFn)
+ appendChildren(elements, RefKind.Member, buildFn)
fun <T : Any> DocumentationNode.appendDetails(elements: Array<T>, buildFn: T.() -> DocumentationNode) =
- appendChildren(elements, DocumentationReference.Kind.Detail, buildFn)
+ appendChildren(elements, RefKind.Detail, buildFn)
fun PsiClass.build(): DocumentationNode {
val kind = when {
- isInterface -> DocumentationNode.Kind.Interface
- isEnum -> DocumentationNode.Kind.Enum
- isAnnotationType -> DocumentationNode.Kind.AnnotationClass
- else -> DocumentationNode.Kind.Class
+ isInterface -> NodeKind.Interface
+ isEnum -> NodeKind.Enum
+ isAnnotationType -> NodeKind.AnnotationClass
+ else -> NodeKind.Class
}
val node = nodeForElement(this, kind)
superTypes.filter { !ignoreSupertype(it) }.forEach {
- node.appendType(it, Kind.Supertype)
+ node.appendType(it, NodeKind.Supertype)
val superClass = it.resolve()
if (superClass != null) {
- link(superClass, node, DocumentationReference.Kind.Inheritor)
+ link(superClass, node, RefKind.Inheritor)
}
}
node.appendDetails(typeParameters) { build() }
@@ -180,9 +179,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
return node
}
- private fun PsiField.nodeKind(): Kind = when {
- this is PsiEnumConstant -> Kind.EnumItem
- else -> Kind.Field
+ private fun PsiField.nodeKind(): NodeKind = when {
+ this is PsiEnumConstant -> NodeKind.EnumItem
+ else -> NodeKind.Field
}
fun PsiMethod.build(): DocumentationNode {
@@ -198,24 +197,24 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
return node
}
- private fun PsiMethod.nodeKind(): Kind = when {
- isConstructor -> Kind.Constructor
- else -> Kind.Function
+ private fun PsiMethod.nodeKind(): NodeKind = when {
+ isConstructor -> NodeKind.Constructor
+ else -> NodeKind.Function
}
fun PsiParameter.build(): DocumentationNode {
- val node = nodeForElement(this, Kind.Parameter)
+ val node = nodeForElement(this, NodeKind.Parameter)
node.appendType(type)
if (type is PsiEllipsisType) {
- node.appendTextNode("vararg", Kind.Modifier, DocumentationReference.Kind.Detail)
+ node.appendTextNode("vararg", NodeKind.Modifier, RefKind.Detail)
}
return node
}
fun PsiTypeParameter.build(): DocumentationNode {
- val node = nodeForElement(this, Kind.TypeParameter)
- extendsListTypes.forEach { node.appendType(it, Kind.UpperBound) }
- implementsListTypes.forEach { node.appendType(it, Kind.UpperBound) }
+ val node = nodeForElement(this, NodeKind.TypeParameter)
+ extendsListTypes.forEach { node.appendType(it, NodeKind.UpperBound) }
+ implementsListTypes.forEach { node.appendType(it, NodeKind.UpperBound) }
return node
}
@@ -224,42 +223,42 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
PsiModifier.MODIFIERS.forEach {
if (modifierList.hasExplicitModifier(it)) {
- appendTextNode(it, Kind.Modifier)
+ appendTextNode(it, NodeKind.Modifier)
}
}
}
- fun DocumentationNode.appendType(psiType: PsiType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) {
+ fun DocumentationNode.appendType(psiType: PsiType?, kind: NodeKind = NodeKind.Type) {
if (psiType == null) {
return
}
- append(psiType.build(kind), DocumentationReference.Kind.Detail)
+ append(psiType.build(kind), RefKind.Detail)
}
- fun PsiType.build(kind: DocumentationNode.Kind = DocumentationNode.Kind.Type): DocumentationNode {
+ fun PsiType.build(kind: NodeKind = NodeKind.Type): DocumentationNode {
val name = mapTypeName(this)
val node = DocumentationNode(name, Content.Empty, kind)
if (this is PsiClassType) {
- node.appendDetails(parameters) { build(Kind.Type) }
+ node.appendDetails(parameters) { build(NodeKind.Type) }
link(node, resolve())
}
if (this is PsiArrayType && this !is PsiEllipsisType) {
- node.append(componentType.build(Kind.Type), DocumentationReference.Kind.Detail)
+ node.append(componentType.build(NodeKind.Type), RefKind.Detail)
}
return node
}
fun PsiAnnotation.build(): DocumentationNode {
- val node = DocumentationNode(nameReferenceElement?.text ?: "<?>", Content.Empty, DocumentationNode.Kind.Annotation)
+ val node = DocumentationNode(nameReferenceElement?.text ?: "<?>", Content.Empty, NodeKind.Annotation)
parameterList.attributes.forEach {
- val parameter = DocumentationNode(it.name ?: "value", Content.Empty, DocumentationNode.Kind.Parameter)
+ val parameter = DocumentationNode(it.name ?: "value", Content.Empty, NodeKind.Parameter)
val value = it.value
if (value != null) {
val valueText = (value as? PsiLiteralExpression)?.value as? String ?: value.text
- val valueNode = DocumentationNode(valueText, Content.Empty, DocumentationNode.Kind.Value)
- parameter.append(valueNode, DocumentationReference.Kind.Detail)
+ val valueNode = DocumentationNode(valueText, Content.Empty, NodeKind.Value)
+ parameter.append(valueNode, RefKind.Detail)
}
- node.append(parameter, DocumentationReference.Kind.Detail)
+ node.append(parameter, RefKind.Detail)
}
return node
}
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
index b7705ec9..3a5769c9 100644
--- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
+++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
@@ -112,8 +112,8 @@ class DescriptorDocumentationParser
val parseResult = JavadocParser(refGraph).parseDocumentation(psi as PsiNamedElement)
return parseResult.content to { node ->
parseResult.deprecatedContent?.let {
- val deprecationNode = DocumentationNode("", it, DocumentationNode.Kind.Modifier)
- node.append(deprecationNode, DocumentationReference.Kind.Deprecation)
+ val deprecationNode = DocumentationNode("", it, NodeKind.Modifier)
+ node.append(deprecationNode, RefKind.Deprecation)
}
}
}
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index d6db3d59..5deb6177 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -3,7 +3,6 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiJavaFile
-import org.jetbrains.dokka.DocumentationNode.Kind
import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
@@ -70,11 +69,11 @@ class DocumentationBuilder
KtTokens.OPEN_KEYWORD, KtTokens.FINAL_KEYWORD, KtTokens.ABSTRACT_KEYWORD, KtTokens.SEALED_KEYWORD,
KtTokens.OVERRIDE_KEYWORD)
- fun link(node: DocumentationNode, descriptor: DeclarationDescriptor, kind: DocumentationReference.Kind) {
+ fun link(node: DocumentationNode, descriptor: DeclarationDescriptor, kind: RefKind) {
refGraph.link(node, descriptor.signature(), kind)
}
- fun link(fromDescriptor: DeclarationDescriptor?, toDescriptor: DeclarationDescriptor?, kind: DocumentationReference.Kind) {
+ fun link(fromDescriptor: DeclarationDescriptor?, toDescriptor: DeclarationDescriptor?, kind: RefKind) {
if (fromDescriptor != null && toDescriptor != null) {
refGraph.link(fromDescriptor.signature(), toDescriptor.signature(), kind)
}
@@ -84,8 +83,8 @@ class DocumentationBuilder
refGraph.register(descriptor.signature(), node)
}
- fun <T> nodeForDescriptor(descriptor: T, kind: Kind): DocumentationNode where T : DeclarationDescriptor, T : Named {
- val (doc, callback) = descriptorDocumentationParser.parseDocumentationAndDetails(descriptor, kind == Kind.Parameter)
+ fun <T> nodeForDescriptor(descriptor: T, kind: NodeKind): DocumentationNode where T : DeclarationDescriptor, T : Named {
+ val (doc, callback) = descriptorDocumentationParser.parseDocumentationAndDetails(descriptor, kind == NodeKind.Parameter)
val node = DocumentationNode(descriptor.name.asString(), doc, kind).withModifiers(descriptor)
callback(node)
return node
@@ -110,22 +109,22 @@ class DocumentationBuilder
}
}
val modifier = modality.name.toLowerCase()
- appendTextNode(modifier, DocumentationNode.Kind.Modifier)
+ appendTextNode(modifier, NodeKind.Modifier)
}
fun DocumentationNode.appendVisibility(descriptor: DeclarationDescriptorWithVisibility) {
val modifier = descriptor.visibility.normalize().displayName
- appendTextNode(modifier, DocumentationNode.Kind.Modifier)
+ appendTextNode(modifier, NodeKind.Modifier)
}
fun DocumentationNode.appendSupertypes(descriptor: ClassDescriptor) {
val superTypes = descriptor.typeConstructor.supertypes
for (superType in superTypes) {
if (!ignoreSupertype(superType)) {
- appendType(superType, DocumentationNode.Kind.Supertype)
+ appendType(superType, NodeKind.Supertype)
val superclass = superType?.constructor?.declarationDescriptor
- link(superclass, descriptor, DocumentationReference.Kind.Inheritor)
- link(descriptor, superclass, DocumentationReference.Kind.Superclass)
+ link(superclass, descriptor, RefKind.Inheritor)
+ link(descriptor, superclass, RefKind.Superclass)
}
}
}
@@ -139,16 +138,16 @@ class DocumentationBuilder
return false
}
- fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) {
+ fun DocumentationNode.appendProjection(projection: TypeProjection, kind: NodeKind = NodeKind.Type) {
if (projection.isStarProjection) {
- appendTextNode("*", Kind.Type)
+ appendTextNode("*", NodeKind.Type)
}
else {
appendType(projection.type, kind, projection.projectionKind.label)
}
}
- fun DocumentationNode.appendType(kotlinType: KotlinType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") {
+ fun DocumentationNode.appendType(kotlinType: KotlinType?, kind: NodeKind = NodeKind.Type, prefix: String = "") {
if (kotlinType == null)
return
val classifierDescriptor = kotlinType.constructor.declarationDescriptor
@@ -167,17 +166,17 @@ class DocumentationBuilder
}
val node = DocumentationNode(name, Content.Empty, kind)
if (prefix != "") {
- node.appendTextNode(prefix, Kind.Modifier)
+ node.appendTextNode(prefix, NodeKind.Modifier)
}
if (kotlinType.isMarkedNullable) {
- node.appendTextNode("?", Kind.NullabilityModifier)
+ node.appendTextNode("?", NodeKind.NullabilityModifier)
}
if (classifierDescriptor != null) {
link(node, classifierDescriptor,
- if (classifierDescriptor.isBoringBuiltinClass()) DocumentationReference.Kind.HiddenLink else DocumentationReference.Kind.Link)
+ if (classifierDescriptor.isBoringBuiltinClass()) RefKind.HiddenLink else RefKind.Link)
}
- append(node, DocumentationReference.Kind.Detail)
+ append(node, RefKind.Detail)
node.appendAnnotations(kotlinType)
for (typeArgument in kotlinType.arguments) {
node.appendProjection(typeArgument)
@@ -192,7 +191,7 @@ class DocumentationBuilder
val annotationNode = it.build()
if (annotationNode != null) {
append(annotationNode,
- if (annotationNode.isDeprecation()) DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation)
+ if (annotationNode.isDeprecation()) RefKind.Deprecation else RefKind.Annotation)
}
}
}
@@ -201,7 +200,7 @@ class DocumentationBuilder
val psi = (descriptor as DeclarationDescriptorWithSource).source.getPsi() as? KtModifierListOwner ?: return
KtTokens.MODIFIER_KEYWORDS_ARRAY.filter { it !in knownModifiers }.forEach {
if (psi.hasModifier(it)) {
- appendTextNode(it.value, Kind.Modifier)
+ appendTextNode(it.value, NodeKind.Modifier)
}
}
}
@@ -212,7 +211,7 @@ class DocumentationBuilder
appendSourceLink(sourceElement.getPsi(), options.sourceLinks)
}
- fun DocumentationNode.appendChild(descriptor: DeclarationDescriptor, kind: DocumentationReference.Kind): DocumentationNode? {
+ fun DocumentationNode.appendChild(descriptor: DeclarationDescriptor, kind: RefKind): DocumentationNode? {
// do not include generated code
if (descriptor is CallableMemberDescriptor && descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION)
return null
@@ -238,22 +237,22 @@ class DocumentationBuilder
if (descriptor is CallableMemberDescriptor && descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
val baseDescriptor = descriptor.overriddenDescriptors.firstOrNull()
if (baseDescriptor != null) {
- link(this, baseDescriptor, DocumentationReference.Kind.InheritedMember)
+ link(this, baseDescriptor, RefKind.InheritedMember)
}
null
}
else {
val descriptorToUse = if (descriptor is ConstructorDescriptor) descriptor else descriptor.original
- appendChild(descriptorToUse, DocumentationReference.Kind.Member)
+ appendChild(descriptorToUse, RefKind.Member)
}
}
return nodes.filterNotNull()
}
- fun DocumentationNode.appendInPageChildren(descriptors: Iterable<DeclarationDescriptor>, kind: DocumentationReference.Kind) {
+ fun DocumentationNode.appendInPageChildren(descriptors: Iterable<DeclarationDescriptor>, kind: RefKind) {
descriptors.forEach { descriptor ->
val node = appendChild(descriptor, kind)
- node?.addReferenceTo(this, DocumentationReference.Kind.TopLevelPage)
+ node?.addReferenceTo(this, RefKind.TopLevelPage)
}
}
@@ -285,17 +284,17 @@ class DocumentationBuilder
fun ClassDescriptor.build(): DocumentationNode {
val kind = when (kind) {
- ClassKind.OBJECT -> Kind.Object
- ClassKind.INTERFACE -> Kind.Interface
- ClassKind.ENUM_CLASS -> Kind.Enum
- ClassKind.ANNOTATION_CLASS -> Kind.AnnotationClass
- ClassKind.ENUM_ENTRY -> Kind.EnumItem
- else -> Kind.Class
+ ClassKind.OBJECT -> NodeKind.Object
+ ClassKind.INTERFACE -> NodeKind.Interface
+ ClassKind.ENUM_CLASS -> NodeKind.Enum
+ ClassKind.ANNOTATION_CLASS -> NodeKind.AnnotationClass
+ ClassKind.ENUM_ENTRY -> NodeKind.EnumItem
+ else -> NodeKind.Class
}
val node = nodeForDescriptor(this, kind)
node.appendSupertypes(this)
if (getKind() != ClassKind.OBJECT && getKind() != ClassKind.ENUM_ENTRY) {
- node.appendInPageChildren(typeConstructor.parameters, DocumentationReference.Kind.Detail)
+ node.appendInPageChildren(typeConstructor.parameters, RefKind.Detail)
val constructorsToDocument = if (getKind() == ClassKind.ENUM_CLASS)
constructors.filter { it.valueParameters.size > 0 }
else
@@ -305,7 +304,7 @@ class DocumentationBuilder
val members = defaultType.memberScope.getContributedDescriptors().filter { it != companionObjectDescriptor }
node.appendMembers(members)
node.appendMembers(staticScope.getContributedDescriptors()).forEach {
- it.appendTextNode("static", Kind.Modifier)
+ it.appendTextNode("static", NodeKind.Modifier)
}
val companionObjectDescriptor = companionObjectDescriptor
if (companionObjectDescriptor != null) {
@@ -319,8 +318,8 @@ class DocumentationBuilder
}
fun ConstructorDescriptor.build(): DocumentationNode {
- val node = nodeForDescriptor(this, Kind.Constructor)
- node.appendInPageChildren(valueParameters, DocumentationReference.Kind.Detail)
+ val node = nodeForDescriptor(this, NodeKind.Constructor)
+ node.appendInPageChildren(valueParameters, RefKind.Detail)
register(this, node)
return node
}
@@ -339,11 +338,11 @@ class DocumentationBuilder
logger.warn("Found an unresolved type in ${signatureWithSourceLocation()}")
}
- val node = nodeForDescriptor(this, if (inCompanionObject()) Kind.CompanionObjectFunction else Kind.Function)
+ val node = nodeForDescriptor(this, if (inCompanionObject()) NodeKind.CompanionObjectFunction else NodeKind.Function)
- node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail)
- extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) }
- node.appendInPageChildren(valueParameters, DocumentationReference.Kind.Detail)
+ node.appendInPageChildren(typeParameters, RefKind.Detail)
+ extensionReceiverParameter?.let { node.appendChild(it, RefKind.Detail) }
+ node.appendInPageChildren(valueParameters, RefKind.Detail)
node.appendType(returnType)
node.appendAnnotations(this)
node.appendModifiers(this)
@@ -360,7 +359,7 @@ class DocumentationBuilder
fun addOverrideLink(baseClassFunction: CallableMemberDescriptor, overridingFunction: CallableMemberDescriptor) {
val source = baseClassFunction.original.source.getPsi()
if (source != null) {
- link(overridingFunction, baseClassFunction, DocumentationReference.Kind.Override)
+ link(overridingFunction, baseClassFunction, RefKind.Override)
} else {
baseClassFunction.overriddenDescriptors.forEach {
addOverrideLink(it, overridingFunction)
@@ -369,15 +368,15 @@ class DocumentationBuilder
}
fun PropertyDescriptor.build(): DocumentationNode {
- val node = nodeForDescriptor(this, if (inCompanionObject()) Kind.CompanionObjectProperty else Kind.Property)
- node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail)
- extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) }
+ val node = nodeForDescriptor(this, if (inCompanionObject()) NodeKind.CompanionObjectProperty else NodeKind.Property)
+ node.appendInPageChildren(typeParameters, RefKind.Detail)
+ extensionReceiverParameter?.let { node.appendChild(it, RefKind.Detail) }
node.appendType(returnType)
node.appendAnnotations(this)
node.appendModifiers(this)
node.appendSourceLink(source)
if (isVar) {
- node.appendTextNode("var", DocumentationNode.Kind.Modifier)
+ node.appendTextNode("var", NodeKind.Modifier)
}
getter?.let {
if (!it.isDefault) {
@@ -413,21 +412,21 @@ class DocumentationBuilder
}
fun ValueParameterDescriptor.build(): DocumentationNode {
- val node = nodeForDescriptor(this, Kind.Parameter)
+ val node = nodeForDescriptor(this, NodeKind.Parameter)
node.appendType(varargElementType ?: type)
if (declaresDefaultValue()) {
val psi = source.getPsi() as? KtParameter
if (psi != null) {
val defaultValueText = psi.defaultValue?.text
if (defaultValueText != null) {
- node.appendTextNode(defaultValueText, Kind.Value)
+ node.appendTextNode(defaultValueText, NodeKind.Value)
}
}
}
node.appendAnnotations(this)
node.appendModifiers(this)
- if (varargElementType != null && node.details(Kind