aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kotlin/DocumentationBuilder.kt20
-rw-r--r--src/Kotlin/KotlinLanguageService.kt15
-rw-r--r--test/data/format/typeProjectionVariance.kt1
-rw-r--r--test/data/format/typeProjectionVariance.md8
-rw-r--r--test/src/format/MarkdownFormatTest.kt6
5 files changed, 32 insertions, 18 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 7804fd72..da7552a7 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -212,12 +212,7 @@ class DocumentationBuilder(val session: ResolveSession,
}
fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) {
- val prefix = when (projection.getProjectionKind()) {
- Variance.IN_VARIANCE -> "in "
- Variance.OUT_VARIANCE -> "out "
- else -> ""
- }
- appendType(projection.getType(), kind, prefix)
+ appendType(projection.getType(), kind, projection.getProjectionKind().label)
}
fun DocumentationNode.appendType(jetType: JetType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") {
@@ -225,11 +220,14 @@ class DocumentationBuilder(val session: ResolveSession,
return
val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor()
val name = when (classifierDescriptor) {
- is Named -> prefix + classifierDescriptor.getName().asString() + if (jetType.isMarkedNullable()) "?" else ""
+ is Named -> classifierDescriptor.getName().asString() + if (jetType.isMarkedNullable()) "?" else ""
else -> "<anonymous>"
}
val node = DocumentationNode(name, Content.Empty, kind)
- if (classifierDescriptor != null)
+ if (prefix != "") {
+ node.appendTextNode(prefix, Kind.Modifier)
+ }
+ if (classifierDescriptor != null){}
link(node, classifierDescriptor)
append(node, DocumentationReference.Kind.Detail)
@@ -473,11 +471,7 @@ class DocumentationBuilder(val session: ResolveSession,
fun TypeParameterDescriptor.build(): DocumentationNode {
val doc = parseDocumentation(this)
val name = getName().asString()
- val prefix = when (getVariance()) {
- Variance.IN_VARIANCE -> "in"
- Variance.OUT_VARIANCE -> "out"
- else -> ""
- }
+ val prefix = getVariance().label
val node = DocumentationNode(name, doc, DocumentationNode.Kind.TypeParameter)
if (prefix != "") {
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index a4f62c3f..ab1f7016 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -104,6 +104,7 @@ class KotlinLanguageService : LanguageService {
renderType(typeArguments.last())
return
}
+ renderSingleModifier(node)
renderLinked(node) { identifier(it.name) }
if (typeArguments.any()) {
symbol("<")
@@ -125,11 +126,7 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderTypeParameter(node: DocumentationNode) {
- val modifier = node.details(DocumentationNode.Kind.Modifier).singleOrNull()
- if (modifier != null) {
- keyword(modifier.name)
- nbsp()
- }
+ renderSingleModifier(node)
identifier(node.name)
@@ -144,6 +141,14 @@ class KotlinLanguageService : LanguageService {
}
}
+ private fun ContentBlock.renderSingleModifier(node: DocumentationNode) {
+ val modifier = node.details(DocumentationNode.Kind.Modifier).singleOrNull()
+ if (modifier != null) {
+ keyword(modifier.name)
+ nbsp()
+ }
+ }
+
private fun ContentBlock.renderParameter(node: DocumentationNode) {
renderAnnotationsForNode(node)
identifier(node.name)
diff --git a/test/data/format/typeProjectionVariance.kt b/test/data/format/typeProjectionVariance.kt
new file mode 100644
index 00000000..85ee344d
--- /dev/null
+++ b/test/data/format/typeProjectionVariance.kt
@@ -0,0 +1 @@
+fun <T> Array<out T>.foo() {}
diff --git a/test/data/format/typeProjectionVariance.md b/test/data/format/typeProjectionVariance.md
new file mode 100644
index 00000000..9812ca3f
--- /dev/null
+++ b/test/data/format/typeProjectionVariance.md
@@ -0,0 +1,8 @@
+[test](test/index) / [Array](test/-array/index)
+
+
+### Extensions for Array
+
+
+| [foo](test/-array/foo) | `fun &lt;T&gt; Array&lt;out&nbsp;T&gt;.foo(): Unit` |
+
diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt
index b0c254ba..7e379cf9 100644
--- a/test/src/format/MarkdownFormatTest.kt
+++ b/test/src/format/MarkdownFormatTest.kt
@@ -116,4 +116,10 @@ public class MarkdownFormatTest {
markdownService.appendNodes(tempLocation, output, model.members.single().members)
}
}
+
+ Test fun typeProjectionVariance() {
+ verifyOutput("test/data/format/typeProjectionVariance.kt", ".md") { model, output ->
+ markdownService.appendNodes(tempLocation, output, model.members.single().members)
+ }
+ }
}