Quickfix for CANNOT_CHECK_FOR_ERASED.
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
1f3739415a
commit
64321dce56
@@ -59,11 +59,17 @@ public class ChangeToStarProjectionFix extends JetIntentionAction<JetTypeElement
|
||||
@Override
|
||||
public IntentionAction createAction(Diagnostic diagnostic) {
|
||||
JetBinaryExpressionWithTypeRHS expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpressionWithTypeRHS.class);
|
||||
if (expression == null) return null;
|
||||
JetTypeReference typeReference = expression.getRight();
|
||||
JetTypeReference typeReference;
|
||||
if (expression == null) {
|
||||
typeReference = QuickFixUtil.getParentElementOfType(diagnostic, JetTypeReference.class);
|
||||
}
|
||||
else {
|
||||
typeReference = expression.getRight();
|
||||
}
|
||||
if (typeReference == null) return null;
|
||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||
return typeElement == null ? null : new ChangeToStarProjectionFix(typeElement);
|
||||
assert typeElement != null;
|
||||
return new ChangeToStarProjectionFix(typeElement);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -180,7 +180,10 @@ public class QuickFixes {
|
||||
|
||||
factories.put(NO_TYPE_ARGUMENTS_ON_RHS_OF_IS_EXPRESSION, AddStarProjectionsFix.createFactoryForIsExpression());
|
||||
factories.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, AddStarProjectionsFix.createFactoryForJavaClass());
|
||||
factories.put(UNCHECKED_CAST, ChangeToStarProjectionFix.createFactory());
|
||||
|
||||
JetIntentionActionFactory changeToStarProjectionFactory = ChangeToStarProjectionFix.createFactory();
|
||||
factories.put(UNCHECKED_CAST, changeToStarProjectionFactory);
|
||||
factories.put(CANNOT_CHECK_FOR_ERASED, changeToStarProjectionFactory);
|
||||
|
||||
factories.put(INACCESSIBLE_OUTER_CLASS_EXPRESSION, AddModifierFix.createFactory(INNER_KEYWORD, JetClass.class));
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*, *>" "true"
|
||||
fun isStringToIntMap(map : Any) = map is Map<<caret>*, *>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*>" "true"
|
||||
fun isStringList(list : Any) = list is List<<caret>*>?
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*>" "true"
|
||||
fun isStringList(list : Any?) = list is (List<<caret>*>)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*, *>" "true"
|
||||
fun isStringToIntMap(map : Any) = map is Map<<caret>String, Int>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*>" "true"
|
||||
fun isStringList(list : Any) = list is List<<caret>String>?
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Change type argument list to <*>" "true"
|
||||
fun isStringList(list : Any?) = list is (List<<caret>String>)
|
||||
@@ -146,7 +146,7 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/addStarProjections")
|
||||
@InnerTestClasses({AddStarProjections.Cast.class, AddStarProjections.JavaClass.class, AddStarProjections.When.class})
|
||||
@InnerTestClasses({AddStarProjections.Cast.class, AddStarProjections.CheckType.class, AddStarProjections.JavaClass.class, AddStarProjections.When.class})
|
||||
public static class AddStarProjections extends AbstractQuickFixTest {
|
||||
public void testAllFilesPresentInAddStarProjections() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/addStarProjections"), Pattern.compile("^before(\\w+)\\.kt$"), true);
|
||||
@@ -200,6 +200,29 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/addStarProjections/checkType")
|
||||
public static class CheckType extends AbstractQuickFixTest {
|
||||
public void testAllFilesPresentInCheckType() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/quickfix/addStarProjections/checkType"), Pattern.compile("^before(\\w+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeChangeToStarProjectionMultipleParameters.kt")
|
||||
public void testChangeToStarProjectionMultipleParameters() throws Exception {
|
||||
doTest("idea/testData/quickfix/addStarProjections/checkType/beforeChangeToStarProjectionMultipleParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("beforeChangeToStarProjectionNullable.kt")
|
||||
public void testChangeToStarProjectionNullable() throws Exception {
|
||||
doTest("idea/testData/quickfix/addStarProjections/checkType/beforeChangeToStarProjectionNullable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("beforeChangeToStarProjectionSingleParameter.kt")
|
||||
public void testChangeToStarProjectionSingleParameter() throws Exception {
|
||||
doTest("idea/testData/quickfix/addStarProjections/checkType/beforeChangeToStarProjectionSingleParameter.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/addStarProjections/javaClass")
|
||||
public static class JavaClass extends AbstractQuickFixTest {
|
||||
public void testAllFilesPresentInJavaClass() throws Exception {
|
||||
@@ -270,6 +293,7 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
TestSuite suite = new TestSuite("AddStarProjections");
|
||||
suite.addTestSuite(AddStarProjections.class);
|
||||
suite.addTestSuite(Cast.class);
|
||||
suite.addTestSuite(CheckType.class);
|
||||
suite.addTestSuite(JavaClass.class);
|
||||
suite.addTestSuite(When.class);
|
||||
return suite;
|
||||
|
||||
Reference in New Issue
Block a user