Quick-Fixes: Support USELESS_CAST diagnostic in "Remove cast" quick-fix
#KT-6422 Fixed
This commit is contained in:
@@ -87,6 +87,7 @@ public class QuickFixRegistrar {
|
|||||||
|
|
||||||
QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, ReplaceOperationInBinaryExpressionFix.createChangeCastToStaticAssertFactory());
|
QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, ReplaceOperationInBinaryExpressionFix.createChangeCastToStaticAssertFactory());
|
||||||
QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory());
|
QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory());
|
||||||
|
QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory());
|
||||||
|
|
||||||
JetSingleIntentionActionFactory changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory();
|
JetSingleIntentionActionFactory changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory();
|
||||||
QuickFixes.factories.put(WRONG_SETTER_PARAMETER_TYPE, changeAccessorTypeFactory);
|
QuickFixes.factories.put(WRONG_SETTER_PARAMETER_TYPE, changeAccessorTypeFactory);
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// "Remove cast" "true"
|
||||||
|
fun foo(a: String) {
|
||||||
|
val b = a
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// "Remove cast" "true"
|
||||||
|
fun test(x: Any): String? {
|
||||||
|
if (x is String) {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// "Remove cast" "true"
|
||||||
|
fun foo(a: String) {
|
||||||
|
val b = a <caret>as Any
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// "Remove cast" "true"
|
||||||
|
fun test(x: Any): String? {
|
||||||
|
if (x is String) {
|
||||||
|
return x <caret>as String
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -2825,6 +2825,24 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeRemoveUselessCast.kt")
|
||||||
|
public void testRemoveUselessCast() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeRemoveUselessCastUnderSmartCast.kt")
|
||||||
|
public void testRemoveUselessCastUnderSmartCast() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveUselessCastUnderSmartCast.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeReplaceUselessCastWithStaticAssert.kt")
|
||||||
|
public void testReplaceUselessCastWithStaticAssert() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeUnnecessaryNonNullAssertion1.kt")
|
@TestMetadata("beforeUnnecessaryNonNullAssertion1.kt")
|
||||||
public void testUnnecessaryNonNullAssertion1() throws Exception {
|
public void testUnnecessaryNonNullAssertion1() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion1.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion1.kt");
|
||||||
@@ -2867,12 +2885,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeUselessCast.kt")
|
|
||||||
public void testUselessCast() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUselessCast.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("beforeUselessCastStaticAssertIsFine.kt")
|
@TestMetadata("beforeUselessCastStaticAssertIsFine.kt")
|
||||||
public void testUselessCastStaticAssertIsFine() throws Exception {
|
public void testUselessCastStaticAssertIsFine() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUselessCastStaticAssertIsFine.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUselessCastStaticAssertIsFine.kt");
|
||||||
@@ -4954,15 +4966,15 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeNonLocalReturn.kt")
|
@TestMetadata("beforeNonLocalReturnRuntime.kt")
|
||||||
public void testNonLocalReturn() throws Exception {
|
public void testNonLocalReturnRuntime() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturn.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnRuntime.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("beforeNonLocalReturnWithLabel.kt")
|
@TestMetadata("beforeNonLocalReturnWithLabelRuntime.kt")
|
||||||
public void testNonLocalReturnWithLabel() throws Exception {
|
public void testNonLocalReturnWithLabelRuntime() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabel.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabelRuntime.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user