From b7764e9c31a581abde8df23387f4c738f2daee99 Mon Sep 17 00:00:00 2001 From: gcx11 Date: Sat, 25 Apr 2020 19:14:07 +0200 Subject: [PATCH] KT-10974 - small fixes --- .../idea/core/formatter/KotlinPackageEntry.kt | 13 ++++++++----- .../idea/formatter/BaseKotlinImportLayoutPanel.kt | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinPackageEntry.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinPackageEntry.kt index b46aedc101a66e..93f86c6459be4c 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinPackageEntry.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinPackageEntry.kt @@ -7,10 +7,12 @@ package org.jetbrains.kotlin.idea.core.formatter import org.jetbrains.kotlin.resolve.ImportPath -data class KotlinPackageEntry( - val packageName: String, +class KotlinPackageEntry( + packageName: String, val withSubpackages: Boolean ) { + val packageName = packageName.removeSuffix(".*") + companion object { @JvmField val ALL_OTHER_IMPORTS_ENTRY = KotlinPackageEntry("", withSubpackages = true) @@ -45,9 +47,10 @@ data class KotlinPackageEntry( return entry.packageName.count { it == '.' } < packageName.count { it == '.' } } - val isSpecial: Boolean get() { - return (this == ALL_OTHER_IMPORTS_ENTRY || this == ALL_OTHER_ALIAS_IMPORTS_ENTRY) - } + val isSpecial: Boolean + get() { + return (this == ALL_OTHER_IMPORTS_ENTRY || this == ALL_OTHER_ALIAS_IMPORTS_ENTRY) + } override fun toString(): String { return packageName diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/BaseKotlinImportLayoutPanel.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/BaseKotlinImportLayoutPanel.kt index 790d1a2a88da65..6c4e74ac367418 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/BaseKotlinImportLayoutPanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/BaseKotlinImportLayoutPanel.kt @@ -12,7 +12,6 @@ import com.intellij.openapi.application.ApplicationBundle import com.intellij.openapi.wm.IdeFocusManager import com.intellij.ui.* import com.intellij.ui.components.JBCheckBox -import com.intellij.ui.layout.selected import com.intellij.ui.table.JBTable import com.intellij.util.IconUtil import com.intellij.util.ui.JBUI @@ -292,7 +291,7 @@ fun createTableForPackageEntries(packageTable: KotlinPackageEntryTable): JBTable override fun getColumnClass(columnIndex: Int): Class<*> { return when (columnIndex) { 0 -> String::class.java - 1 -> Boolean::class.java + 1 -> Boolean::class.javaObjectType else -> throw IllegalArgumentException(columnIndex.toString()) } } @@ -302,7 +301,7 @@ fun createTableForPackageEntries(packageTable: KotlinPackageEntryTable): JBTable val newEntry = when (columnIndex) { 0 -> KotlinPackageEntry((value as String).trim(), entry.withSubpackages) - 1 -> KotlinPackageEntry(entry.packageName, (value as Boolean)) + 1 -> KotlinPackageEntry(entry.packageName, value.toString().toBoolean()) else -> throw IllegalArgumentException(columnIndex.toString()) }