From 821883e06af48d5557a12475d9f08ff1d5c39f1c Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 22 Apr 2019 21:58:19 +0200 Subject: Code style fixes. --- .../pl/treksoft/kvision/core/StyledComponent.kt | 3 +-- src/main/kotlin/pl/treksoft/kvision/core/Widget.kt | 1 + .../kotlin/pl/treksoft/kvision/form/FormPanel.kt | 2 +- .../kotlin/pl/treksoft/kvision/panel/SplitPanel.kt | 4 ++-- src/main/kotlin/pl/treksoft/kvision/table/Table.kt | 2 ++ src/main/kotlin/pl/treksoft/kvision/types/Date.kt | 2 +- src/main/kotlin/pl/treksoft/kvision/utils/Cache.kt | 26 +++++++++++----------- 7 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src/main/kotlin/pl/treksoft') diff --git a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt index 1207ba5e..aa3f26bb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt @@ -489,10 +489,9 @@ abstract class StyledComponent : Component { } protected open fun getCacheKey(): String { - val SEP = "###KvSep###" return propertyValues.map { it.toString() - }.joinToString(SEP) + }.joinToString("###KvSep###") } private fun refreshOnUpdate(refreshFunction: ((T) -> Unit) = { this.refresh() }) = diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index f0be38cb..7bbbcca3 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -637,6 +637,7 @@ open class Widget(classes: Set = setOf()) : StyledComponent() { /** * Internal method called after destroying Snabbdom vnode. */ + @Suppress("UnsafeCastFromDynamic") internal open fun afterDestroyInternal() { this.tooltipOptions?.let { getElementJQueryD().tooltip("destroy") diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt index 2b51c62e..21281556 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt @@ -402,7 +402,7 @@ open class FormPanel( type: FormType? = null, classes: Set = setOf(), noinline init: (FormPanel.() -> Unit)? = null ): FormPanel { - val formPanel = FormPanel.create(method, action, enctype, type, classes) + val formPanel = create(method, action, enctype, type, classes) init?.invoke(formPanel) this.add(formPanel) return formPanel diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index f3625e97..d3211d7a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -52,7 +52,7 @@ enum class Direction(internal val dir: String) { */ open class SplitPanel( private val direction: Direction = Direction.VERTICAL, - classes: Set = setOf(), init: (SplitPanel.() -> kotlin.Unit)? = null + classes: Set = setOf(), init: (SplitPanel.() -> Unit)? = null ) : SimplePanel(classes + ("splitpanel-" + direction.dir)) { @Suppress("LeakingThis") @@ -107,7 +107,7 @@ open class SplitPanel( */ fun Container.splitPanel( direction: Direction = Direction.VERTICAL, - classes: Set = setOf(), init: (SplitPanel.() -> kotlin.Unit)? = null + classes: Set = setOf(), init: (SplitPanel.() -> Unit)? = null ): SplitPanel { val splitPanel = SplitPanel(direction, classes, init) this.add(splitPanel) diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt index 68db05d3..967d8b1d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt @@ -82,7 +82,9 @@ open class Table( private val tbody = Tag(TAG.TBODY) init { + @Suppress("LeakingThis") thead.parent = this + @Suppress("LeakingThis") tbody.parent = this refreshHeaders() @Suppress("LeakingThis") diff --git a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt index dc8ea5f4..022eb6a0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt +++ b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -31,7 +31,7 @@ import kotlin.js.Date const val KV_DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss" -actual typealias Date = kotlin.js.Date +actual typealias Date = Date /** * Extension function to convert String to Date with a given date format. diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Cache.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Cache.kt index 6a473661..5b4306df 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Cache.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Cache.kt @@ -95,27 +95,27 @@ class LinkedList { fun last(): Node? { var node = head - if (node != null) { + return if (node != null) { while (node?.next != null) { node = node.next } - return node + node } else { - return null + null } } fun count(): Int { var node = head - if (node != null) { + return if (node != null) { var counter = 1 while (node?.next != null) { node = node.next counter += 1 } - return counter + counter } else { - return 0 + 0 } } @@ -167,19 +167,19 @@ class LinkedList { fun removeLast(): T? { val last = this.last() - if (last != null) { - return removeNode(last) + return if (last != null) { + removeNode(last) } else { - return null + null } } fun removeAtIndex(index: Int): T? { val node = nodeAtIndex(index) - if (node != null) { - return removeNode(node) + return if (node != null) { + removeNode(node) } else { - return null + null } } @@ -193,6 +193,6 @@ class LinkedList { s += ", " } } - return s + "]" + return "$s]" } } -- cgit