From 8a4ce41c1c3a7dbda725c04d397145306575c491 Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Tue, 14 Oct 2025 15:35:34 +0200 Subject: [PATCH] IJPF-CR-30511 [java-highlighting] IDEA-252433 Suggest the correct import when the wrong one was chosen from ambiguous - change `to` with `with` (cherry picked from commit c3e68d77a1b5ee1a5b252b19027cc061609ca9d6) GitOrigin-RevId: 9ad86fb558f91e64e4a1068f5ea134424e3aff67 --- .../messages/QuickFixBundle.properties | 4 ++-- .../ReplaceTypeWithWrongImportFixTest.java | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/java/java-analysis-impl/resources/messages/QuickFixBundle.properties b/java/java-analysis-impl/resources/messages/QuickFixBundle.properties index 7d54df4e4951..bdfc8117c83f 100644 --- a/java/java-analysis-impl/resources/messages/QuickFixBundle.properties +++ b/java/java-analysis-impl/resources/messages/QuickFixBundle.properties @@ -147,8 +147,8 @@ enable.optimize.imports.on.the.fly=Enable 'Settings | Editor | General | Auto Im implement.methods.fix=Implement methods import.class.fix=Import class replace.type.new.expression.family.name=Replace a constructor call type -replace.type.new.expression.name=Replace a constructor call type to ''{0}'' -replace.type.variable.name=Replace a variable type to ''{0}'' +replace.type.new.expression.name=Replace a constructor call type with ''{0}'' +replace.type.variable.name=Replace a variable type with ''{0}'' insert.new.fix=Insert new insert.super.constructor.call.family=Insert base class constructor call make.class.an.interface.family=Make Class an Interface diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceTypeWithWrongImportFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceTypeWithWrongImportFixTest.java index eb12173da305..aac211a61d5e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceTypeWithWrongImportFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceTypeWithWrongImportFixTest.java @@ -26,7 +26,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu void call(B b){} """); - IntentionAction intention = myFixture.findSingleIntention("Replace a constructor call type to 'bar.p2.A'"); + IntentionAction intention = myFixture.findSingleIntention("Replace a constructor call type with 'bar.p2.A'"); assertEquals(myFixture.getIntentionPreviewText(intention), """ import bar.p1.A; @@ -63,7 +63,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type to 'bar.p1.B'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type with 'bar.p1.B'")); myFixture.checkResult(""" import bar.p1.A; import bar.p1.B; @@ -109,7 +109,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type to 'bar.p1.B'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type with 'bar.p1.B'")); myFixture.checkResult(""" import bar.p1.A; import bar.p1.B; @@ -135,7 +135,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu return new A("1"); } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type to 'bar.p1.B'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a variable type with 'bar.p1.B'")); myFixture.checkResult(""" import bar.p1.A; import bar.p1.B; @@ -161,7 +161,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type to 'bar.p2.A'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type with 'bar.p2.A'")); myFixture.checkResult(""" import bar.p2.A; import bar.p2.B; @@ -194,7 +194,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type to 'bar.p3.A'")); + assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type with 'bar.p3.A'")); } public void testFixConstructorTypeClassNotAssignable() { @@ -219,7 +219,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type to 'bar.p3.A'")); + assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type with 'bar.p3.A'")); } public void testFixConstructorTypeClassUnavailable() { @@ -244,7 +244,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type to 'bar.p3.A'")); + assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type with 'bar.p3.A'")); } public void testFixConstructorTypeClassDefaultConstructor() { @@ -276,7 +276,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type to 'bar.p3.A'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type with 'bar.p3.A'")); myFixture.checkResult(""" import bar.p3.A; import bar.p3.B; @@ -298,7 +298,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu } """); - myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type to 'bar.p2.A<>'")); + myFixture.launchAction(myFixture.findSingleIntention("Replace a constructor call type with 'bar.p2.A<>'")); myFixture.checkResult(""" import bar.p2.A; import bar.p2.B; @@ -330,7 +330,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type to 'bar.p3.A'")); + assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type with 'bar.p3.A'")); } public void testFixConstructorTypeNoAvailableClass() { @@ -349,7 +349,7 @@ public class ReplaceTypeWithWrongImportFixTest extends LightJavaCodeInsightFixtu B b = new A("1"); } """); - assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type to 'bar.p3.A'")); + assertEmpty(myFixture.filterAvailableIntentions("Replace a constructor call type with 'bar.p3.A'")); } private void addClasses() {