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.Modifier).none { it.name == "vararg" }) {
- node.appendTextNode("vararg", Kind.Modifier)
+ if (varargElementType != null && node.details(NodeKind.Modifier).none { it.name == "vararg" }) {
+ node.appendTextNode("vararg", NodeKind.Modifier)
}
register(this, node)
return node
@@ -438,25 +437,25 @@ class DocumentationBuilder
val name = name.asString()
val prefix = variance.label
- val node = DocumentationNode(name, doc, DocumentationNode.Kind.TypeParameter)
+ val node = DocumentationNode(name, doc, NodeKind.TypeParameter)
if (prefix != "") {
- node.appendTextNode(prefix, Kind.Modifier)
+ node.appendTextNode(prefix, NodeKind.Modifier)
}
if (isReified) {
- node.appendTextNode("reified", Kind.Modifier)
+ node.appendTextNode("reified", NodeKind.Modifier)
}
for (constraint in upperBounds) {
if (KotlinBuiltIns.isDefaultBound(constraint)) {
continue
}
- node.appendType(constraint, Kind.UpperBound)
+ node.appendType(constraint, NodeKind.UpperBound)
}
for (constraint in lowerBounds) {
if (KotlinBuiltIns.isNothing(constraint))
continue
- node.appendType(constraint, Kind.LowerBound)
+ node.appendType(constraint, NodeKind.LowerBound)
}
return node
}
@@ -468,9 +467,9 @@ class DocumentationBuilder
}
link(receiverClass,
containingDeclaration,
- DocumentationReference.Kind.Extension)
+ RefKind.Extension)
- val node = DocumentationNode(name.asString(), Content.Empty, Kind.Receiver)
+ val node = DocumentationNode(name.asString(), Content.Empty, NodeKind.Receiver)
node.appendType(type)
return node
}
@@ -480,14 +479,14 @@ class DocumentationBuilder
if (annotationClass == null || ErrorUtils.isError(annotationClass)) {
return null
}
- val node = DocumentationNode(annotationClass.name.asString(), Content.Empty, DocumentationNode.Kind.Annotation)
+ val node = DocumentationNode(annotationClass.name.asString(), Content.Empty, NodeKind.Annotation)
val arguments = allValueArguments.toList().sortedBy { it.first.index }
arguments.forEach {
val valueNode = it.second.toDocumentationNode()
if (valueNode != null) {
- val paramNode = DocumentationNode(it.first.name.asString(), Content.Empty, DocumentationNode.Kind.Parameter)
- paramNode.append(valueNode, DocumentationReference.Kind.Detail)
- node.append(paramNode, DocumentationReference.Kind.Detail)
+ val paramNode = DocumentationNode(it.first.name.asString(), Content.Empty, NodeKind.Parameter)
+ paramNode.append(valueNode, RefKind.Detail)
+ node.append(paramNode, RefKind.Detail)
}
}
return node
@@ -506,7 +505,7 @@ class DocumentationBuilder
value.containingDeclaration.name.asString() + "." + value.name.asString()
else -> value.toString()
}.let { valueString ->
- DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value)
+ DocumentationNode(valueString, Content.Empty, NodeKind.Value)
}
}
}
@@ -521,7 +520,7 @@ class KotlinPackageDocumentationBuilder : PackageDocumentationBuilder {
with(documentationBuilder) {
if (descriptor.isDocumented()) {
val parent = packageNode.getParentForPackageMember(descriptor, externalClassNodes)
- parent.appendChild(descriptor, DocumentationReference.Kind.Member)
+ parent.appendChild(descriptor, RefKind.Member)
}
}
}
@@ -545,7 +544,7 @@ class KotlinJavaDocumentationBuilder
}
else {
with(documentationBuilder) {
- packageNode.appendChild(descriptor, DocumentationReference.Kind.Member)
+ packageNode.appendChild(descriptor, RefKind.Member)
}
}
}
@@ -580,8 +579,8 @@ fun DocumentationNode.getParentForPackageMember(descriptor: DeclarationDescripto
!ErrorUtils.isError(extensionClassDescriptor)) {
val fqName = DescriptorUtils.getFqNameSafe(extensionClassDescriptor)
return externalClassNodes.getOrPut(fqName, {
- val newNode = DocumentationNode(fqName.asString(), Content.Empty, Kind.ExternalClass)
- append(newNode, DocumentationReference.Kind.Member)
+ val newNode = DocumentationNode(fqName.asString(), Content.Empty, NodeKind.ExternalClass)
+ append(newNode, RefKind.Member)
newNode
})
}
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index c0c101bf..80f91646 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -11,22 +11,22 @@ class KotlinLanguageService : LanguageService {
override fun render(node: DocumentationNode, renderMode: RenderMode): ContentNode {
return content {
when (node.kind) {
- DocumentationNode.Kind.Package -> if (renderMode == RenderMode.FULL) renderPackage(node)
- in DocumentationNode.Kind.classLike -> renderClass(node, renderMode)
-
- DocumentationNode.Kind.EnumItem,
- DocumentationNode.Kind.ExternalClass -> if (renderMode == RenderMode.FULL) identifier(node.name)
-
- DocumentationNode.Kind.TypeParameter -> renderTypeParameter(node, renderMode)
- DocumentationNode.Kind.Type,
- DocumentationNode.Kind.UpperBound -> renderType(node, renderMode)
-
- DocumentationNode.Kind.Modifier -> renderModifier(node)
- DocumentationNode.Kind.Constructor,
- DocumentationNode.Kind.Function,
- DocumentationNode.Kind.CompanionObjectFunction -> renderFunction(node, renderMode)
- DocumentationNode.Kind.Property,
- DocumentationNode.Kind.CompanionObjectProperty -> renderProperty(node, renderMode)
+ NodeKind.Package -> if (renderMode == RenderMode.FULL) renderPackage(node)
+ in NodeKind.classLike -> renderClass(node, renderMode)
+
+ NodeKind.EnumItem,
+ NodeKind.ExternalClass -> if (renderMode == RenderMode.FULL) identifier(node.name)
+
+ NodeKind.TypeParameter -> renderTypeParameter(node, renderMode)
+ NodeKind.Type,
+ NodeKind.UpperBound -> renderType(node, renderMode)
+
+ NodeKind.Modifier -> renderModifier(node)
+ NodeKind.Constructor,
+ NodeKind.Function,
+ NodeKind.CompanionObjectFunction -> renderFunction(node, renderMode)
+ NodeKind.Property,
+ NodeKind.CompanionObjectProperty -> renderProperty(node, renderMode)
else -> identifier(node.name)
}
}
@@ -34,7 +34,7 @@ class KotlinLanguageService : LanguageService {
override fun renderName(node: DocumentationNode): String {
return when (node.kind) {
- DocumentationNode.Kind.Constructor -> node.owner!!.name
+ NodeKind.Constructor -> node.owner!!.name
else -> node.name
}
}
@@ -42,10 +42,10 @@ class KotlinLanguageService : LanguageService {
override fun summarizeSignatures(nodes: List<DocumentationNode>): ContentNode? {
if (nodes.size < 2) return null
val receiverKind = nodes.getReceiverKind() ?: return null
- val functionWithTypeParameter = nodes.firstOrNull { it.details(DocumentationNode.Kind.TypeParameter).any() } ?: return null
+ val functionWithTypeParameter = nodes.firstOrNull { it.details(NodeKind.TypeParameter).any() } ?: return null
return content {
- val typeParameter = functionWithTypeParameter.details(DocumentationNode.Kind.TypeParameter).first()
- if (functionWithTypeParameter.kind == DocumentationNode.Kind.Function) {
+ val typeParameter = functionWithTypeParameter.details(NodeKind.TypeParameter).first()
+ if (functionWithTypeParameter.kind == NodeKind.Function) {
renderFunction(functionWithTypeParameter, RenderMode.SUMMARY, SummarizingMapper(receiverKind, typeParameter.name))
}
else {
@@ -63,9 +63,9 @@ class KotlinLanguageService : LanguageService {
}
private fun DocumentationNode.getReceiverQName(): String? {
- if (kind != DocumentationNode.Kind.Function && kind != DocumentationNode.Kind.Property) return null
- val receiver = details(DocumentationNode.Kind.Receiver).singleOrNull() ?: return null
- return receiver.detail(DocumentationNode.Kind.Type).qualifiedNameFromType()
+ if (kind != NodeKind.Function && kind != NodeKind.Property) return null
+ val receiver = details(NodeKind.Receiver).singleOrNull() ?: return null
+ return receiver.detail(NodeKind.Type).qualifiedNameFromType()
}
companion object {
@@ -142,7 +142,7 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) {
- var typeArguments = node.details(DocumentationNode.Kind.Type)
+ var typeArguments = node.details(NodeKind.Type)
if (node.name == "Function${typeArguments.count() - 1}") {
// lambda
val isExtension = node.annotations.any { it.name == "ExtensionFunctionType" }
@@ -174,7 +174,7 @@ class KotlinLanguageService : LanguageService {
}
symbol(">")
}
- val nullabilityModifier = node.details(DocumentationNode.Kind.NullabilityModifier).singleOrNull()
+ val nullabilityModifier = node.details(NodeKind.NullabilityModifier).singleOrNull()
if (nullabilityModifier != null) {
symbol(nullabilityModifier.name)
}
@@ -200,7 +200,7 @@ class KotlinLanguageService : LanguageService {
identifier(node.name)
- val constraints = node.details(DocumentationNode.Kind.UpperBound)
+ val constraints = node.details(NodeKind.UpperBound)
if (constraints.any()) {
nbsp()
symbol(":")
@@ -218,9 +218,9 @@ class KotlinLanguageService : LanguageService {
identifier(node.name, IdentifierKind.ParameterName)
symbol(":")
nbsp()
- val parameterType = node.detail(DocumentationNode.Kind.Type)
+ val parameterType = node.detail(NodeKind.Type)
renderType(parameterType, renderMode)
- val valueNode = node.details(DocumentationNode.Kind.Value).firstOrNull()
+ val valueNode = node.details(NodeKind.Value).firstOrNull()
if (valueNode != null) {
nbsp()
symbol("=")
@@ -230,7 +230,7 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderTypeParametersForNode(node: DocumentationNode, renderMode: RenderMode) {
- val typeParameters = node.details(DocumentationNode.Kind.TypeParameter)
+ val typeParameters = node.details(NodeKind.TypeParameter)
if (typeParameters.any()) {
symbol("<")
renderList(typeParameters) {
@@ -241,7 +241,7 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderSupertypesForNode(node: DocumentationNode, renderMode: RenderMode) {
- val supertypes = node.details(DocumentationNode.Kind.Supertype)
+ val supertypes = node.details(NodeKind.Supertype)
if (supertypes.any()) {
nbsp()
symbol(":")
@@ -256,9 +256,9 @@ class KotlinLanguageService : LanguageService {
private fun ContentBlock.renderModifiersForNode(node: DocumentationNode,
renderMode: RenderMode,
nowrap: Boolean = false) {
- val modifiers = node.details(DocumentationNode.Kind.Modifier)
+ val modifiers = node.details(NodeKind.Modifier)
for (it in modifiers) {
- if (node.kind == org.jetbrains.dokka.DocumentationNode.Kind.Interface && it.name == "abstract")
+ if (node.kind == org.jetbrains.dokka.NodeKind.Interface && it.name == "abstract")
continue
if (renderMode == RenderMode.SUMMARY && it.name in fullOnlyModifiers) {
continue
@@ -275,11 +275,11 @@ class KotlinLanguageService : LanguageService {
private fun ContentBlock.renderAnnotation(node: DocumentationNode) {
identifier("@" + node.name, IdentifierKind.AnnotationName)
- val parameters = node.details(DocumentationNode.Kind.Parameter)
+ val parameters = node.details(NodeKind.Parameter)
if (!parameters.isEmpty()) {
symbol("(")
renderList(parameters) {
- text(it.detail(DocumentationNode.Kind.Value).name)
+ text(it.detail(NodeKind.Value).name)
}
symbol(")")
}
@@ -292,12 +292,12 @@ class KotlinLanguageService : LanguageService {
}
renderModifiersForNode(node, renderMode)
when (node.kind) {
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.AnnotationClass,
- DocumentationNode.Kind.Enum -> keyword("class ")
- DocumentationNode.Kind.Interface -> keyword("interface ")
- DocumentationNode.Kind.EnumItem -> keyword("enum val ")
- DocumentationNode.Kind.Object -> keyword("object ")
+ NodeKind.Class,
+ NodeKind.AnnotationClass,
+ NodeKind.Enum -> keyword("class ")
+ NodeKind.Interface -> keyword("interface ")
+ NodeKind.EnumItem -> keyword("enum val ")
+ NodeKind.Object -> keyword("object ")
else -> throw IllegalArgumentException("Node $node is not a class-like object")
}
@@ -314,23 +314,23 @@ class KotlinLanguageService : LanguageService {
}
renderModifiersForNode(node, renderMode)
when (node.kind) {
- DocumentationNode.Kind.Constructor -> identifier(node.owner!!.name)
- DocumentationNode.Kind.Function,
- DocumentationNode.Kind.CompanionObjectFunction -> keyword("fun ")
+ NodeKind.Constructor -> identifier(node.owner!!.name)
+ NodeKind.Function,
+ NodeKind.CompanionObjectFunction -> keyword("fun ")
else -> throw IllegalArgumentException("Node $node is not a function-like object")
}
renderTypeParametersForNode(node, renderMode)
- if (node.details(DocumentationNode.Kind.TypeParameter).any()) {
+ if (node.details(NodeKind.TypeParameter).any()) {
text(" ")
}
renderReceiver(node, renderMode, signatureMapper)
- if (node.kind != org.jetbrains.dokka.DocumentationNode.Kind.Constructor)
+ if (node.kind != org.jetbrains.dokka.NodeKind.Constructor)
identifierOrDeprecated(node)
symbol("(")
- val parameters = node.details(DocumentationNode.Kind.Parameter)
+ val parameters = node.details(NodeKind.Parameter)
renderList(parameters) {
indentedSoftLineBreak()
renderParameter(it, renderMode)
@@ -341,7 +341,7 @@ class KotlinLanguageService : LanguageService {
}
symbol(")")
symbol(": ")
- renderType(node.detail(DocumentationNode.Kind.Type), renderMode)
+ renderType(node.detail(NodeKind.Type), renderMode)
}
else {
symbol(")")
@@ -349,24 +349,24 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderReceiver(node: DocumentationNode, renderMode: RenderMode, signatureMapper: SignatureMapper?) {
- val receiver = node.details(DocumentationNode.Kind.Receiver).singleOrNull()
+ val receiver = node.details(NodeKind.Receiver).singleOrNull()
if (receiver != null) {
if (signatureMapper != null) {
signatureMapper.renderReceiver(receiver, this)
} else {
- renderType(receiver.detail(DocumentationNode.Kind.Type), renderMode)
+ renderType(receiver.detail(NodeKind.Type), renderMode)
}
symbol(".")
}
}
private fun needReturnType(node: DocumentationNode) = when(node.kind) {
- DocumentationNode.Kind.Constructor -> false
+ NodeKind.Constructor -> false
else -> !node.isUnitReturnType()
}
fun DocumentationNode.isUnitReturnType(): Boolean =
- detail(DocumentationNode.Kind.Type).hiddenLinks.firstOrNull()?.qualifiedName() == "kotlin.Unit"
+ detail(NodeKind.Type).hiddenLinks.firstOrNull()?.qualifiedName() == "kotlin.Unit"
private fun ContentBlock.renderProperty(node: DocumentationNode,
renderMode: RenderMode,
@@ -376,12 +376,12 @@ class KotlinLanguageService : LanguageService {
}
renderModifiersForNode(node, renderMode)
when (node.kind) {
- DocumentationNode.Kind.Property,
- DocumentationNode.Kind.CompanionObjectProperty -> keyword("${node.getPropertyKeyword()} ")
+ NodeKind.Property,
+ NodeKind.CompanionObjectProperty -> keyword("${node.getPropertyKeyword()} ")
else -> throw IllegalArgumentException("Node $node is not a property")
}
renderTypeParametersForNode(node, renderMode)
- if (node.details(DocumentationNode.Kind.TypeParameter).any()) {
+ if (node.details(NodeKind.TypeParameter).any()) {
text(" ")
}
@@ -389,11 +389,11 @@ class KotlinLanguageService : LanguageService {
identifierOrDeprecated(node)
symbol(": ")
- renderType(node.detail(DocumentationNode.Kind.Type), renderMode)
+ renderType(node.detail(NodeKind.Type), renderMode)
}
fun DocumentationNode.getPropertyKeyword() =
- if (details(DocumentationNode.Kind.Modifier).any { it.name == "var" }) "var" else "val"
+ if (details(NodeKind.Modifier).any { it.name == "var" }) "var" else "val"
fun ContentBlock.identifierOrDeprecated(node: DocumentationNode) {
if (node.deprecation != null) {
diff --git a/core/src/main/kotlin/Languages/JavaLanguageService.kt b/core/src/main/kotlin/Languages/JavaLanguageService.kt
index 8be9f13e..d6f9ade5 100644
--- a/core/src/main/kotlin/Languages/JavaLanguageService.kt
+++ b/core/src/main/kotlin/Languages/JavaLanguageService.kt
@@ -1,6 +1,5 @@
package org.jetbrains.dokka
-import org.jetbrains.dokka.DocumentationNode.Kind
import org.jetbrains.dokka.LanguageService.RenderMode
/**
@@ -9,23 +8,23 @@ import org.jetbrains.dokka.LanguageService.RenderMode
class JavaLanguageService : LanguageService {
override fun render(node: DocumentationNode, renderMode: RenderMode): ContentNode {
return ContentText(when (node.kind) {
- Kind.Package -> renderPackage(node)
- in Kind.classLike -> renderClass(node)
+ NodeKind.Package -> renderPackage(node)
+ in NodeKind.classLike -> renderClass(node)
- Kind.TypeParameter -> renderTypeParameter(node)
- Kind.Type,
- Kind.UpperBound -> renderType(node)
+ NodeKind.TypeParameter -> renderTypeParameter(node)
+ NodeKind.Type,
+ NodeKind.UpperBound -> renderType(node)
- Kind.Constructor,
- Kind.Function -> renderFunction(node)
- Kind.Property -> renderProperty(node)
+ NodeKind.Constructor,
+ NodeKind.Function -> renderFunction(node)
+ NodeKind.Property -> renderProperty(node)
else -> "${node.kind}: ${node.name}"
})
}
override fun renderName(node: DocumentationNode): String {
return when (node.kind) {
- Kind.Constructor -> node.owner!!.name
+ NodeKind.Constructor -> node.owner!!.name
else -> node.name
}
}
@@ -45,13 +44,13 @@ class JavaLanguageService : LanguageService {
}
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)
+ "Array" -> node.details(NodeKind.Type).singleOrNull()?.let { et -> getArrayElementType(et) ?: et } ?: DocumentationNode("Object", node.content, NodeKind.ExternalClass)
+ "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> DocumentationNode(node.name.removeSuffix("Array").toLowerCase(), node.content, NodeKind.Type)
else -> null
}
fun getArrayDimension(node: DocumentationNode): Int = when (node.name) {
- "Array" -> 1 + (node.details(DocumentationNode.Kind.Type).singleOrNull()?.let { getArrayDimension(it) } ?: 0)
+ "Array" -> 1 + (node.details(NodeKind.Type).singleOrNull()?.let { getArrayDimension(it) } ?: 0)
"IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> 1
else -> 0
}
@@ -71,7 +70,7 @@ class JavaLanguageService : LanguageService {
}
private fun renderTypeParameter(node: DocumentationNode): String {
- val constraints = node.details(Kind.UpperBound)
+ val constraints = node.details(NodeKind.UpperBound)
return if (constraints.none())
node.name
else {
@@ -80,12 +79,12 @@ class JavaLanguageService : LanguageService {
}
private fun renderParameter(node: DocumentationNode): String {
- return "${renderType(node.detail(Kind.Type))} ${node.name}"
+ return "${renderType(node.detail(NodeKind.Type))} ${node.name}"
}
private fun renderTypeParametersForNode(node: DocumentationNode): String {
return StringBuilder().apply {
- val typeParameters = node.details(Kind.TypeParameter)
+ val typeParameters = node.details(NodeKind.TypeParameter)
if (typeParameters.any()) {
append("<")
append(typeParameters.map { renderTypeParameter(it) }.joinToString())
@@ -95,7 +94,7 @@ class JavaLanguageService : LanguageService {
}
private fun renderModifiersForNode(node: DocumentationNode): String {
- val modifiers = node.details(Kind.Modifier).map { renderModifier(it) }.filter { it != "" }
+ val modifiers = node.details(NodeKind.Modifier).map { renderModifier(it) }.filter { it != "" }
if (modifiers.none())
return ""
return modifiers.joinToString(" ", postfix = " ")
@@ -104,11 +103,11 @@ class JavaLanguageService : LanguageService {
private fun renderClass(node: DocumentationNode): String {
return StringBuilder().apply {
when (node.kind) {
- Kind.Class -> append("class ")
- Kind.Interface -> append("interface ")
- Kind.Enum -> append("enum ")
- Kind.EnumItem -> append("enum value ")
- Kind.Object -> append("class ")
+ NodeKind.Class -> append("class ")
+ NodeKind.Interface -> append("interface ")
+ NodeKind.Enum -> append("enum ")
+ NodeKind.EnumItem -> append("enum value ")
+ NodeKind.Object -> append("class ")
else -> throw IllegalArgumentException("Node $node is not a class-like object")
}
@@ -120,22 +119,22 @@ class JavaLanguageService : LanguageService {
private fun renderFunction(node: DocumentationNode): String {
return StringBuilder().apply {
when (node.kind) {
- Kind.Constructor -> append(node.owner?.name)
- Kind.Function -> {
+ NodeKind.Constructor -> append(node.owner?.name)
+ NodeKind.Function -> {
append(renderTypeParametersForNode(node))
- append(renderType(node.detail(Kind.Type)))
+ append(renderType(node.detail(NodeKind.Type)))
append(" ")
append(node.name)
}
else -> throw IllegalArgumentException("Node $node is not a function-like object")
}
- val receiver = node.details(Kind.Receiver).singleOrNull()
+ val receiver = node.details(NodeKind.Receiver).singleOrNull()
append("(")
if (receiver != null)
- (listOf(receiver) + node.details(Kind.Parameter)).map { renderParameter(it) }.joinTo(this)
+ (listOf(receiver) + node.details(NodeKind.Parameter)).map { renderParameter(it) }.joinTo(this)
else
- node.details(Kind.Parameter).map { renderParameter(it) }.joinTo(this)
+ node.details(NodeKind.Parameter).map { renderParameter(it) }.joinTo(this)
append(")")
}.toString()
@@ -144,19 +143,19 @@ class JavaLanguageService : LanguageService {
private fun renderProperty(node: DocumentationNode): String {
return StringBuilder().apply {
when (node.kind) {
- Kind.Property -> append("val ")
+ NodeKind.Property -> append("val ")
else -> throw IllegalArgumentException("Node $node is not a property")
}
append(renderTypeParametersForNode(node))
- val receiver = node.details(Kind.Receiver).singleOrNull()
+ val receiver = node.details(NodeKind.Receiver).singleOrNull()
if (receiver != null) {
- append(renderType(receiver.detail(Kind.Type)))
+ append(renderType(receiver.detail(NodeKind.Type)))
append(".")
}
append(node.name)
append(": ")
- append(renderType(node.detail(Kind.Type)))
+ append(renderType(node.detail(NodeKind.Type)))
}.toString()
}
} \ No newline at end of file
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 35933aee..ba3edc24 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -2,9 +2,61 @@ package org.jetbrains.dokka
import java.util.*
+enum class NodeKind {
+ Unknown,
+
+ Package,
+ Class,
+ Interface,
+ Enum,
+ AnnotationClass,
+ EnumItem,
+ Object,
+
+ Constructor,
+ Function,
+ Property,
+ Field,
+
+ CompanionObjectProperty,
+ CompanionObjectFunction,
+
+ Parameter,
+ Receiver,
+ TypeParameter,
+ Type,
+ Supertype,
+ UpperBound,
+ LowerBound,
+ Exception,
+
+ Modifier,
+ NullabilityModifier,
+
+ Module,
+
+ ExternalClass,
+ Annotation,
+
+ Value,
+
+ SourceUrl,
+ SourcePosition,
+
+ /**
+ * A note which is rendered once on a page documenting a group of overloaded functions.
+ * Needs to be generated equally on all overloads.
+ */
+ OverloadGroupNote;
+
+ companion object {
+ val classLike = setOf(Class, Interface, Enum, AnnotationClass, Object)
+ }
+}
+
open class DocumentationNode(val name: String,
content: Content,
- val kind: DocumentationNode.Kind) {
+ val kind: NodeKind) {
private val references = LinkedHashSet<DocumentationReference>()
@@ -14,30 +66,30 @@ open class DocumentationNode(val name: String,
val summary: ContentNode get() = content.summary
val owner: DocumentationNode?
- get() = references(DocumentationReference.Kind.Owner).singleOrNull()?.to
+ get() = references(RefKind.Owner).singleOrNull()?.to
val details: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Detail).map { it.to }
+ get() = references(RefKind.Detail).map { it.to }
val members: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Member).map { it.to }
+ get() = references(RefKind.Member).map { it.to }
val inheritedMembers: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.InheritedMember).map { it.to }
+ get() = references(RefKind.InheritedMember).map { it.to }
val extensions: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Extension).map { it.to }
+ get() = references(RefKind.Extension).map { it.to }
val inheritors: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Inheritor).map { it.to }
+ get() = references(RefKind.Inheritor).map { it.to }
val overrides: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Override).map { it.to }
+ get() = references(RefKind.Override).map { it.to }
val links: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Link).map { it.to }
+ get() = references(RefKind.Link).map { it.to }
val hiddenLinks: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.HiddenLink).map { it.to }
+ get() = references(RefKind.HiddenLink).map { it.to }
val annotations: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Annotation).map { it.to }
+ get() = references(RefKind.Annotation).map { it.to }
val deprecation: DocumentationNode?
- get() = references(DocumentationReference.Kind.Deprecation).singleOrNull()?.to
+ get() = references(RefKind.Deprecation).singleOrNull()?.to
// TODO: Should we allow node mutation? Model merge will copy by ref, so references are transparent, which could nice
- fun addReferenceTo(to: DocumentationNode, kind: DocumentationReference.Kind) {
+ fun addReferenceTo(to: DocumentationNode, kind: RefKind) {
references.add(DocumentationReference(this, to, kind))
}
@@ -52,77 +104,25 @@ open class DocumentationNode(val name: String,
(content as MutableContent).body()
}
- fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind }
- fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind }
- fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
- fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind }
+ fun details(kind: NodeKind): List<DocumentationNode> = details.filter { it.kind == kind }
+ fun members(kind: NodeKind): List<DocumentationNode> = members.filter { it.kind == kind }
+ fun inheritedMembers(kind: NodeKind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
+ fun links(kind: NodeKind): List<DocumentationNode> = links.filter { it.kind == kind }
- fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single()
- fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single()
- fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single()
+ fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single()
+ fun member(kind: NodeKind): DocumentationNode = members.filter { it.kind == kind }.single()
+ fun link(kind: NodeKind): DocumentationNode = links.filter { it.kind == kind }.single()
- fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind }
+ fun references(kind: RefKind): List<DocumentationReference> = references.filter { it.kind == kind }
fun allReferences(): Set<DocumentationReference> = references
override fun toString(): String {
return "$kind:$name"
}
-
- enum class Kind {
- Unknown,
-
- Package,
- Class,
- Interface,
- Enum,
- AnnotationClass,
- EnumItem,
- Object,
-
- Constructor,
- Function,
- Property,
- Field,
-
- CompanionObjectProperty,
- CompanionObjectFunction,
-
- Parameter,
- Receiver,
- TypeParameter,
- Type,
- Supertype,
- UpperBound,
- LowerBound,
- Exception,
-
- Modifier,
- NullabilityModifier,
-
- Module,
-
- ExternalClass,
- Annotation,
-
- Value,
-
- SourceUrl,
- SourcePosition,
-
- /**
- * A note which is rendered once on a page documenting a group of overloaded functions.
- * Needs to be generated equally on all overloads.
- */
- OverloadGroupNote;
-
- companion object {
- val classLike = setOf(Class, Interface, Enum, AnnotationClass, Object)
- }
- }
}
class DocumentationModule(name: String, content: Content = Content.Empty)
- : DocumentationNode(name, content, DocumentationNode.Kind.Module) {
+ : DocumentationNode(name, content, NodeKind.Module) {
}
val DocumentationNode.path: List<DocumentationNode>
@@ -132,30 +132,30 @@ val DocumentationNode.path: List<DocumentationNode>
}
fun DocumentationNode.findOrCreatePackageNode(packageName: String, packageContent: Map<String, Content>): DocumentationNode {
- val existingNode = members(DocumentationNode.Kind.Package).firstOrNull { it.name == packageName }
+ val existingNode = members(NodeKind.Package).firstOrNull { it.name == packageName }
if (existingNode != null) {
return existingNode
}
val newNode = DocumentationNode(packageName,
packageContent.getOrElse(packageName) { Content.Empty },
- DocumentationNode.Kind.Package)
- append(newNode, DocumentationReference.Kind.Member)
+ NodeKind.Package)
+ append(newNode, RefKind.Member)
return newNode
}
-fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationReference.Kind) {
+fun DocumentationNode.append(child: DocumentationNode, kind: RefKind) {
addReferenceTo(child, kind)
when (kind) {
- DocumentationReference.Kind.Detail -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
- DocumentationReference.Kind.Member -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
- DocumentationReference.Kind.Owner -> child.addReferenceTo(this, DocumentationReference.Kind.Member)
+ RefKind.Detail -> child.addReferenceTo(this, RefKind.Owner)
+ RefKind.Member -> child.addReferenceTo(this, RefKind.Owner)
+ RefKind.Owner -> child.addReferenceTo(this, RefKind.Member)
else -> { /* Do not add any links back for other types */ }
}
}
fun DocumentationNode.appendTextNode(text: String,
- kind: DocumentationNode.Kind,
- refKind: DocumentationReference.Kind = DocumentationReference.Kind.Detail) {
+ kind: NodeKind,
+ refKind: RefKind = RefKind.Detail) {
append(DocumentationNode(text, Content.Empty, kind), refKind)
}
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index 99a1f434..6db6d303 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -2,27 +2,28 @@ package org.jetbrains.dokka
import com.google.inject.Singleton
-data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReference.Kind) {
- enum class Kind {
- Owner,
- Member,
- InheritedMember,
- Detail,
- Link,
- HiddenLink,
- Extension,
- Inheritor,
- Superclass,
- Override,
- Annotation,
- Deprecation,
- TopLevelPage
- }
+enum class RefKind {
+ Owner,
+ Member,
+ InheritedMember,
+ Detail,
+ Link,
+ HiddenLink,
+ Extension,
+ Inheritor,
+ Superclass,
+ Override,
+ Annotation,
+ Deprecation,
+ TopLevelPage
+}
+
+data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: RefKind) {
}
class PendingDocumentationReference(val lazyNodeFrom: () -> DocumentationNode?,
val lazyNodeTo: () -> DocumentationNode?,
- val kind: DocumentationReference.Kind) {
+ val kind: RefKind) {
fun resolve() {
val fromNode = lazyNodeFrom()
val toNode = lazyNodeTo()
@@ -41,15 +42,15 @@ class NodeReferenceGraph() {
nodeMap.put(signature, node)
}
- fun link(fromNode: DocumentationNode, toSignature: String, kind: DocumentationReference.Kind) {
+ fun link(fromNode: DocumentationNode, toSignature: String, kind: RefKind) {
references.add(PendingDocumentationReference({ -> fromNode}, { -> nodeMap[toSignature]}, kind))
}
- fun link(fromSignature: String, toNode: DocumentationNode, kind: DocumentationReference.Kind) {
+ fun link(fromSignature: String, toNode: DocumentationNode, kind: RefKind) {
references.add(PendingDocumentationReference({ -> nodeMap[fromSignature]}, { -> toNode}, kind))
}
- fun link(fromSignature: String, toSignature: String, kind: DocumentationReference.Kind) {
+ fun link(fromSignature: String, toSignature: String, kind: RefKind) {
references.add(PendingDocumentationReference({ -> nodeMap[fromSignature]}, { -> nodeMap[toSignature]}, kind))
}
diff --git a/core/src/main/kotlin/Model/SourceLinks.kt b/core/src/main/kotlin/Model/SourceLinks.kt
index 956bfe4b..99bb8f60 100644
--- a/core/src/main/kotlin/Model/SourceLinks.kt
+++ b/core/src/main/kotlin/Model/SourceLinks.kt
@@ -1,10 +1,10 @@
package org.jetbrains.dokka
-import com.intellij.psi.PsiElement
-import java.io.File
import com.intellij.psi.PsiDocumentManager
+import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNameIdentifierOwner
import org.jetbrains.kotlin.psi.psiUtil.startOffset
+import java.io.File
class SourceLinkDefinition(val path: String, val url: String, val lineSuffix: String?)
@@ -22,12 +22,12 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<Sourc
url += linkDef.lineSuffix + line.toString()
}
}
- append(DocumentationNode(url, Content.Empty, DocumentationNode.Kind.SourceUrl),
- DocumentationReference.Kind.Detail);
+ append(DocumentationNode(url, Content.Empty, NodeKind.SourceUrl),
+ RefKind.Detail);
}
if (target != null) {
- append(DocumentationNode(target.sourcePosition(), Content.Empty, DocumentationNode.Kind.SourcePosition), DocumentationReference.Kind.Detail)
+ append(DocumentationNode(target.sourcePosition(), Content.Empty, NodeKind.SourcePosition), RefKind.Detail)
}
}
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt
index a0caca94..25733464 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -34,17 +34,17 @@ open class DocumentationNodeBareAdapter(override val node: DocumentationNode) :
override fun getRawCommentText(): String = rawCommentText_ ?: ""
override fun isError(): Boolean = false
- override fun isException(): Boolean = node.kind == DocumentationNode.Kind.Exception
- override fun isEnumConstant(): Boolean = node.kind == DocumentationNode.Kind.EnumItem
- override fun isEnum(): Boolean = node.kind == DocumentationNode.Kind.Enum
- override fun isMethod(): Boolean = node.kind == DocumentationNode.Kind.Function
- override fun isInterface(): Boolean = node.kind == DocumentationNode.Kind.Interface
- override fun isField(): Boolean = node.kind == DocumentationNode.Kind.Field
- override fun isClass(): Boolean = node.kind == DocumentationNode.Kind.Class
- override fun isAnnotationType(): Boolean = node.kind == DocumentationNode.Kind.AnnotationClass
- override fun isConstructor(): Boolean = node.kind == DocumentationNode.Kind.Constructor
- override fun isOrdinaryClass(): Boolean = node.kind == DocumentationNode.Kind.Class
- override fun isAnnotationTypeElement(): Boolean = node.kind == DocumentationNode.Kind.Annotation
+ override fun isException(): Boolean = node.kind == NodeKind.Exception
+ override fun isEnumConstant(): Boolean = node.kind == NodeKind.EnumItem
+ override fun isEnum(): Boolean = node.kind == NodeKind.Enum
+ override fun isMethod(): Boolean = node.kind == NodeKind.Function
+ override fun isInterface(): Boolean = node.kind == NodeKind.Interface
+ override fun isField(): Boolean = node.kind == NodeKind.Field
+ override fun isClass(): Boolean = node.kind == NodeKind.Class
+ override fun isAnnotationType(): Boolean = node.kind == NodeKind.AnnotationClass
+ override fun isConstructor(): Boolean = node.kind == NodeKind.Constructor
+ override fun isOrdinaryClass(): Boolean = node.kind == NodeKind.Class
+ override fun isAnnotationTypeElement(): Boolean = node.kind == NodeKind.Annotation
override fun compareTo(other: Any?): Int = when (other) {
!is DocumentationNodeAdapter -> 1
@@ -54,7 +54,7 @@ open class DocumentationNodeBareAdapter(override val node: DocumentationNode) :
override fun equals(other: Any?): Boolean = node.qualifiedName() == (other as? DocumentationNodeAdapter)?.node?.qualifiedName()
override fun hashCode(): Int = node.name.hashCode()
- override fun isIncluded(): Boolean = node.kind != DocumentationNode.Kind.ExternalClass
+ override fun isIncluded(): Boolean = node.kind != NodeKind.ExternalClass
}
@@ -89,7 +89,7 @@ private fun <T> nodeAnnotations(self: T): List<AnnotationDescAdapter> where T :
= self.node.annotations.map { AnnotationDescAdapter(self.module, it) }
private fun DocumentationNode.hasAnnotation(klass: KClass<*>) = klass.qualifiedName in annotations.map { it.qualifiedName() }
-private fun DocumentationNode.hasModifier(name: String) = details(DocumentationNode.Kind.Modifier).any { it.name == name }
+private fun DocumentationNode.hasModifier(name: String) = details(NodeKind.Modifier).any { it.name == name }
class PackageAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), PackageDoc {
@@ -99,12 +99,12 @@ class PackageAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : Docum
allClasses.get(className)?.let { ClassDocumentationNodeAdapter(module, it) }
override fun annotationTypes(): Array<out AnnotationTypeDoc> = emptyArray()
- override fun annotations(): Array<out AnnotationDesc> = node.members(DocumentationNode.Kind.AnnotationClass).map { AnnotationDescAdapter(module, it) }.toTypedArray()
- override fun exceptions(): Array<out ClassDoc> = node.members(DocumentationNode.Kind.Exception).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
- override fun ordinaryClasses(): Array<out ClassDoc> = node.members(DocumentationNode.Kind.Class).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
- override fun interfaces(): Array<out ClassDoc> = node.members(DocumentationNode.Kind.Interface).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
+ override fun annotations(): Array<out AnnotationDesc> = node.members(NodeKind.AnnotationClass).map { AnnotationDescAdapter(module, it) }.toTypedArray()
+ override fun exceptions(): Array<out ClassDoc> = node.members(NodeKind.Exception).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
+ override fun ordinaryClasses(): Array<out ClassDoc> = node.members(NodeKind.Class).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
+ override fun interfaces(): Array<out ClassDoc> = node.members(NodeKind.Interface).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
override fun errors(): Array<out ClassDoc> = emptyArray()
- override fun enums(): Array<out ClassDoc> = node.members(DocumentationNode.Kind.Enum).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
+ override fun enums(): Array<out ClassDoc> = node.members(NodeKind.Enum).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
override fun allClasses(filter: Boolean): Array<out ClassDoc> = allClasses.values.map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
override fun allClasses(): Array<out ClassDoc> = allClasses(true)
@@ -126,7 +126,7 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode)
override fun isPackagePrivate(): Boolean = false
override fun isStatic(): Boolean = node.hasModifier("static")
override fun modifierSpecifier(): Int = Modifier.PUBLIC + if (isStatic) Modifier.STATIC else 0
- override fun qualifiedName(): String? = if (node.kind == DocumentationNode.Kind.Type) node.qualifiedNameFromType() else node.qualifiedName()
+ override fun qualifiedName(): String? = if (node.kind == NodeKind.Type) node.qualifiedNameFromType() else node.qualifiedName()
override fun annotations(): Array<out AnnotationDesc>? = nodeAnnotations(this).toTypedArray()
override fun modifiers(): String? = "public ${if (isStatic) "static" else ""}".trim()
override fun isProtected(): Boolean = false
@@ -134,13 +134,13 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode)
override fun isFinal(): Boolean = node.hasModifier("final")
override fun containingPackage(): PackageDoc? {
- if (node.kind == DocumentationNode.Kind.Type) {
+ if (node.kind == NodeKind.Type) {
return null
}
var owner: DocumentationNode? = node
while (owner != null) {
- if (owner.kind == DocumentationNode.Kind.Package) {
+ if (owner.kind == NodeKind.Package) {
return PackageAdapter(module, owner)
}
owner = owner.owner
@@ -150,16 +150,16 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode)
}
override fun containingClass(): ClassDoc? {
- if (node.kind == DocumentationNode.Kind.Type) {
+ if (node.kind == NodeKind.Type) {
return null
}
var owner = node.owner
while (owner != null) {
when (owner.kind) {
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Enum -> return ClassDocumentationNodeAdapter(module, owner)
+ NodeKind.Class,
+ NodeKind.Interface,
+ NodeKind.Enum -> return ClassDocumentationNodeAdapter(module, owner)
else -> owner = owner.owner
}
}
@@ -184,9 +184,9 @@ open class TypeAdapter(override val module: ModuleNodeAdapter, override val node
override fun asClassDoc(): ClassDoc? = if (isPrimitive) null else
elementType?.asClassDoc() ?:
when (node.kind) {
- in DocumentationNode.Kind.classLike,
- DocumentationNode.Kind.ExternalClass,
- DocumentationNode.Kind.Exception -> module.classNamed(qualifiedTypeName()) ?: ClassDocumentationNodeAdapter(module, node)
+ in NodeKind.classLike,
+ NodeKind.ExternalClass,
+ NodeKind.Exception -> module.classNamed(qualifiedTypeName()) ?: ClassDocumentationNodeAdapter(module, node)
else -> when {
node.links.isNotEmpty() -> TypeAdapter(module, node.links.first()).asClassDoc()
@@ -194,12 +194,12 @@ open class TypeAdapter(override val module: ModuleNodeAdapter, override val node
}
}
- override fun asTypeVariable(): TypeVariable? = if (node.kind == DocumentationNode.Kind.TypeParameter) TypeVariableAdapter(module, node) else null
+ override fun asTypeVariable(): TypeVariable? = if (node.kind == NodeKind.TypeParameter) TypeVariableAdapter(module, node) else null
override fun asParameterizedType(): ParameterizedType? =
- if (node.details(DocumentationNode.Kind.Type).isNotEmpty()) ParameterizedTypeAdapter(module, node)
+ if (node.details(NodeKind.Type).isNotEmpty()) ParameterizedTypeAdapter(module, node)
else null // TODO it should ignore dimensions
- override fun asAnnotationTypeDoc(): AnnotationTypeDoc? = if (node.kind == DocumentationNode.Kind.AnnotationClass) AnnotationTypeDocAdapter(module, node) else null
+ override fun asAnnotationTypeDoc(): AnnotationTypeDoc? = if (node.kind == NodeKind.AnnotationClass) AnnotationTypeDocAdapter(module, node) else null
override fun asAnnotatedType(): AnnotatedType? = if (node.annotations.isNotEmpty()) AnnotatedTypeAdapter(module, node) else null
override fun getElementType(): Type? = javaLanguageService.getArrayElementType(node)?.let { et -> TypeAdapter(module, et) }
override fun asWildcardType(): WildcardType? = null
@@ -215,26 +215,26 @@ class AnnotatedTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) :
}
class WildcardTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), WildcardType {
- override fun extendsBounds(): Array<out Type> = node.details(DocumentationNode.Kind.UpperBound).map { TypeAdapter(module, it) }.toTypedArray()
- override fun superBounds(): Array<out Type> = node.details(DocumentationNode.Kind.LowerBound).map { TypeAdapter(module, it) }.toTypedArray()
+ override fun extendsBounds(): Array<out Type> = node.details(NodeKind.UpperBound).map { TypeAdapter(module, it) }.toTypedArray()
+ override fun superBounds(): Array<out Type> = node.details(NodeKind.LowerBound).map { TypeAdapter(module, it) }.toTypedArray()
}
class TypeVariableAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), TypeVariable {
override fun owner(): ProgramElementDoc = node.owner!!.let<DocumentationNode, ProgramElementDoc> { owner ->
when (owner.kind) {
- DocumentationNode.Kind.Function,
- DocumentationNode.Kind.Constructor -> ExecutableMemberAdapter(module, owner)
+ NodeKind.Function,
+ NodeKind.Constructor -> ExecutableMemberAdapter(module, owner)
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Enum -> ClassDocumentationNodeAdapter(module, owner)
+ NodeKind.Class,
+ NodeKind.Interface,
+ NodeKind.Enum -> ClassDocumentationNodeAdapter(module, owner)
else -> ProgramElementAdapter(module, node.owner!!)
}
}
- override fun bounds(): Array<out Type>? = node.details(DocumentationNode.Kind.UpperBound).map { TypeAdapter(module, it) }.toTypedArray()
- override fun annotations(): Array<out AnnotationDesc>? = node.members(DocumentationNode.Kind.Annotation).map { AnnotationDescAdapter(module, it) }.toTypedArray()
+ override fun bounds(): Array<out Type>? = node.details(NodeKind.UpperBound).map { TypeAdapter(module, it) }.toTypedArray()
+ override fun annotations(): Array<out AnnotationDesc>? = node.members(NodeKind.Annotation).map { AnnotationDescAdapter(module, it) }.toTypedArray()
override fun qualifiedTypeName(): String = node.name
override fun simpleTypeName(): String = node.name
@@ -247,32 +247,32 @@ class TypeVariableAdapter(module: ModuleNodeAdapter, node: DocumentationNode) :
}
class ParameterizedTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), ParameterizedType {
- override fun typeArguments(): Array<out Type> = node.details(DocumentationNode.Kind.Type).map { TypeVariableAdapter(module, it) }.toTypedArray()
+ override fun typeArguments(): Array<out Type> = node.details(NodeKind.Type).map { TypeVariableAdapter(module, it) }.toTypedArray()
override fun superclassType(): Type? =
node.lookupSuperClasses(module)
- .firstOrNull { it.kind == DocumentationNode.Kind.Class || it.kind == DocumentationNode.Kind.ExternalClass }
+ .firstOrNull { it.kind == NodeKind.Class || it.kind == NodeKind.ExternalClass }
?.let { ClassDocumentationNodeAdapter(module, it) }
override fun interfaceTypes(): Array<out Type> =
node.lookupSuperClasses(module)
- .filter { it.kind == DocumentationNode.Kind.Interface }
+ .filter { it.kind == NodeKind.Interface }
.map { ClassDocumentationNodeAdapter(module, it) }
.toTypedArray()
override fun containingType(): Type? = when (node.owner?.kind) {
- DocumentationNode.Kind.Package -> null
- DocumentationNode.Kind.Class,
- DocumentationNode.Kind.Interface,
- DocumentationNode.Kind.Object,
- DocumentationNode.Kind.Enum -> ClassDocumentationNodeAdapter(module, node.owner!!)
+ NodeKind.Package -> null
+ NodeKind.Class,
+ NodeKind.Interface,
+ NodeKind.Object,
+ NodeKind.Enum -> ClassDocumentationNodeAdapter(module, node.owner!!)
else -> null
}
}
class ParameterAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), Parameter {
- override fun typeName(): String? = JavaLanguageService().renderType(node.detail(DocumentationNode.Kind.Type))
- override fun type(): Type? = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type))
+ override fun typeName(): String? = JavaLanguageService().renderType(node.detail(NodeKind.Type))
+ override fun type(): Type? = TypeAdapter(module, node.detail(NodeKind.Type))
override fun annotations(): Array<out AnnotationDesc> = nodeAnnotations(this).toTypedArray()
}
@@ -288,10 +288,10 @@ class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: Docu
}
}
-fun classOf(fqName: String, kind: DocumentationNode.Kind = DocumentationNode.Kind.Class) = DocumentationNode(fqName.substringAfterLast(".", fqName), Content.Empty, kind).let { node ->
+fun classOf(fqName: String, kind: NodeKind = NodeKind.Class) = DocumentationNode(fqName.substringAfterLast(".", fqName), Content.Empty, kind).let { node ->
val pkg = fqName.substringBeforeLast(".", "")
if (pkg.isNotEmpty()) {
- node.append(DocumentationNode(pkg, Content.Empty, DocumentationNode.Kind.Package), DocumentationReference.Kind.Owner)
+ node.append(DocumentationNode(pkg, Content.Empty, NodeKind.Package), RefKind.Owner)
}
node
@@ -308,37 +308,37 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio
.filter { it.tag == "Exceptions" }
.map { it.subjectName }
.filterNotNull()
- .map { ThrowsTagAdapter(this, ClassDocumentationNodeAdapter(module, classOf(it, DocumentationNode.Kind.Exception))) }
+ .map { ThrowsTagAdapter(this, ClassDocumentationNodeAdapter(module, classOf(it, NodeKind.Exception))) }
.toTypedArray()
- override fun isVarArgs(): Boolean = node.details(DocumentationNode.Kind.Parameter).any { false } // TODO
+ override fun isVarArgs(): Boolean = node.details(NodeKind.Parameter).any { false } // TODO
override fun isSynchronized(): Boolean = node.annotations.any { it.name == "synchronized" }
- override fun paramTags(): Array<out ParamTag> = node.details(DocumentationNode.Kind.Parameter)
+ override fun paramTags(): Array<out ParamTag> = node.details(NodeKind.Parameter)
.filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }
.map { ParamTagAdapter(module, this, it.name, false, it.content.children) }
.toTypedArray()
override fun thrownExceptionTypes(): Array<out Type> = emptyArray()
override fun receiverType(): Type? = receiverNode()?.let { receiver -> TypeAdapter(module, receiver) }
- override fun flatSignature(): String = node.details(DocumentationNode.Kind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")")
- override fun signature(): String = node.details(DocumentationNode.Kind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")") // TODO it should be FQ types
+ override fun flatSignature(): String = node.details(NodeKind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")")
+ override fun signature(): String = node.details(NodeKind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")") // TODO it should be FQ types
override fun parameters(): Array<out Parameter> =
((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver, this)) } ?: emptyList())
- + node.details(DocumentationNode.Kind.Parameter).map { ParameterAdapter(module, it) }
+ + node.details(NodeKind.Parameter).map { ParameterAdapter(module, it) }
).toTypedArray()
- override fun typeParameters(): Array<out TypeVariable> = node.details(DocumentationNode.Kind.TypeParameter).map { TypeVariableAdapter(module, it) }.toTypedArray()
+ override fun typeParameters(): Array<out TypeVariable> = node.details(NodeKind.TypeParameter).map { TypeVariableAdapter(module, it) }.toTypedArray()
- override fun typeParamTags(): Array<out ParamTag> = node.details(DocumentationNode.Kind.TypeParameter).filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }.map {
+ override fun typeParamTags(): Array<out ParamTag> = node.details(NodeKind.TypeParameter).filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }.map {
ParamTagAdapter(module, this, it.name, true, it.content.children)
}.toTypedArray()
- private fun receiverNode() = node.details(DocumentationNode.Kind.Receiver).let { receivers ->
+ private fun receiverNode() = node.details(NodeKind.Receiver).let { receivers ->
when {
- receivers.isNotEmpty() -> receivers.single().detail(DocumentationNode.Kind.Type)
+ receivers.isNotEmpty() -> receivers.single().detail(NodeKind.Type)
else -> null
}
}
@@ -360,16 +360,16 @@ class MethodAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : Docume
override fun isDefault(): Boolean = false
- override fun returnType(): Type = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type))
+ override fun returnType(): Type = TypeAdapter(module, node.detail(NodeKind.Type))
}
class FieldAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc by ProgramElementAdapter(module, node), FieldDoc {
override fun isSynthetic(): Boolean = false
- override fun constantValueExpression(): String? = node.details(DocumentationNode.Kind.Value).firstOrNull()?.let { it.name }
+ override fun constantValueExpression(): String? = node.details(NodeKind.Value).firstOrNull()?.let { it.name }
override fun constantValue(): Any? = constantValueExpression()
- override fun type(): Type = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type))
+ override fun type(): Type = TypeAdapter(module, node.detail(NodeKind.Type))
override fun isTransient(): Boolean = node.hasAnnotation(Transient::class)
override fun serialFieldTags(): Array<out SerialFieldTag> = emptyArray()
@@ -384,48 +384,48 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
override fun name(): String {
val parent = classNode.owner
- if (parent?.kind in DocumentationNode.Kind.classLike) {
+ if (parent?.kind in NodeKind.classLike) {
return parent!!.name + "." + classNode.name
}
return classNode.name
}
- override fun constructors(filter: Boolean): Array<out ConstructorDoc> = classNode.members(DocumentationNode.Kind.Constructor).map { ConstructorAdapter(module, it) }.toTypedArray()
+ override fun constructors(filter: Boolean): Array<out ConstructorDoc> = classNode.members(NodeKind.Constructor).map { ConstructorAdapter(module, it) }.toTypedArray()
override fun constructors(): Array<out ConstructorDoc> = constructors(true)
override fun importedPackages(): Array<out PackageDoc> = emptyArray()
override fun importedClasses(): Array<out ClassDoc>? = emptyArray()
- override fun typeParameters(): Array<out TypeVariable> = classNode.details(DocumentationNode.Kind.TypeParameter).map { TypeVariableAdapter(module, it) }.toTypedArray()
- override fun asTypeVariable(): TypeVariable? = if (classNode.kind == DocumentationNode.Kind.Class) TypeVariableAdapter(module, classNode) else null
+ override fun typeParameters(): Array<out TypeVariable> = classNode.details(NodeKind.TypeParameter).map { TypeVariableAdapter(module, it) }.toTypedArray()
+ override fun asTypeVariable(): TypeVariable? = if (classNode.kind == NodeKind.Class) TypeVariableAdapter(module, classNode) else null
override fun isExternalizable(): Boolean = interfaces().any { it.qualifiedName() == "java.io.Externalizable" }
override fun definesSerializableFields(): Boolean = false
- override fun methods(filter: Boolean): Array<out MethodDoc> = classNode.members(DocumentationNode.Kind.Function).map { MethodAdapter(module, it) }.toTypedArray() // TODO include get/set methods
+ override fun methods(filter: Boolean): Array<out MethodDoc> = classNode.members(NodeKind.Function).map { MethodAdapter(module, it) }.toTypedArray() // TODO include get/set methods
override fun methods(): Array<out MethodDoc> = methods(true)
- override fun enumConstants(): Array<out FieldDoc>? = classNode.members(DocumentationNode.Kind.EnumItem).map { FieldAdapter(module, it) }.toTypedArray()
- override fun isAbstract(): Boolean = classNode.details(DocumentationNode.Kind.Modifier).any { it.name == "abstract" }
+ override fun enumConstants(): Array<out FieldDoc>? = classNode.members(NodeKind.EnumItem).map { FieldAdapter(module, it) }.toTypedArray()
+ override fun isAbstract(): Boolean = classNode.details(NodeKind.Modifier).any { it.name == "abstract" }
override fun interfaceTypes(): Array<out Type> = classNode.lookupSuperClasses(module)
- .filter { it.kind == DocumentationNode.Kind.Interface }
+ .filter { it.kind == NodeKind.Interface }
.map { ClassDocumentationNodeAdapter(module, it) }
.toTypedArray()
override fun interfaces(): Array<out ClassDoc> = classNode.lookupSuperClasses(module)
- .filter { it.kind == DocumentationNode.Kind.Interface }
+ .filter { it.kind == NodeKind.Interface }
.map { ClassDocumentationNodeAdapter(module, it) }
.toTypedArray()
- override fun typeParamTags(): Array<out ParamTag> = (classNode.details(DocumentationNode.Kind.TypeParameter).filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }.map {
+ override fun typeParamTags(): Array<out ParamTag> = (classNode.details(NodeKind.TypeParameter).filter { it.content.summary !is ContentEmpty || it.content.description !is ContentEmpty || it.content.sections.isNotEmpty() }.map {
ParamTagAdapter(module, this, it.name, true, it.content.children)
} + classNode.content.sections.filter { it.subjectName in typeParameters().map { it.simpleTypeName() } }.map {
ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children)
}).toTypedArray()
override fun fields(): Array<out FieldDoc> = fields(true)
- override fun fields(filter: Boolean): Array<out FieldDoc> = classNode.members(DocumentationNode.Kind.Field).map { FieldAdapter(module, it) }.toTypedArray()
+ override fun fields(filter: Boolean): Array<out FieldDoc> = classNode.members(NodeKind.Field).map { FieldAdapter(module, it) }.toTypedArray()
override fun findClass(className: String?): ClassDoc? = null // TODO !!!
override fun serializableFields(): Array<out FieldDoc> = emptyArray()
- override fun superclassType(): Type? = classNode.lookupSuperClasses(module).singleOrNull { it.kind == DocumentationNode.Kind.Class }?.let { ClassDocumentationNodeAdapter(module, it) }
+ override fun superclassType(): Type? = classNode.lookupSuperClasses(module).singleOrNull { it.kind == NodeKind.Class }?.let { ClassDocumentationNodeAdapter(module, it) }
override fun serializationMethods(): Array<out MethodDoc> = emptyArray() // TODO
- override fun superclass(): ClassDoc? = classNode.lookupSuperClasses(module).singleOrNull { it.kind == DocumentationNode.Kind.Class }?.let { ClassDocumentationNodeAdapter(module, it) }
+ override fun superclass(): ClassDoc? = classNode.lookupSuperClasses(module).singleOrNull { it.kind == NodeKind.Class }?.let { ClassDocumentationNodeAdapter(module, it) }
override fun isSerializable(): Boolean = false // TODO
override fun subclassOf(cd: ClassDoc?): Boolean {
if (cd == null) {
@@ -445,18 +445,18 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
}
visitedTypes.add(fqName)
- types.addAll(type.details(DocumentationNode.Kind.Supertype).filter { it.qualifiedName() !in visitedTypes })
+ types.addAll(type.details(NodeKind.Supertype).filter { it.qualifiedName() !in visitedTypes })
}
return false
}
- override fun innerClasses(): Array<out ClassDoc> = classNode.members(DocumentationNode.Kind.Class).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
+ override fun innerClasses(): Array<out ClassDoc> = classNode.members(NodeKind.Class).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
override fun innerClasses(filter: Boolean): Array<out ClassDoc> = innerClasses()
}
fun DocumentationNode.lookupSuperClasses(module: ModuleNodeAdapter) =
- details(DocumentationNode.Kind.Supertype)
+ details(NodeKind.Supertype)
.map { it.links.firstOrNull() }
.map { module.allTypes[it?.qualifiedName()] }
.filterNotNull()
@@ -465,7 +465,7 @@ fun List<DocumentationNode>.collectAllTypesRecursively(): Map<String, Documentat
val result = hashMapOf<String, DocumentationNode>()
fun DocumentationNode.collectTypesRecursively() {
- val classLikeMembers = DocumentationNode.Kind.classLike.flatMap { members(it) }
+ val classLikeMembers = NodeKind.classLike.flatMap { members(it) }
classLikeMembers.forEach {
result.put(it.qualifiedName(), it)
it.collectTypesRecursively()
@@ -477,8 +477,8 @@ fun List<DocumentationNode>.collectAllTypesRecursively(): Map<String, Documentat
}
class ModuleNodeAdapter(val module: DocumentationModule, val reporter: DocErrorReporter, val outputPath: String) : DocumentationNodeBareAdapter(module), DocErrorReporter by reporter, RootDoc {
- val allPackages = module.members(DocumentationNode.Kind.Package).toMapBy { it.name }
- val allTypes = module.members(DocumentationNode.Kind.Package).collectAllTypesRecursively()
+ val allPackages = module.members(NodeKind.Package).toMapBy { it.name }
+ val allTypes = module.members(NodeKind.Package).collectAllTypesRecursively()
override fun packageNamed(name: String?): PackageDoc? = allPackages[name]?.let { PackageAdapter(this, it) }
@@ -492,7 +492,7 @@ class ModuleNodeAdapter(val module: DocumentationModule, val reporter: DocErrorR
arrayOf("-keywords")
)
- override fun specifiedPackages(): Array<out PackageDoc>? = module.members(DocumentationNode.Kind.Package).map { PackageAdapter(this, it) }.toTypedArray()
+ override fun specifiedPackages(): Array<out PackageDoc>? = module.members(NodeKind.Package).map { PackageAdapter(this, it) }.toTypedArray()
override fun classNamed(qualifiedName: String?): ClassDoc? =
allTypes[qualifiedName]?.let { ClassDocumentationNodeAdapter(this, it) }
diff --git a/core/src/main/kotlin/javadoc/source-position.kt b/core/src/main/kotlin/javadoc/source-position.kt
index 0e4c6e3c..6125f968 100644
--- a/core/src/main/kotlin/javadoc/source-position.kt
+++ b/core/src/main/kotlin/javadoc/source-position.kt
@@ -2,12 +2,13 @@ package org.jetbrains.dokka.javadoc
import com.sun.javadoc.SourcePosition
import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.NodeKind
import java.io.File
class SourcePositionAdapter(val docNode: DocumentationNode) : SourcePosition {
private val sourcePositionParts: List<String> by lazy {
- docNode.details(DocumentationNode.Kind.SourcePosition).firstOrNull()?.name?.split(":") ?: emptyList()
+ docNode.details(NodeKind.SourcePosition).firstOrNull()?.name?.split(":") ?: emptyList()
}
override fun file(): File? = if (sourcePositionParts.isEmpty()) null else File(sourcePositionParts[0])
diff --git a/core/src/main/kotlin/javadoc/tags.kt b/core/src/main/kotlin/javadoc/tags.kt
index 5872dbaa..aab5ecf1 100644
--- a/core/src/main/kotlin/javadoc/tags.kt
+++ b/core/src/main/kotlin/javadoc/tags.kt
@@ -176,9 +176,9 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten
is ContentNodeLink -> {
val target = node.node
when (target?.kind) {
- DocumentationNode.Kind.Function -> result.add(SeeMethodTagAdapter(holder, MethodAdapter(module, node.node!!), node))
+ NodeKind.Function -> result.add(SeeMethodTagAdapter(holder, MethodAdapter(module, node.node!!), node))
- in DocumentationNode.Kind.classLike -> result.add(SeeClassTagAdapter(holder, ClassDocumentationNodeAdapter(module, node.node!!), node))
+ in NodeKind.classLike -> result.add(SeeClassTagAdapter(holder, ClassDocumentationNodeAdapter(module, node.node!!), node))
else -> buildInlineTags(module, holder, node.children, result)
}
diff --git a/core/src/test/kotlin/model/ClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt
index 981791c4..0a824f1c 100644
--- a/core/src/test/kotlin/model/ClassTest.kt
+++ b/core/src/test/kotlin/model/ClassTest.kt
@@ -1,8 +1,8 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
+import org.jetbrains.dokka.NodeKind
+import org.jetbrains.dokka.RefKind
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -11,7 +11,7 @@ public class ClassTest {
@Test fun emptyClass() {
verifyModel("testdata/classes/emptyClass.kt") { model ->
with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("Klass", name)
assertEquals(Content.Empty, content)
assertEquals("<init>", members.single().name)
@@ -23,7 +23,7 @@ public class ClassTest {
@Test fun emptyObject() {
verifyModel("testdata/classes/emptyObject.kt") { model ->
with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Object, kind)
+ assertEquals(NodeKind.Object, kind)
assertEquals("Obj", name)
assertEquals(Content.Empty, content)
assertTrue(members.none())
@@ -35,7 +35,7 @@ public class ClassTest {
@Test fun classWithConstructor() {
verifyModel("testdata/classes/classWithConstructor.kt") { model ->
with (model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("Klass", name)
assertEquals(Content.Empty, content)
assertTrue(links.none())
@@ -44,12 +44,12 @@ public class ClassTest {
with(members.elementAt(0)) {
assertEquals("<init>", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
+ assertEquals(NodeKind.Constructor, kind)
assertEquals(2, details.count())
assertEquals("public", details.elementAt(0).name)
with(details.elementAt(1)) {
assertEquals("name", name)
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals(Content.Empty, content)
assertEquals("String", details.single().name)
assertTrue(links.none())
@@ -65,7 +65,7 @@ public class ClassTest {
@Test fun classWithFunction() {
verifyModel("testdata/classes/classWithFunction.kt") { model ->
with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("Klass", name)
assertEquals(Content.Empty, content)
assertTrue(links.none())
@@ -74,7 +74,7 @@ public class ClassTest {
with(members.elementAt(0)) {
assertEquals("<init>", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
+ assertEquals(NodeKind.Constructor, kind)
assertEquals(1, details.count())
assertEquals("public", details.elementAt(0).name)
assertTrue(links.none())
@@ -83,8 +83,8 @@ public class ClassTest {
with(members.elementAt(1)) {
assertEquals("fn", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
+ assertEquals(NodeKind.Function, kind)
+ assertEquals("Unit", detail(NodeKind.Type).name)
assertTrue(links.none())
assertTrue(members.none())
}
@@ -95,7 +95,7 @@ public class ClassTest {
@Test fun classWithProperty() {
verifyModel("testdata/classes/classWithProperty.kt") { model ->
with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("Klass", name)
assertEquals(Content.Empty, content)
assertTrue(links.none())
@@ -104,7 +104,7 @@ public class ClassTest {
with(members.elementAt(0)) {
assertEquals("<init>", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
+ assertEquals(NodeKind.Constructor, kind)
assertEquals(1, details.count())
assertEquals("public", details.elementAt(0).name)
assertTrue(members.none())
@@ -113,8 +113,8 @@ public class ClassTest {
with(members.elementAt(1)) {
assertEquals("name", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
+ assertEquals(NodeKind.Property, kind)
+ assertEquals("String", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
@@ -125,7 +125,7 @@ public class ClassTest {
@Test fun classWithCompanionObject() {
verifyModel("testdata/classes/classWithCompanionObject.kt") { model ->
with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("Klass", name)
assertEquals(Content.Empty, content)
assertTrue(links.none())
@@ -137,13 +137,13 @@ public class ClassTest {
}
with(members.elementAt(1)) {
assertEquals("x", name)
- assertEquals(DocumentationNode.Kind.CompanionObjectProperty, kind)
+ assertEquals(NodeKind.CompanionObjectProperty, kind)
assertTrue(members.none())
assertTrue(links.none())
}
with(members.elementAt(2)) {
assertEquals("foo", name)
- assertEquals(DocumentationNode.Kind.CompanionObjectFunction, kind)
+ assertEquals(NodeKind.CompanionObjectFunction, kind)
assertTrue(members.none())
assertTrue(links.none())
}
@@ -157,21 +157,21 @@ public class ClassTest {
with(cls.annotations[0]) {
assertEquals("Strictfp", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
}
}
}
@Test fun dataClass() {
verifyPackageMember("testdata/classes/dataClass.kt") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
+ val modifiers = cls.details(NodeKind.Modifier).map { it.name }
assertTrue("data" in modifiers)
}
}
@Test fun sealedClass() {
verifyPackageMember("testdata/classes/sealedClass.kt") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
+ val modifiers = cls.details(NodeKind.Modifier).map { it.name }
assertEquals(1, modifiers.count { it == "sealed" })
}
}
@@ -182,13 +182,13 @@ public class ClassTest {
with(deprecation!!) {
assertEquals("Deprecated", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
+ assertEquals(NodeKind.Value, kind)
assertEquals("\"should no longer be used\"", name)
}
}
@@ -204,12 +204,12 @@ public class ClassTest {
with(annotations[0]) {
assertEquals("Retention", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
+ assertEquals(NodeKind.Value, kind)
assertEquals("RetentionPolicy.SOURCE", name)
}
}
@@ -221,11 +221,11 @@ public class ClassTest {
@Test fun notOpenClass() {
verifyModel("testdata/classes/notOpenClass.kt") { model ->
with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) {
- val modifiers = details(DocumentationNode.Kind.Modifier)
+ val modifiers = details(NodeKind.Modifier)
assertEquals(2, modifiers.size)
assertEquals("final", modifiers[1].name)
- val overrideReferences = references(DocumentationReference.Kind.Override)
+ val overrideReferences = references(RefKind.Override)
assertEquals(1, overrideReferences.size)
}
}
@@ -234,11 +234,11 @@ public class ClassTest {
@Test fun indirectOverride() {
verifyModel("testdata/classes/indirectOverride.kt") { model ->
with(model.members.single().members.first { it.name == "E"}.members.first { it.name == "foo" }) {
- val modifiers = details(DocumentationNode.Kind.Modifier)
+ val modifiers = details(NodeKind.Modifier)
assertEquals(2, modifiers.size)
assertEquals("final", modifiers[1].name)
- val overrideReferences = references(DocumentationReference.Kind.Override)
+ val overrideReferences = references(RefKind.Override)
assertEquals(1, overrideReferences.size)
}
}
@@ -247,7 +247,7 @@ public class ClassTest {
@Test fun innerClass() {
verifyPackageMember("testdata/classes/innerClass.kt") { cls ->
val innerClass = cls.members.single { it.name == "D" }
- val modifiers = innerClass.details(DocumentationNode.Kind.Modifier)
+ val modifiers = innerClass.details(NodeKind.Modifier)
assertEquals(3, modifiers.size)
assertEquals("inner", modifiers[2].name)
}
@@ -257,16 +257,16 @@ public class ClassTest {
verifyModel("testdata/classes/companionObjectExtension.kt") { model ->
val pkg = model.members.single()
val cls = pkg.members.single { it.name == "Foo" }
- val extensions = cls.extensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty }
+ val extensions = cls.extensions.filter { it.kind == NodeKind.CompanionObjectProperty }
assertEquals(1, extensions.size)
}
}
@Test fun secondaryConstructor() {
verifyPackageMember("testdata/classes/secondaryConstructor.kt") { cls ->
- val constructors = cls.members(DocumentationNode.Kind.Constructor)
+ val constructors = cls.members(NodeKind.Constructor)
assertEquals(2, constructors.size)
- with (constructors.first { it.details(DocumentationNode.Kind.Parameter).size == 1}) {
+ with (constructors.first { it.details(NodeKind.Parameter).size == 1}) {
assertEquals("<init>", name)
assertEquals("This is a secondary constructor.", summary.toTestString())
}
diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt
index 83fd8223..0a65b640 100644
--- a/core/src/test/kotlin/model/FunctionTest.kt
+++ b/core/src/test/kotlin/model/FunctionTest.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.NodeKind
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -11,9 +11,9 @@ public class FunctionTest {
verifyModel("testdata/functions/function.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("Function fn", content.summary.toTestString())
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("Unit", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
@@ -24,17 +24,17 @@ public class FunctionTest {
verifyModel("testdata/functions/functionWithReceiver.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("kotlin.String", name)
- assertEquals(DocumentationNode.Kind.ExternalClass, kind)
+ assertEquals(NodeKind.ExternalClass, kind)
assertEquals(2, members.count())
with(members[0]) {
assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("Function with receiver", content.summary.toTestString())
assertEquals("public", details.elementAt(0).name)
assertEquals("final", details.elementAt(1).name)
with(details.elementAt(2)) {
assertEquals("<this>", name)
- assertEquals(DocumentationNode.Kind.Receiver, kind)
+ assertEquals(NodeKind.Receiver, kind)
assertEquals(Content.Empty, content)
assertEquals("String", details.single().name)
assertTrue(members.none())
@@ -46,7 +46,7 @@ public class FunctionTest {
}
with(members[1]) {
assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
}
}
}
@@ -56,14 +56,14 @@ public class FunctionTest {
verifyModel("testdata/functions/genericFunction.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("generic", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("generic function", content.summary.toTestString())
assertEquals("private", details.elementAt(0).name)
assertEquals("final", details.elementAt(1).name)
with(details.elementAt(2)) {
assertEquals("T", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
+ assertEquals(NodeKind.TypeParameter, kind)
assertEquals(Content.Empty, content)
assertTrue(details.none())
assertTrue(members.none())
@@ -80,18 +80,18 @@ public class FunctionTest {
verifyModel("testdata/functions/genericFunctionWithConstraints.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("generic", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("generic function", content.summary.toTestString())
assertEquals("public", details.elementAt(0).name)
assertEquals("final", details.elementAt(1).name)
with(details.elementAt(2)) {
assertEquals("T", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
+ assertEquals(NodeKind.TypeParameter, kind)
assertEquals(Content.Empty, content)
with(details.single()) {
assertEquals("R", name)
- assertEquals(DocumentationNode.Kind.UpperBound, kind)
+ assertEquals(NodeKind.UpperBound, kind)
assertEquals(Content.Empty, content)
assertTrue(details.none())
assertTrue(members.none())
@@ -102,7 +102,7 @@ public class FunctionTest {
}
with(details.elementAt(3)) {
assertEquals("R", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
+ assertEquals(NodeKind.TypeParameter, kind)
assertEquals(Content.Empty, content)
assertTrue(members.none())
assertTrue(links.none())
@@ -119,7 +119,7 @@ public class FunctionTest {
verifyModel("testdata/functions/functionWithParams.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("function", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("Multiline", content.summary.toTestString())
assertEquals("""Function
Documentation""", content.description.toTestString())
@@ -128,7 +128,7 @@ Documentation""", content.description.toTestString())
assertEquals("final", details.elementAt(1).name)
with(details.elementAt(2)) {
assertEquals("x", name)
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals("parameter", content.summary.toTestString())
assertEquals("Int", details.single().name)
assertTrue(members.none())
@@ -147,7 +147,7 @@ Documentation""", content.description.toTestString())
with(func.annotations[0]) {
assertEquals("Strictfp", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
}
}
}
@@ -160,7 +160,7 @@ Documentation""", content.description.toTestString())
@Test fun inlineFunction() {
verifyPackageMember("testdata/functions/inlineFunction.kt") { func ->
- val modifiers = func.details(DocumentationNode.Kind.Modifier).map { it.name }
+ val modifiers = func.details(NodeKind.Modifier).map { it.name }
assertTrue("inline" in modifiers)
}
}
@@ -173,7 +173,7 @@ Documentation""", content.description.toTestString())
with(annotations[0]) {
assertEquals("Fancy", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
}
}
}
@@ -183,7 +183,7 @@ Documentation""", content.description.toTestString())
@Test fun functionWithNoinlineParam() {
verifyPackageMember("testdata/functions/functionWithNoinlineParam.kt") { func ->
with(func.details.elementAt(2)) {
- val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
+ val modifiers = details(NodeKind.Modifier).map { it.name }
assertTrue("noinline" in modifiers)
}
}
@@ -196,13 +196,13 @@ Documentation""", content.description.toTestString())
with(annotations[0]) {
assertEquals("Fancy", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
+ assertEquals(NodeKind.Value, kind)
assertEquals("1", name)
}
}
@@ -215,7 +215,7 @@ Documentation""", content.description.toTestString())
verifyModel("testdata/functions/functionWithDefaultParameter.kt") { model ->
with(model.members.single().members.single()) {
with(details.elementAt(2)) {
- val value = details(DocumentationNode.Kind.Value)
+ val value = details(NodeKind.Value)
assertEquals(1, value.count())
with(value[0]) {
assertEquals("\"\"", name)
diff --git a/core/src/test/kotlin/model/JavaTest.kt b/core/src/test/kotlin/model/JavaTest.kt
index 903260d3..3d6f2e75 100644
--- a/core/src/test/kotlin/model/JavaTest.kt
+++ b/core/src/test/kotlin/model/JavaTest.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.tests
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
+import org.jetbrains.dokka.NodeKind
+import org.jetbrains.dokka.RefKind
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
@@ -11,8 +11,8 @@ public class JavaTest {
@Test fun function() {
verifyJavaPackageMember("testdata/java/member.java") { cls ->
assertEquals("Test", cls.name)
- assertEquals(DocumentationNode.Kind.Class, cls.kind)
- with(cls.members(DocumentationNode.Kind.Function).single()) {
+ assertEquals(NodeKind.Class, cls.kind)
+ with(cls.members(NodeKind.Function).single()) {
assertEquals("fn", name)
assertEquals("Summary for Function", content.summary.toTestString().trimEnd())
assertEquals(3, content.sections.size)
@@ -30,16 +30,16 @@ public class JavaTest {
assertEquals("Author", tag)
assertEquals("yole", toTestString())
}
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("Unit", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
with(details.first { it.name == "name" }) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
+ assertEquals(NodeKind.Parameter, kind)
+ assertEquals("String", detail(NodeKind.Type).name)
}
with(details.first { it.name == "value" }) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals("Int", detail(DocumentationNode.Kind.Type).name)
+ assertEquals(NodeKind.Parameter, kind)
+ assertEquals("Int", detail(NodeKind.Type).name)
}
}
}
@@ -47,7 +47,7 @@ public class JavaTest {
@Test fun memberWithModifiers() {
verifyJavaPackageMember("testdata/java/memberWithModifiers.java") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
+ val modifiers = cls.details(NodeKind.Modifier).map { it.name }
assertTrue("abstract" in modifiers)
with(cls.members.single { it.name == "fn" }) {
assertEquals("protected", details[0].name)
@@ -60,7 +60,7 @@ public class JavaTest {
@Test fun superClass() {
verifyJavaPackageMember("testdata/java/superClass.java") { cls ->
- val superTypes = cls.details(DocumentationNode.Kind.Supertype)
+ val superTypes = cls.details(NodeKind.Supertype)
assertEquals(2, superTypes.size)
assertEquals("Exception", superTypes[0].name)
assertEquals("Cloneable", superTypes[1].name)
@@ -69,12 +69,12 @@ public class JavaTest {
@Test fun arrayType() {
verifyJavaPackageMember("testdata/java/arrayType.java") { cls ->
- with(cls.members(DocumentationNode.Kind.Function).single()) {
- val type = detail(DocumentationNode.Kind.Type)
+ with(cls.members(NodeKind.Function).single()) {
+ val type = detail(NodeKind.Type)
assertEquals("Array", type.name)
- assertEquals("String", type.detail(DocumentationNode.Kind.Type).name)
- with(details(DocumentationNode.Kind.Parameter).single()) {
- val parameterType = detail(DocumentationNode.Kind.Type)
+ assertEquals("String", type.detail(NodeKind.Type).name)
+ with(details(NodeKind.Parameter).single()) {
+ val parameterType = detail(NodeKind.Type)
assertEquals("IntArray", parameterType.name)
}
}
@@ -83,16 +83,16 @@ public class JavaTest {
@Test fun typeParameter() {
verifyJavaPackageMember("testdata/java/typeParameter.java") { cls ->
- val typeParameters = cls.details(DocumentationNode.Kind.TypeParameter)
+ val typeParameters = cls.details(NodeKind.TypeParameter)
with(typeParameters.single()) {
assertEquals("T", name)
- with(detail(DocumentationNode.Kind.UpperBound)) {
+ with(detail(NodeKind.UpperBound)) {
assertEquals("Comparable", name)
- assertEquals("T", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("T", detail(NodeKind.Type).name)
}
}
- with(cls.members(DocumentationNode.Kind.Function).single()) {
- val methodTypeParameters = details(DocumentationNode.Kind.TypeParameter)
+ with(cls.members(NodeKind.Function).single()) {
+ val methodTypeParameters = details(NodeKind.TypeParameter)
with(methodTypeParameters.single()) {
assertEquals("E", name)
}
@@ -102,7 +102,7 @@ public class JavaTest {
@Test fun constructors() {
verifyJavaPackageMember("testdata/java/constructors.java") { cls ->
- val constructors = cls.members(DocumentationNode.Kind.Constructor)
+ val constructors = cls.members(NodeKind.Constructor)
assertEquals(2, constructors.size)
with(constructors[0]) {
assertEquals("<init>", name)
@@ -112,39 +112,39 @@ public class JavaTest {
@Test fun innerClass() {
verifyJavaPackageMember("testdata/java/innerClass.java") { cls ->
- val innerClass = cls.members(DocumentationNode.Kind.Class).single()
+ val innerClass = cls.members(NodeKind.Class).single()
assertEquals("D", innerClass.name)
}
}
@Test fun varargs() {
verifyJavaPackageMember("testdata/java/varargs.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
- val param = fn.detail(DocumentationNode.Kind.Parameter)
- assertEquals("vararg", param.details(DocumentationNode.Kind.Modifier).first().name)
- val psiType = param.detail(DocumentationNode.Kind.Type)
+ val fn = cls.members(NodeKind.Function).single()
+ val param = fn.detail(NodeKind.Parameter)
+ assertEquals("vararg", param.details(NodeKind.Modifier).first().name)
+ val psiType = param.detail(NodeKind.Type)
assertEquals("String", psiType.name)
- assertTrue(psiType.details(DocumentationNode.Kind.Type).isEmpty())
+ assertTrue(psiType.details(NodeKind.Type).isEmpty())
}
}
@Test fun fields() {
verifyJavaPackageMember("testdata/java/field.java") { cls ->
- val i = cls.members(DocumentationNode.Kind.Property).single { it.name == "i" }
- assertEquals("Int", i.detail(DocumentationNode.Kind.Type).name)
- assertTrue("var" in i.details(DocumentationNode.Kind.Modifier).map { it.name })
-
- val s = cls.members(DocumentationNode.Kind.Property).single { it.name == "s" }
- assertEquals("String", s.detail(DocumentationNode.Kind.Type).name)
- assertFalse("var" in s.details(DocumentationNode.Kind.Modifier).map { it.name })
- assertTrue("static" in s.details(DocumentationNode.Kind.Modifier).map { it.name })
+ val i = cls.members(NodeKind.Property).single { it.name == "i" }
+ assertEquals("Int", i.detail(NodeKind.Type).name)
+ assertTrue("var" in i.details(NodeKind.Modifier).map { it.name })
+
+ val s = cls.members(NodeKind.Property).single { it.name == "s" }
+ assertEquals("String", s.detail(NodeKind.Type).name)
+ assertFalse("var" in s.details(NodeKind.Modifier).map { it.name })
+ assertTrue("static" in s.details(NodeKind.Modifier).map { it.name })
}
}
@Test fun staticMethod() {
verifyJavaPackageMember("testdata/java/staticMethod.java") { cls ->
- val m = cls.members(DocumentationNode.Kind.Function).single { it.name == "foo" }
- assertTrue("static" in m.details(DocumentationNode.Kind.Modifier).map { it.name })
+ val m = cls.members(NodeKind.Function).single { it.name == "foo" }
+ assertTrue("static" in m.details(NodeKind.Modifier).map { it.name })
}
}
@@ -154,10 +154,10 @@ public class JavaTest {
with(cls.annotations[0]) {
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
+ assertEquals(NodeKind.Parameter, kind)
assertEquals(1, details.count())
with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
+ assertEquals(NodeKind.Value, kind)
assertEquals("[AnnotationTarget.FIELD, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]", name)
}
}
@@ -167,30 +167,30 @@ public class JavaTest {
@Test fun deprecation() {
verifyJavaPackageMember("testdata/java/deprecation.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
+ val fn = cls.members(NodeKind.Function).single()
assertEquals("This should no longer be used", fn.deprecation!!.content.toTestString())
}
}
@Test fun javaLangObject() {
verifyJavaPackageMember("testdata/java/javaLangObject.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
- assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name)
+ val fn = cls.members(NodeKind.Function).single()
+ assertEquals("Any", fn.detail(NodeKind.Type).name)
}
}
@Test fun enumValues() {
verifyJavaPackageMember("testdata/java/enumValues.java") { cls ->
- val superTypes = cls.details(DocumentationNode.Kind.Supertype)
+ val superTypes = cls.details(NodeKind.Supertype)
assertEquals(0, superTypes.size)
- assertEquals(1, cls.members(DocumentationNode.Kind.EnumItem).size)
+ assertEquals(1, cls.members(NodeKind.EnumItem).size)
}
}
@Test fun inheritorLinks() {
verifyJavaPackageMember("testdata/java/inheritorLinks.java") { cls ->
val fooClass = cls.members.single { it.name == "Foo" }
- val inheritors = fooClass.references(DocumentationReference.Kind.Inheritor)
+ val inheritors = fooClass.references(RefKind.Inheritor)
assertEquals(1, inheritors.size)
}
}
diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
index b439d399..fab307f3 100644
--- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt
+++ b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.DocumentationModule
-import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.NodeKind
import org.junit.Test
import kotlin.test.assertEquals
@@ -11,11 +11,11 @@ class KotlinAsJavaTest {
val pkg = model.members.single()
val facadeClass = pkg.members.single { it.name == "FunctionKt" }
- assertEquals(DocumentationNode.Kind.Class, facadeClass.kind)
+ assertEquals(NodeKind.Class, facadeClass.kind)
val fn = facadeClass.members.single()
assertEquals("fn", fn.name)
- assertEquals(DocumentationNode.Kind.Function, fn.kind)
+ assertEquals(NodeKind.Function, fn.kind)
}
}
@@ -23,7 +23,7 @@ class KotlinAsJavaTest {
verifyModelAsJava("testdata/comments/oneLineDoc.kt") { model ->
val facadeClass = model.members.single().members.single { it.name == "OneLineDocKt" }
val getter = facadeClass.members.single { it.name == "getProperty" }
- assertEquals(DocumentationNode.Kind.Function, getter.kind)
+ assertEquals(NodeKind.Function, getter.kind)
assertEquals("doc", getter.content.summary.toTestString())
}
}
diff --git a/core/src/test/kotlin/model/LinkTest.kt b/core/src/test/kotlin/model/LinkTest.kt
index c30e1c10..3db1b90f 100644
--- a/core/src/test/kotlin/model/LinkTest.kt
+++ b/core/src/test/kotlin/model/LinkTest.kt
@@ -9,7 +9,7 @@ public class LinkTest {
verifyModel("testdata/links/linkToSelf.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("This is link to [Foo -> Class:Foo]", content.summary.toTestString())
}
}
@@ -19,7 +19,7 @@ public class LinkTest {
verifyModel("testdata/links/linkToMember.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("This is link to [member -> Function:member]", content.summary.toTestString())
}
}
@@ -29,7 +29,7 @@ public class LinkTest {
verifyModel("testdata/links/linkToQualifiedMember.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
+ assertEquals(NodeKind.Class, kind)
assertEquals("This is link to [Foo.member -> Function:member]", content.summary.toTestString())
}
}
@@ -39,7 +39,7 @@ public class LinkTest {
verifyModel("testdata/links/linkToParam.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
+ assertEquals(NodeKind.Function, kind)
assertEquals("This is link to [param -> Parameter:param]", content.summary.toTestString())
}
}
diff --git a/core/src/test/kotlin/model/PackageTest.kt b/core/src/test/kotlin/model/PackageTest.kt
index aa5a059a..edb5d989 100644
--- a/core/src/test/kotlin/model/PackageTest.kt
+++ b/core/src/test/kotlin/model/PackageTest.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.NodeKind
import org.jetbrains.kotlin.config.KotlinSourceRoot
import org.junit.Test
import kotlin.test.assertEquals
@@ -11,7 +11,7 @@ public class PackageTest {
@Test fun rootPackage() {
verifyModel("testdata/packages/rootPackage.kt") { model ->
with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals("", name)
assertEquals(Content.Empty, content)
assertTrue(details.none())
@@ -24,7 +24,7 @@ public class PackageTest {
@Test fun simpleNamePackage() {
verifyModel("testdata/packages/simpleNamePackage.kt") { model ->
with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals("simple", name)
assertEquals(Content.Empty, content)
assertTrue(details.none())
@@ -37,7 +37,7 @@ public class PackageTest {
@Test fun dottedNamePackage() {
verifyModel("testdata/packages/dottedNamePackage.kt") { model ->
with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals("dot.name", name)
assertEquals(Content.Empty, content)
assertTrue(details.none())
@@ -52,7 +52,7 @@ public class PackageTest {
KotlinSourceRoot("testdata/packages/simpleNamePackage.kt")) { model ->
assertEquals(2, model.members.count())
with(model.members.single { it.name == "simple" }) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals("simple", name)
assertEquals(Content.Empty, content)
assertTrue(details.none())
@@ -60,7 +60,7 @@ public class PackageTest {
assertTrue(links.none())
}
with(model.members.single { it.name == "dot.name" }) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals(Content.Empty, content)
assertTrue(details.none())
assertTrue(members.none())
@@ -74,7 +74,7 @@ public class PackageTest {
KotlinSourceRoot("testdata/packages/simpleNamePackage2.kt")) { model ->
assertEquals(1, model.members.count())
with(model.members.elementAt(0)) {
- assertEquals(DocumentationNode.Kind.Package, kind)
+ assertEquals(NodeKind.Package, kind)
assertEquals("simple", name)
assertEquals(Content.Empty, content)
assertTrue(details.none())
diff --git a/core/src/test/kotlin/model/PropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt
index 716aac54..a049979d 100644
--- a/core/src/test/kotlin/model/PropertyTest.kt
+++ b/core/src/test/kotlin/model/PropertyTest.kt
@@ -1,8 +1,8 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
+import org.jetbrains.dokka.NodeKind
+import org.jetbrains.dokka.RefKind
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -12,9 +12,9 @@ public class PropertyTest {
verifyModel("testdata/properties/valueProperty.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
+ assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("String", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
@@ -25,9 +25,9 @@ public class PropertyTest {
verifyModel("testdata/properties/variableProperty.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
+ assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("String", detail(NodeKind.Type).name)
assertTrue(members.none())
assertTrue(links.none())
}
@@ -38,9 +38,9 @@ public class PropertyTest {
verifyModel("testdata/properties/valuePropertyWithGetter.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
+ assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
+ assertEquals("String", detail(NodeKind.Type).name)
assertTrue(links.none())
assertTrue(members.none())
}
@@ -51,10 +51,10 @@ public class PropertyTest {
verifyModel("testdata/properties/variablePropertyWithAccessors.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
+ assertEquals(NodeKind.Property, kind)
assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
+ assertEquals("String", detail(NodeKind.Type).name)
+ val modifiers = details(NodeKind.Modifier).map { it.name }
assertTrue("final" in modifiers)
assertTrue("public" in modifiers)
assertTrue("var" in modifiers)
@@ -71,7 +71,7 @@ public class PropertyTest {
with(annotations[0]) {
assertEquals("Volatile", name)
assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
+ assertEquals(NodeKind.Annotation, kind)
}
}
}
@@ -81,10 +81,10 @@ public class PropertyTest {
verifyModel("testdata/properties/propertyWithReceiver.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("kotlin.String", name)
- assertEquals(DocumentationNode.Kind.ExternalClass, kind)
+ assertEquals(NodeKind.ExternalClass, kind)
with(members.single()) {
assertEquals("foobar", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
+ assertEquals(NodeKind.Property, kind)
}
}
}
@@ -94,7 +94,7 @@ public class PropertyTest {
verifyModel("testdata/properties/propertyOverride.kt") { model ->
with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) {
assertEquals("xyzzy", name)
- val override = references(DocumentationReference.Kind.Override).single().to
+ val override = references(RefKind.Override).single().to
assertEquals("xyzzy", override.name)
assertEquals("Foo", override.owner!!.name)
}