diff options
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 14 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 0cc17d1f..57f8572f 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -8,6 +8,7 @@ import org.jetbrains.jet.lang.resolve.name.* import org.jetbrains.jet.lang.resolve.lazy.* import org.jetbrains.jet.lang.descriptors.annotations.Annotated import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.jet.lang.resolve.DescriptorUtils public data class DocumentationOptions(val includeNonPublic: Boolean = false) @@ -75,11 +76,20 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati fun DocumentationNode.appendSupertypes(descriptor: ClassDescriptor) { val superTypes = descriptor.getTypeConstructor().getSupertypes() for (superType in superTypes) { - if (superType.toString() != "Any") + if (!ignoreSupertype(superType)) appendType(superType, DocumentationNode.Kind.Supertype) } } + private fun ignoreSupertype(superType: JetType): Boolean { + val superClass = superType.getConstructor()?.getDeclarationDescriptor() as? ClassDescriptor + if (superClass != null) { + val fqName = DescriptorUtils.getFqNameSafe(superClass).asString() + return fqName == "kotlin.Annotation" || fqName == "kotlin.Enum" || fqName == "kotlin.Any" + } + return false + } + fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) { val prefix = when (projection.getProjectionKind()) { Variance.IN_VARIANCE -> "in " @@ -161,6 +171,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati ClassKind.CLASS_OBJECT -> Kind.Object ClassKind.TRAIT -> Kind.Interface ClassKind.ENUM_CLASS -> Kind.Enum + ClassKind.ANNOTATION_CLASS -> Kind.AnnotationClass ClassKind.ENUM_ENTRY -> Kind.EnumItem else -> Kind.Class } @@ -267,7 +278,6 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati val constraintNode = DocumentationNode(constraint.toString(), Content.Empty, DocumentationNode.Kind.LowerBound) node.append(constraintNode, DocumentationReference.Kind.Detail) } - node.appendAnnotations(this) return node } diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index 1e5edf4d..0538ba74 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -14,6 +14,7 @@ class KotlinLanguageService : LanguageService { DocumentationNode.Kind.Interface, DocumentationNode.Kind.Enum, DocumentationNode.Kind.EnumItem, + DocumentationNode.Kind.AnnotationClass, DocumentationNode.Kind.Object -> renderClass(node) DocumentationNode.Kind.TypeParameter -> renderTypeParameter(node) @@ -181,6 +182,7 @@ class KotlinLanguageService : LanguageService { DocumentationNode.Kind.Class -> keyword("class ") DocumentationNode.Kind.Interface -> keyword("trait ") DocumentationNode.Kind.Enum -> keyword("enum class ") + DocumentationNode.Kind.AnnotationClass -> keyword("annotation class ") DocumentationNode.Kind.EnumItem -> keyword("enum val ") DocumentationNode.Kind.Object -> keyword("object ") else -> throw IllegalArgumentException("Node $node is not a class-like object") |