diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-10-12 22:35:47 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-10-12 22:35:47 +0400 |
commit | 11355cefc9f6856054cb3760d2a339f40d22dae3 (patch) | |
tree | 8b3abf314cd517c7c0136ad5a2334b2140d69cf7 /test/src | |
parent | cf272252a8e62d7b212e9025065a8bce4f514946 (diff) | |
download | dokka-11355cefc9f6856054cb3760d2a339f40d22dae3.tar.gz dokka-11355cefc9f6856054cb3760d2a339f40d22dae3.tar.bz2 dokka-11355cefc9f6856054cb3760d2a339f40d22dae3.zip |
Convert visitors to top-down builder
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/TestAPI.kt | 18 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 28 |
2 files changed, 23 insertions, 23 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index 309654e5..fcff75e9 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -27,18 +27,22 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> addSources(files.toList()) } - val documentation = environment.withContext<DocumentationModule> { environment, module, context -> - val packageSet = environment.getSourceFiles().map { file -> - context.getPackageFragment(file)!!.fqName - }.toSet() + val options = DocumentationOptions(includeNonPublic = true) - context.createDocumentationModule("test", module, packageSet, DocumentationOptions(includeNonPublic = true)) + val documentation = environment.withContext { environment, module, context -> + val documentationModule = DocumentationModule("test") + val documentationBuilder = DocumentationBuilder(context, options) + with(documentationBuilder) { + documentationModule.appendFiles(environment.getSourceFiles()) + } + documentationBuilder.resolveReferences(documentationModule) + documentationModule } verifier(documentation) Disposer.dispose(environment) } -fun StringBuilder.appendChildren(node: ContentNode) : StringBuilder { +fun StringBuilder.appendChildren(node: ContentNode): StringBuilder { for (child in node.children) { val childText = child.toTestString() append(childText) @@ -46,7 +50,7 @@ fun StringBuilder.appendChildren(node: ContentNode) : StringBuilder { return this } -fun StringBuilder.appendNode(node: ContentNode) : StringBuilder { +fun StringBuilder.appendNode(node: ContentNode): StringBuilder { when (node) { is ContentText -> { append(node.text) diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index ed49bd6b..cac62194 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -58,18 +58,10 @@ public class PropertyTest { assertEquals(DocumentationNode.Kind.Property, kind) assertEquals(Content.Empty, doc) assertEquals(3, details.count()) - with(details.elementAt(0)) { - assertEquals(DocumentationNode.Kind.Type, kind) - assertEquals("String", name) - } - with(details.elementAt(1)) { - assertEquals(DocumentationNode.Kind.Modifier, kind) - assertEquals("final", name) - } - with(details.elementAt(2)) { - assertEquals(DocumentationNode.Kind.Modifier, kind) - assertEquals("internal", name) - } + assertEquals("String", detail(DocumentationNode.Kind.Type).name) + val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } + assertTrue("final" in modifiers) + assertTrue("internal" in modifiers) assertTrue(links.none()) assertEquals(2, members.count()) @@ -77,6 +69,9 @@ public class PropertyTest { assertEquals("<get-property>", name) assertEquals(DocumentationNode.Kind.Function, kind) assertEquals(Content.Empty, doc) + val get_modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } + assertTrue("final" in get_modifiers) + assertTrue("internal" in get_modifiers) assertEquals("String", detail(DocumentationNode.Kind.Type).name) assertTrue(links.none()) assertTrue(members.none()) @@ -86,10 +81,11 @@ public class PropertyTest { assertEquals(DocumentationNode.Kind.Function, kind) assertEquals(Content.Empty, doc) assertEquals(4, details.count()) - assertEquals("Unit", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - assertEquals("internal", details.elementAt(2).name) - with(details.elementAt(3)) { + assertEquals("Unit", detail(DocumentationNode.Kind.Type).name) + val set_modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } + assertTrue("final" in set_modifiers) + assertTrue("internal" in set_modifiers) + with(detail(DocumentationNode.Kind.Parameter)) { assertEquals("value", name) assertEquals(DocumentationNode.Kind.Parameter, kind) assertEquals(Content.Empty, doc) |