From 11355cefc9f6856054cb3760d2a339f40d22dae3 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Sun, 12 Oct 2014 22:35:47 +0400 Subject: Convert visitors to top-down builder --- test/src/TestAPI.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'test/src/TestAPI.kt') 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 { 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) -- cgit