aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
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 /core/src/main/kotlin/Kotlin
parentfc13de8cedb956107b624ebb0a7e4c3544a504ca (diff)
downloaddokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.gz
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.bz2
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.zip
cleanup: DocumentationNode.Kind -> NodeKind, DocumentationReference.Kind -> RefKind
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-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
3 files changed, 120 insertions, 121 deletions
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) {