diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-02-27 13:11:15 +0100 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2020-02-27 13:11:15 +0100 |
commit | 4705e788a52287b2eb1275253bad41f178d42df2 (patch) | |
tree | 4992ed604f6adedff81e99d52ff089652dde9ac9 /plugins/base/src/main/kotlin | |
parent | 463996144e99055203a0205700e7a5be5d970067 (diff) | |
download | dokka-4705e788a52287b2eb1275253bad41f178d42df2.tar.gz dokka-4705e788a52287b2eb1275253bad41f178d42df2.tar.bz2 dokka-4705e788a52287b2eb1275253bad41f178d42df2.zip |
Rename `actual` to `sources`
Diffstat (limited to 'plugins/base/src/main/kotlin')
2 files changed, 27 insertions, 26 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 64363078..68ee059d 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -71,8 +71,8 @@ private fun <T> mergeExpectActual( } fun analyzeExpectActual(sameDriElements: List<T>): List<T> { - val (expect, actual) = sameDriElements.partition { it.actual.expect != null } - val mergedExpect = expect.groupBy { it.actual.expect?.path }.values.map { e -> + val (expect, actual) = sameDriElements.partition { it.sources.expect != null } + val mergedExpect = expect.groupBy { it.sources.expect?.path }.values.map { e -> e.first().platformSetter(e.flatMap { it.platformData }.distinct()) } return actual.groupBy { findExpect(it, mergedExpect) }.flatMap { reduceExpectActual(it) } @@ -103,7 +103,7 @@ fun Function.mergeWith(other: Function) : Function = copy( parameters = merge(this.parameters + other.parameters, Parameter::mergeWith), receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct(), generics = merge(generics + other.generics, TypeParameter::mergeWith) @@ -112,7 +112,7 @@ fun Function.mergeWith(other: Function) : Function = copy( fun Property.mergeWith(other: Property): Property = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct(), getter = getter?.let { g -> other.getter?.let { g.mergeWith(it) } ?: g } ?: other.getter, @@ -145,7 +145,7 @@ fun Class.mergeWith(other: Class): Class = copy( generics = merge(generics + other.generics, TypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) @@ -159,7 +159,7 @@ fun Enum.mergeWith(other: Enum): Enum = copy( companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) @@ -178,7 +178,7 @@ fun Object.mergeWith(other: Object): Object = copy( classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) @@ -191,7 +191,7 @@ fun Interface.mergeWith(other: Interface): Interface = copy( generics = merge(generics + other.generics, TypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) @@ -203,7 +203,7 @@ fun Annotation.mergeWith(other: Annotation): Annotation = copy( classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, documentation = documentation.mergeWith(other.documentation), - actual = actual.mergeWith(other.actual), + sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 895690c2..531537a4 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -96,7 +96,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), classlikes = scope.classlikes(driWithPlatform), - actual = descriptor.actual(platformData, descriptor), + sources = descriptor.createSources(), visibility = PlatformDependent.from(platformData, descriptor.visibility), supertypes = PlatformDependent.from(platformData, info.supertypes), documentation = info.docs, @@ -117,7 +117,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), classlikes = scope.classlikes(driWithPlatform), - actual = descriptor.actual(platformData, descriptor), + sources = descriptor.createSources(), visibility = PlatformDependent(mapOf(platformData to descriptor.visibility)), supertypes = PlatformDependent.from(platformData, info.supertypes), documentation = info.docs, @@ -138,7 +138,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), classlikes = scope.classlikes(driWithPlatform), - actual = descriptor.actual(platformData, descriptor), + sources = descriptor.createSources(), visibility = PlatformDependent(mapOf(platformData to descriptor.visibility)), supertypes = PlatformDependent.from(platformData, info.supertypes), documentation = info.docs, @@ -166,7 +166,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - val actual = descriptor.actual(platformData, descriptor) + val actual = descriptor.createSources() return Class( dri = driWithPlatform.dri, @@ -181,7 +181,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), classlikes = scope.classlikes(driWithPlatform), - actual = actual, + sources = actual, visibility = PlatformDependent.from(platformData, descriptor.visibility), generics = descriptor.typeConstructor.parameters.map { it.toTypeParameter() }, documentation = info.docs, @@ -195,14 +195,14 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { val dri = parent.dri.copy(callable = Callable.from(descriptor)) - val actual = descriptor.actual(platformData, descriptor) + val actual = descriptor.createSources() return Property( dri = dri, name = descriptor.name.asString(), receiver = descriptor.extensionReceiverParameter?.let { visitReceiverParameterDescriptor(it, DRIWithPlatformInfo(dri, actual)) }, - actual = actual, + sources = actual, getter = descriptor.accessors.filterIsInstance<PropertyGetterDescriptor>().singleOrNull()?.let { visitPropertyAccessorDescriptor(it, descriptor, dri) }!!, @@ -220,7 +220,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { val dri = parent.dri.copy(callable = Callable.from(descriptor)) - val actual = descriptor.actual(platformData, descriptor) + val actual = descriptor.createSources() return Function( dri = dri, name = descriptor.name.asString(), @@ -231,7 +231,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private parameters = descriptor.valueParameters.mapIndexed { index, desc -> parameter(index, desc, DRIWithPlatformInfo(dri, actual)) }, - actual = actual, + sources = actual, visibility = PlatformDependent.from(platformData, descriptor.visibility), generics = descriptor.typeParameters.map { it.toTypeParameter() }, documentation = descriptor.resolveDescriptorData(platformData), @@ -243,7 +243,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { val dri = parent.dri.copy(callable = Callable.from(descriptor)) - val actual = descriptor.actual(platformData, descriptor) + val actual = descriptor.createSources() return Function( dri = dri, name = "<init>", @@ -254,7 +254,7 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private parameters = descriptor.valueParameters.mapIndexed { index, desc -> parameter(index, desc, DRIWithPlatformInfo(dri, actual)) }, - actual = actual, + sources = actual, visibility = PlatformDependent(mapOf(platformData to descriptor.visibility)), documentation = descriptor.resolveDescriptorData(platformData), type = KotlinTypeWrapper(descriptor.returnType), @@ -318,10 +318,10 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private receiver = descriptor.extensionReceiverParameter?.let { visitReceiverParameterDescriptor( it, - DRIWithPlatformInfo(dri, descriptor.actual(platformData, descriptor)) + DRIWithPlatformInfo(dri, descriptor.createSources()) ) }, - actual = descriptor.actual(platformData, descriptor), + sources = descriptor.createSources(), platformData = listOf(platformData) ) } @@ -413,10 +413,11 @@ open class DokkaDescriptorVisitor( // TODO: close this class and make it private else -> WithAbstraction.Modifier.Empty } - fun MemberDescriptor.actual(platformData: PlatformData, expected: DeclarationDescriptor? = null) = - this.takeIf { it.isActual }?.let { DescriptorDocumentableSource(it) }?.let { - PlatformDependent(mapOf(platformData to it), expected?.let { DescriptorDocumentableSource(it) }) - }.orEmpty() + private fun MemberDescriptor.createSources(): PlatformDependent<DocumentableSource> = if(isExpect()) { + PlatformDependent(emptyMap(), DescriptorDocumentableSource(this)) + } else { + PlatformDependent(mapOf(platformData to DescriptorDocumentableSource(this))) + } data class ClassInfo(val supertypes: List<DRI>, val docs: PlatformDependent<DocumentationNode>) } |