Can't add import for using with '*' in settings (KT-22570)
#KT-22570 Fixed
This commit is contained in:
@@ -65,7 +65,7 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane
|
|||||||
private val starImportPackageEntryTable = PackageEntryTable()
|
private val starImportPackageEntryTable = PackageEntryTable()
|
||||||
private val dummyImportLayoutPanel = object : ImportLayoutPanel() {
|
private val dummyImportLayoutPanel = object : ImportLayoutPanel() {
|
||||||
override fun areStaticImportsEnabled() = false
|
override fun areStaticImportsEnabled() = false
|
||||||
override fun refresh() { }
|
override fun refresh() {}
|
||||||
}
|
}
|
||||||
private val starImportPackageTable = ImportLayoutPanel.createTableForPackageEntries(starImportPackageEntryTable, dummyImportLayoutPanel)
|
private val starImportPackageTable = ImportLayoutPanel.createTableForPackageEntries(starImportPackageEntryTable, dummyImportLayoutPanel)
|
||||||
|
|
||||||
@@ -109,15 +109,11 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun apply(settings: KotlinCodeStyleSettings, dropEmptyPackages: Boolean = true) {
|
fun apply(settings: KotlinCodeStyleSettings) {
|
||||||
settings.NAME_COUNT_TO_USE_STAR_IMPORT = nameCountToUseStarImportSelector.value
|
settings.NAME_COUNT_TO_USE_STAR_IMPORT = nameCountToUseStarImportSelector.value
|
||||||
settings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS = nameCountToUseStarImportForMembersSelector.value
|
settings.NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS = nameCountToUseStarImportForMembersSelector.value
|
||||||
settings.IMPORT_NESTED_CLASSES = cbImportNestedClasses.isSelected
|
settings.IMPORT_NESTED_CLASSES = cbImportNestedClasses.isSelected
|
||||||
|
settings.PACKAGES_TO_USE_STAR_IMPORTS.copyFrom(getCopyWithoutEmptyPackages(starImportPackageEntryTable))
|
||||||
if (dropEmptyPackages) {
|
|
||||||
starImportPackageEntryTable.removeEmptyPackages()
|
|
||||||
}
|
|
||||||
settings.PACKAGES_TO_USE_STAR_IMPORTS.copyFrom(starImportPackageEntryTable)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isModified(settings: KotlinCodeStyleSettings): Boolean {
|
fun isModified(settings: KotlinCodeStyleSettings): Boolean {
|
||||||
@@ -126,7 +122,7 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane
|
|||||||
isModified = isModified || nameCountToUseStarImportSelector.value != NAME_COUNT_TO_USE_STAR_IMPORT
|
isModified = isModified || nameCountToUseStarImportSelector.value != NAME_COUNT_TO_USE_STAR_IMPORT
|
||||||
isModified = isModified || nameCountToUseStarImportForMembersSelector.value != NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS
|
isModified = isModified || nameCountToUseStarImportForMembersSelector.value != NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS
|
||||||
isModified = isModified || isModified(cbImportNestedClasses, IMPORT_NESTED_CLASSES)
|
isModified = isModified || isModified(cbImportNestedClasses, IMPORT_NESTED_CLASSES)
|
||||||
isModified = isModified || isModified(starImportPackageEntryTable, PACKAGES_TO_USE_STAR_IMPORTS)
|
isModified = isModified || isModified(getCopyWithoutEmptyPackages(starImportPackageEntryTable), PACKAGES_TO_USE_STAR_IMPORTS)
|
||||||
|
|
||||||
isModified
|
isModified
|
||||||
}
|
}
|
||||||
@@ -152,6 +148,16 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCopyWithoutEmptyPackages(table: PackageEntryTable): PackageEntryTable {
|
||||||
|
try {
|
||||||
|
val copy = table.clone() as PackageEntryTable
|
||||||
|
copy.removeEmptyPackages()
|
||||||
|
return copy
|
||||||
|
} catch (ignored: CloneNotSupportedException) {
|
||||||
|
throw IllegalStateException("Clone should be supported")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NameCountToUseStarImportSelector(title: String) : OptionGroup(title) {
|
private class NameCountToUseStarImportSelector(title: String) : OptionGroup(title) {
|
||||||
@@ -193,17 +199,17 @@ class ImportSettingsPanel(private val commonSettings: CodeStyleSettings) : JPane
|
|||||||
else -> starImportLimitModel.number as Int
|
else -> starImportLimitModel.number as Int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
when (value) {
|
when (value) {
|
||||||
Int.MAX_VALUE -> rbUseSingleImports.isSelected = true
|
Int.MAX_VALUE -> rbUseSingleImports.isSelected = true
|
||||||
|
|
||||||
1 -> rbUseStarImports.isSelected = true
|
1 -> rbUseStarImports.isSelected = true
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
rbUseStarImportsIfAtLeast.isSelected = true
|
rbUseStarImportsIfAtLeast.isSelected = true
|
||||||
starImportLimitField.value = value
|
starImportLimitField.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user