From 2308016b143cf8c0c5f216f7eb5975b77ef552a5 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Fri, 21 Feb 2020 15:52:38 +0100 Subject: Fix descriptor to documentable translator --- core/src/main/kotlin/model/Documentable.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/src/main/kotlin/model/Documentable.kt') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 73a5f9d3..337bddc5 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -47,7 +47,8 @@ data class PlatformDependent( get() = map.values.distinct().singleOrNull() companion object { - fun empty() = PlatformDependent(mapOf()) + fun empty(): PlatformDependent = PlatformDependent(emptyMap()) + fun from(platformData: PlatformData, element: T) = PlatformDependent(mapOf(platformData to element)) } } @@ -77,7 +78,7 @@ interface WithAbstraction { val modifier: Modifier? enum class Modifier { - Abstract, Open, Final, Static + Abstract, Open, Final, Sealed, Empty } } @@ -345,6 +346,7 @@ fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } +fun PlatformDependent?.orEmpty(): PlatformDependent = this ?: PlatformDependent.empty() sealed class DocumentableSource(val path: String) class DescriptorDocumentableSource(val descriptor: DeclarationDescriptor) : -- cgit