mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] Fix import action title for function imported from different classes
#KTIJ-20617 GitOrigin-RevId: f24e4adf799c2cf7f67132c508cf3585a5a8de42
This commit is contained in:
committed by
intellij-monorepo-bot
parent
82abefb21c
commit
4b01e453d4
+5
@@ -590,6 +590,11 @@ public abstract class HighLevelQuickFixMultiFileTestGenerated extends AbstractHi
|
||||
runTest("../idea/tests/testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFunctionCandidate.test")
|
||||
public void testMultiFunctionCandidate() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/autoImports/multiFunctionCandidate.test");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.before.Main.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/autoImports/nestedClass.before.Main.kt");
|
||||
|
||||
@@ -186,8 +186,24 @@ internal abstract class ImportFixBase<T : KtExpression> protected constructor(
|
||||
} else {
|
||||
KotlinBundle.message("fix.import.kind.0.name.1.2", kind.toText(size), firstName, size - 1)
|
||||
}
|
||||
} else {
|
||||
} else if (kind.groupedByPackage) {
|
||||
KotlinBundle.message("fix.import.kind.0.name.1.2", kind.toText(1), firstName, 0)
|
||||
} else {
|
||||
val groupBy = sortedNames.map { it.name }.toSortedSet().groupBy {
|
||||
val endIndex = it.indexOf(".")
|
||||
if (endIndex > 0) it.substring(0, endIndex) else it
|
||||
}
|
||||
val value = groupBy.entries.first().value
|
||||
val first = value.first()
|
||||
val multiple = if (value.size == 1) 0 else 1
|
||||
if (groupBy.size == 1) {
|
||||
if (value.size == 2) {
|
||||
KotlinBundle.message("fix.import.kind.0.name.1.and.name.2", kind.toText(value.size), first, value.last())
|
||||
} else
|
||||
KotlinBundle.message("fix.import.kind.0.name.1.2", kind.toText(1), first, multiple)
|
||||
} else {
|
||||
KotlinBundle.message("fix.import.kind.0.name.1.2", kind.toText(1), first.substring(first.indexOf(".") + 1), multiple)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
KotlinBundle.message("fix.import")
|
||||
@@ -196,10 +212,10 @@ internal abstract class ImportFixBase<T : KtExpression> protected constructor(
|
||||
|
||||
private class ImportName(val kind: ImportKind, val name: String, val priority: ComparablePriority)
|
||||
|
||||
private enum class ImportKind(private val key: String) {
|
||||
CLASS("text.class.0"),
|
||||
private enum class ImportKind(private val key: String, val groupedByPackage: Boolean = false) {
|
||||
CLASS("text.class.0", true),
|
||||
PROPERTY("text.property.0"),
|
||||
OBJECT("text.object.0"),
|
||||
OBJECT("text.object.0", true),
|
||||
FUNCTION("text.function.0"),
|
||||
EXTENSION_PROPERTY("text.extension.property.0"),
|
||||
EXTENSION_FUNCTION("text.extension.function.0");
|
||||
|
||||
+5
@@ -693,6 +693,11 @@ public abstract class QuickFixMultiFileTestGenerated extends AbstractQuickFixMul
|
||||
runTest("testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFunctionCandidate.test")
|
||||
public void testMultiFunctionCandidate() throws Exception {
|
||||
runTest("testData/quickfix/autoImports/multiFunctionCandidate.test");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.before.Main.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("testData/quickfix/autoImports/nestedClass.before.Main.kt");
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import extension function 'Some.component1'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
@@ -36,7 +36,7 @@ operator fun Some.component2() = 3
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import extension function 'Some.component1'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import extension function 'Some.component1'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
@@ -35,7 +35,7 @@ operator fun Some.component1() = 1
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import extension function 'Some.component1'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import extension function 'Some.component2'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
@@ -37,7 +37,7 @@ operator fun Some.component2() = 3
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import extension function 'Some.component2'" "true"
|
||||
// "Import extension functions 'Some.component1', 'Some.component2'" "true"
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
|
||||
// ERROR: Destructuring declaration initializer of type Some must have a 'component2()' function
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import function 'min'" "true"
|
||||
// ERROR: Unresolved reference: min
|
||||
// WITH_STDLIB
|
||||
/* IGNORE_FIR */
|
||||
|
||||
package testing
|
||||
|
||||
fun testing() {
|
||||
val x = <caret>min(1, 2)
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import function 'min'" "true"
|
||||
// ERROR: Unresolved reference: min
|
||||
// WITH_STDLIB
|
||||
/* IGNORE_FIR */
|
||||
|
||||
package testing
|
||||
|
||||
import java.util.Collections.min
|
||||
|
||||
fun testing() {
|
||||
val x = <caret>min(1, 2)
|
||||
}
|
||||
//-----------------------
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// FILE: first.before.kt
|
||||
// "Import extension function 'Some.plusAssign'" "true"
|
||||
// "Import extension functions 'Some.plus', 'Some.plusAssign'" "true"
|
||||
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun String?.plus(other: Any?): String defined in kotlin
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -31,7 +31,7 @@ operator fun Some.plus(i: Int) : Some = this
|
||||
|
||||
|
||||
// FILE: first.after.kt
|
||||
// "Import extension function 'Some.plusAssign'" "true"
|
||||
// "Import extension functions 'Some.plus', 'Some.plusAssign'" "true"
|
||||
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun String?.plus(other: Any?): String defined in kotlin
|
||||
/* IGNORE_FIR */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user