aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2021-04-06 15:34:39 +0200
committerGitHub <noreply@github.com>2021-04-06 15:34:39 +0200
commit6b2e9382a298045c1d3c39bdb3c33cdc0eebf38d (patch)
tree978d2cac1d7cd91f322fff2da8186797aadde5b9 /plugins/base/src/main
parent6756bad5e9d5ebd996275e17bc3ea4f07aea54f4 (diff)
downloaddokka-6b2e9382a298045c1d3c39bdb3c33cdc0eebf38d.tar.gz
dokka-6b2e9382a298045c1d3c39bdb3c33cdc0eebf38d.tar.bz2
dokka-6b2e9382a298045c1d3c39bdb3c33cdc0eebf38d.zip
Fix some compiler warnings (#1812)
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt55
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt3
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt14
4 files changed, 37 insertions, 39 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 2a0af90c..f0d86b97 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -52,7 +52,7 @@ open class HtmlRenderer(
val sorted = strategy.sort(tabs)
if (sorted.size != tabs.size)
context.logger.warn("Tab sorting strategy has changed number of tabs from ${tabs.size} to ${sorted.size}")
- return sorted;
+ return sorted
}
override fun FlowContent.wrapGroup(
@@ -68,7 +68,7 @@ open class HtmlRenderer(
val firstLevel = node.children.filterIsInstance<ContentHeader>().flatMap { it.children }
.filterIsInstance<ContentText>()
- val renderable = firstLevel.union(secondLevel).let { sortTabs(tabSortingStrategy, it) }
+ val renderable = sortTabs(tabSortingStrategy, firstLevel.union(secondLevel))
div(classes = "tabs-section") {
attributes["tabs-section"] = "tabs-section"
@@ -84,7 +84,7 @@ open class HtmlRenderer(
childrenCallback()
}
}
- node.hasStyle(ContentStyle.WithExtraAttributes) -> div() {
+ node.hasStyle(ContentStyle.WithExtraAttributes) -> div {
node.extra.extraHtmlAttributes().forEach { attributes[it.extraKey] = it.extraValue }
childrenCallback()
}
@@ -93,13 +93,13 @@ open class HtmlRenderer(
if (node.hasStyle(TextStyle.Monospace)) copyButton()
}
node.hasStyle(TextStyle.BreakableAfter) -> {
- span() { childrenCallback() }
+ span { childrenCallback() }
wbr { }
}
node.hasStyle(TextStyle.Breakable) -> {
span("breakable-word") { childrenCallback() }
}
- node.hasStyle(TextStyle.Span) -> span() { childrenCallback() }
+ node.hasStyle(TextStyle.Span) -> span { childrenCallback() }
node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() }
node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() }
node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { //TODO this can be removed
@@ -152,11 +152,6 @@ open class HtmlRenderer(
}
}
- fun FlowContent.withHtml(content: String): Unit = when (this) {
- is HTMLTag -> unsafe { +content }
- else -> div { unsafe { +content } }
- }
-
override fun FlowContent.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
@@ -245,22 +240,24 @@ open class HtmlRenderer(
override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) {
val distinct =
- node.groupDivergentInstances(pageContext, { instance, contentPage, sourceSet ->
- createHTML(prettyPrint = false).prepareForTemplates().div {
- instance.before?.let { before ->
- buildContentNode(before, pageContext, sourceSet)
- }
- }.stripDiv()
- }, { instance, contentPage, sourceSet ->
- createHTML(prettyPrint = false).prepareForTemplates().div {
- instance.after?.let { after ->
- buildContentNode(after, pageContext, sourceSet)
- }
- }.stripDiv()
- })
+ node.groupDivergentInstances(pageContext,
+ beforeTransformer = { instance, _, sourceSet ->
+ createHTML(prettyPrint = false).prepareForTemplates().div {
+ instance.before?.let { before ->
+ buildContentNode(before, pageContext, sourceSet)
+ }
+ }.stripDiv()
+ },
+ afterTransformer = { instance, _, sourceSet ->
+ createHTML(prettyPrint = false).prepareForTemplates().div {
+ instance.after?.let { after ->
+ buildContentNode(after, pageContext, sourceSet)
+ }
+ }.stripDiv()
+ })
- distinct.forEach {
- val groupedDivergent = it.value.groupBy { it.second }
+ distinct.forEach { distinctInstances ->
+ val groupedDivergent = distinctInstances.value.groupBy { it.second }
consumer.onTagContentUnsafe {
+createHTML().prepareForTemplates().div("divergent-group") {
@@ -279,7 +276,7 @@ open class HtmlRenderer(
consumer.onTagContentUnsafe {
+createHTML().prepareForTemplates().div("with-platform-tags") {
- consumer.onTagContentUnsafe { +it.key.first }
+ consumer.onTagContentUnsafe { +distinctInstances.key.first }
consumer.onTagContentUnsafe {
+createHTML().prepareForTemplates().span("pull-right") {
@@ -296,12 +293,12 @@ open class HtmlRenderer(
if (node.implicitlySourceSetHinted) {
buildPlatformDependent(divergentForPlatformDependent, pageContext)
} else {
- it.value.forEach {
+ distinctInstances.value.forEach {
buildContentNode(it.first.divergent, pageContext, setOf(it.second))
}
}
}
- consumer.onTagContentUnsafe { +it.key.second }
+ consumer.onTagContentUnsafe { +distinctInstances.key.second }
}
}
}
@@ -492,7 +489,7 @@ open class HtmlRenderer(
private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DisplaySourceSet>, cssClasses: String = "") {
if (shouldRenderSourceSetBubbles) {
- div("platform-tags " + cssClasses) {
+ div("platform-tags $cssClasses") {
sourceSets.sortedBy { it.name }.forEach {
div("platform-tag") {
when (it.platform.key) {
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
index 1fb7b960..a9b99840 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ActualTypealiasAdder.kt
@@ -8,8 +8,8 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer
class ActualTypealiasAdder : DocumentableTransformer {
- override fun invoke(modules: DModule, context: DokkaContext) = modules.generateTypealiasesMap().let { aliases ->
- modules.copy(packages = modules.packages.map { it.copy(classlikes = addActualTypeAliasToClasslikes(it.classlikes, aliases)) })
+ override fun invoke(original: DModule, context: DokkaContext) = original.generateTypealiasesMap().let { aliases ->
+ original.copy(packages = original.packages.map { it.copy(classlikes = addActualTypeAliasToClasslikes(it.classlikes, aliases)) })
}
private fun DModule.generateTypealiasesMap(): Map<DRI, DTypeAlias> =
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 07e52851..c611927c 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -71,7 +71,8 @@ open class DefaultPageCreator(
private fun <T> T.toClashedName() where T : Documentable, T : WithExtraProperties<T> =
(extra[ClashingDriIdentifier]?.value?.joinToString(", ", "[", "]") { it.displayName } ?: "") + name.orEmpty()
- private fun <T> List<T>.renameClashingDocumentable(): List<T> where T : Documentable =
+ @Suppress("UNCHECKED_CAST")
+ private fun <T : Documentable> List<T>.renameClashingDocumentable(): List<T> =
groupBy { it.dri }.values.flatMap { elements ->
if (elements.size == 1) elements else elements.mapNotNull { element ->
when (element) {
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 14d57df0..84510824 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -172,15 +172,15 @@ class DefaultPsiToDocumentableTranslator(
methods.asIterable().parallelForEach { superMethodsKeys.add(it.hash) }
fun parseSupertypes(superTypes: Array<PsiClassType>, level: Int = 0) { // TODO: Rewrite it
if (superTypes.isEmpty()) return
- val parsedClasses = superTypes.filter { !it.shouldBeIgnored }.mapNotNull { psi ->
- psi.resolve()?.let { psiClass ->
- val (dri, javaClassKind) = when {
- psiClass.isInterface -> DRI.from(psiClass) to JavaClassKindTypes.INTERFACE
- else -> DRI.from(psiClass) to JavaClassKindTypes.CLASS
+ val parsedClasses = superTypes.filter { !it.shouldBeIgnored }.mapNotNull { supertypePsi ->
+ supertypePsi.resolve()?.let { supertypePsiClass ->
+ val (supertypeDri, javaClassKind) = when {
+ supertypePsiClass.isInterface -> DRI.from(supertypePsiClass) to JavaClassKindTypes.INTERFACE
+ else -> DRI.from(supertypePsiClass) to JavaClassKindTypes.CLASS
}
GenericTypeConstructor(
- dri,
- psi.parameters.map(::getProjection)
+ supertypeDri,
+ supertypePsi.parameters.map(::getProjection)
) to javaClassKind
}
}