diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 5 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 14 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 2 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 1 |
4 files changed, 19 insertions, 3 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 2d326854..b75f39d1 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -188,7 +188,8 @@ public abstract class StructuredFormatService(val locationService: LocationServi DocumentationNode.Kind.Class, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Enum, - DocumentationNode.Kind.Object) + DocumentationNode.Kind.Object, + DocumentationNode.Kind.AnnotationClass) }, node, to) appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) @@ -200,7 +201,9 @@ public abstract class StructuredFormatService(val locationService: LocationServi 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, 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") diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 783dea1c..0698a5d0 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -64,6 +64,7 @@ public open class DocumentationNode(val name: String, Class Interface Enum + AnnotationClass EnumItem Object |