From ba77d9b5349a80deef35cfa2832ae27944c3d3ae Mon Sep 17 00:00:00 2001 From: Nikolay Rykunov Date: Thu, 2 Nov 2023 17:04:47 +0100 Subject: [PATCH] Cleanup code for lint checks --- .../jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt | 1 - .../jewel/foundation/lazy/SelectableLazyColumn.kt | 1 - .../jewel/foundation/lazy/SelectableLazyListScope.kt | 8 ++------ .../jewel/foundation/lazy/SelectableLazyColumnTest.kt | 1 - .../samples/standalone/view/component/ChipsAndTree.kt | 2 +- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt index 52d269b5c..0307a7b4e 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableColumnOnKeyEvent.kt @@ -1,7 +1,6 @@ package org.jetbrains.jewel.foundation.lazy import org.jetbrains.jewel.foundation.lazy.SelectableLazyListKey.Selectable -import java.util.Collections.addAll import kotlin.math.max import kotlin.math.min diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumn.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumn.kt index 81afdd871..4c4568230 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumn.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumn.kt @@ -26,7 +26,6 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.pointer.PointerEventType import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.unit.dp -import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import org.jetbrains.jewel.foundation.lazy.SelectableLazyListScopeContainer.Entry import org.jetbrains.jewel.foundation.lazy.tree.DefaultSelectableLazyColumnEventAction diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt index 747264536..70daa6189 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyListScope.kt @@ -104,13 +104,9 @@ internal class SelectableLazyListScopeContainer : SelectableLazyListScope { ) : Entry } - internal fun getKeyIndex(key: Any): Int { - return keyToIndex[key] ?: error("Cannot find index of '$key'") - } + internal fun getKeyIndex(key: Any): Int = keyToIndex[key] ?: error("Cannot find index of '$key'") - internal fun isKeySelectable(key: Any): Boolean { - return key !in nonSelectableKeys - } + internal fun isKeySelectable(key: Any): Boolean = key !in nonSelectableKeys override fun item( key: Any, diff --git a/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumnTest.kt b/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumnTest.kt index 28cce64b9..77615063c 100644 --- a/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumnTest.kt +++ b/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumnTest.kt @@ -237,7 +237,6 @@ internal class SelectableLazyColumnTest { assertEquals(expectedElementsAfterPageUp.size, state.selectedKeys.size) assertEquals(expectedElementsAfterPageUp.toSet(), state.selectedKeys.toSet()) - // select item 5 by click composeRule.onNodeWithTag("Item 5").assertExists() composeRule.onNodeWithTag("Item 5").performClick() diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/ChipsAndTree.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/ChipsAndTree.kt index 0622d90bb..1acd4141f 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/ChipsAndTree.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/ChipsAndTree.kt @@ -67,7 +67,7 @@ fun SelectableLazyColumnSample() { val interactionSource = remember { MutableInteractionSource() } val state = rememberSelectableLazyListState() Box( - modifier = Modifier.size(200.dp, 200.dp) + modifier = Modifier.size(200.dp, 200.dp), ) { SelectableLazyColumn( modifier = Modifier.focusable(interactionSource = interactionSource),