Added quickfix for CONFLICTING_PROJECTION

This commit is contained in:
Agnieszka Paszek
2013-02-15 17:49:31 +01:00
committed by Evgeny Gerashchenko
parent 56774cccd8
commit 50f8948706
4 changed files with 13 additions and 4 deletions
@@ -104,7 +104,7 @@ public class QuickFixes {
factories.put(ABSTRACT_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true)); factories.put(ABSTRACT_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true));
factories.put(OPEN_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD, true)); factories.put(OPEN_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD, true));
factories.put(TRAIT_CAN_NOT_BE_FINAL, removeFinalModifierFactory); factories.put(TRAIT_CAN_NOT_BE_FINAL, removeFinalModifierFactory);
factories.put(REDUNDANT_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory()); factories.put(REDUNDANT_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory(true));
factories.put(INCOMPATIBLE_MODIFIERS, RemoveModifierFix.createRemoveModifierFactory(false)); factories.put(INCOMPATIBLE_MODIFIERS, RemoveModifierFix.createRemoveModifierFactory(false));
factories.put(VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY, RemoveModifierFix.createRemoveVarianceFactory()); factories.put(VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY, RemoveModifierFix.createRemoveVarianceFactory());
@@ -202,6 +202,8 @@ public class QuickFixes {
factories.put(NESTED_CLASS_NOT_ALLOWED, AddModifierFix.createFactory(INNER_KEYWORD)); factories.put(NESTED_CLASS_NOT_ALLOWED, AddModifierFix.createFactory(INNER_KEYWORD));
factories.put(CONFLICTING_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory(false));
factories.put(NOT_AN_ANNOTATION_CLASS, MakeClassAnAnnotationClassFix.createFactory()); factories.put(NOT_AN_ANNOTATION_CLASS, MakeClassAnAnnotationClassFix.createFactory());
factories.put(DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED, AddSemicolonAfterFunctionCallFix.createFactory()); factories.put(DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED, AddSemicolonAfterFunctionCallFix.createFactory());
@@ -31,7 +31,6 @@ import org.jetbrains.jet.lang.psi.JetModifierList;
import org.jetbrains.jet.lang.psi.JetModifierListOwner; import org.jetbrains.jet.lang.psi.JetModifierListOwner;
import org.jetbrains.jet.lang.psi.JetTypeParameter; import org.jetbrains.jet.lang.psi.JetTypeParameter;
import org.jetbrains.jet.lang.psi.JetTypeProjection; import org.jetbrains.jet.lang.psi.JetTypeProjection;
import org.jetbrains.jet.lang.psi.stubs.elements.JetTypeParameterElementType;
import org.jetbrains.jet.lang.types.Variance; import org.jetbrains.jet.lang.types.Variance;
import org.jetbrains.jet.lexer.JetKeywordToken; import org.jetbrains.jet.lexer.JetKeywordToken;
import org.jetbrains.jet.lexer.JetToken; import org.jetbrains.jet.lexer.JetToken;
@@ -140,7 +139,7 @@ public class RemoveModifierFix extends JetIntentionAction<JetModifierListOwner>
}; };
} }
public static JetIntentionActionFactory createRemoveProjectionFactory() { public static JetIntentionActionFactory createRemoveProjectionFactory(final boolean isRedundant) {
return new JetIntentionActionFactory() { return new JetIntentionActionFactory() {
@Nullable @Nullable
@Override @Override
@@ -152,7 +151,7 @@ public class RemoveModifierFix extends JetIntentionAction<JetModifierListOwner>
IElementType elementType = projectionAstNode.getElementType(); IElementType elementType = projectionAstNode.getElementType();
if (!(elementType instanceof JetKeywordToken)) return null; if (!(elementType instanceof JetKeywordToken)) return null;
JetKeywordToken variance = (JetKeywordToken) elementType; JetKeywordToken variance = (JetKeywordToken) elementType;
return new RemoveModifierFix(projection, variance, true); return new RemoveModifierFix(projection, variance, isRedundant);
} }
}; };
} }
@@ -0,0 +1,4 @@
// "Remove 'in' modifier" "true"
class Foo<out T> {}
fun bar(x : Foo<Any>) {}
@@ -0,0 +1,4 @@
// "Remove 'in' modifier" "true"
class Foo<out T> {}
fun bar(x : Foo<<caret>in Any>) {}