From f5b7797255576e5f1c230e2ca3fcb5f4e602387c Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 21 Feb 2022 22:01:06 +0800 Subject: Code cleanups (#2165) --- core/test-api/src/main/kotlin/testApi/context/MockContext.kt | 2 +- core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'core/test-api/src') diff --git a/core/test-api/src/main/kotlin/testApi/context/MockContext.kt b/core/test-api/src/main/kotlin/testApi/context/MockContext.kt index 7b17a8ee..7a3c4786 100644 --- a/core/test-api/src/main/kotlin/testApi/context/MockContext.kt +++ b/core/test-api/src/main/kotlin/testApi/context/MockContext.kt @@ -24,7 +24,7 @@ class MockContext( private val plugins = mutableMapOf, DokkaPlugin>() - override fun plugin(kclass: KClass): T? = plugins.getOrPut(kclass) { + override fun plugin(kclass: KClass): T = plugins.getOrPut(kclass) { kclass.constructors.single { it.parameters.isEmpty() }.call().also { it.injectContext(this) } } as T diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index c692c83f..de0cd896 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -99,14 +99,12 @@ abstract class AbstractTest, D : DokkaTestGe .replace("\r\n", "\n") .sliceAt(filePathRegex) .filter { it.isNotEmpty() && it.isNotBlank() && "\n" in it } - .map { fileDeclaration -> fileDeclaration.trim() } - .map { fileDeclaration -> + .map { fileDeclaration -> fileDeclaration.trim() }.associate { fileDeclaration -> val filePathAndContent = fileDeclaration.split("\n", limit = 2) val filePath = filePathAndContent.first().removePrefix("/").trim() val content = filePathAndContent.last().trim() filePath to content } - .toMap() } private fun String.sliceAt(regex: Regex): List { -- cgit