Added QuickFix for redundant type projections.
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
e384d4ec96
commit
8d71840255
@@ -102,6 +102,7 @@ public class QuickFixes {
|
||||
factories.put(ABSTRACT_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true));
|
||||
factories.put(OPEN_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD, true));
|
||||
factories.put(TRAIT_CAN_NOT_BE_FINAL, removeFinalModifierFactory);
|
||||
factories.put(REDUNDANT_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory());
|
||||
|
||||
JetIntentionActionFactory removeOpenModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD);
|
||||
factories.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, AddModifierFix.createFactory(OPEN_KEYWORD, JetClass.class));
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.psi.JetModifierList;
|
||||
import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeProjection;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -135,4 +136,21 @@ public class RemoveModifierFix extends JetIntentionAction<JetModifierListOwner>
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static JetIntentionActionFactory createRemoveProjectionFactory() {
|
||||
return new JetIntentionActionFactory() {
|
||||
@Nullable
|
||||
@Override
|
||||
public JetIntentionAction<JetModifierListOwner> createAction(Diagnostic diagnostic) {
|
||||
JetTypeProjection projection = QuickFixUtil.getParentElementOfType(diagnostic, JetTypeProjection.class);
|
||||
if (projection == null) return null;
|
||||
ASTNode projectionAstNode = projection.getProjectionNode();
|
||||
if (projectionAstNode == null) return null;
|
||||
IElementType elementType = projectionAstNode.getElementType();
|
||||
if (!(elementType instanceof JetKeywordToken)) return null;
|
||||
JetKeywordToken variance = (JetKeywordToken) elementType;
|
||||
return new RemoveModifierFix(projection, variance, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant 'out' modifier" "true"
|
||||
class Foo<out T> {
|
||||
val x = 0
|
||||
}
|
||||
|
||||
fun bar(x : Foo<Any>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant 'in' modifier" "true"
|
||||
class Foo<in T> {
|
||||
val x = 0
|
||||
}
|
||||
|
||||
fun bar(x : Foo<Any>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant 'out' modifier" "true"
|
||||
class Foo<out T> {
|
||||
val x = 0
|
||||
}
|
||||
|
||||
fun bar(x : Foo< out<caret> Any>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Remove redundant 'in' modifier" "true"
|
||||
class Foo<in T> {
|
||||
val x = 0
|
||||
}
|
||||
|
||||
fun bar(x : Foo< in<caret> Any>) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user