Add removeTypeAnnotation(JetFunction function) utility.
This commit is contained in:
committed by
Andrey Breslav
parent
3ec9cd817f
commit
a880b2a699
@@ -265,21 +265,24 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeTypeAnnotation(@NotNull JetNamedDeclaration property, @Nullable JetTypeReference typeReference) {
|
private static void removeTypeAnnotation(@Nullable PsiElement removeAfter, @Nullable JetTypeReference typeReference) {
|
||||||
|
if (removeAfter == null) return;
|
||||||
if (typeReference == null) return;
|
if (typeReference == null) return;
|
||||||
PsiElement identifier = property.getNameIdentifier();
|
PsiElement sibling = removeAfter.getNextSibling();
|
||||||
if (identifier == null) return;
|
|
||||||
PsiElement sibling = identifier.getNextSibling();
|
|
||||||
if (sibling == null) return;
|
if (sibling == null) return;
|
||||||
PsiElement nextSibling = typeReference.getNextSibling();
|
PsiElement nextSibling = typeReference.getNextSibling();
|
||||||
sibling.getParent().getNode().removeRange(sibling.getNode(), nextSibling == null ? null : nextSibling.getNode());
|
sibling.getParent().getNode().removeRange(sibling.getNode(), nextSibling == null ? null : nextSibling.getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeTypeAnnotation(JetProperty property) {
|
public static void removeTypeAnnotation(JetProperty property) {
|
||||||
removeTypeAnnotation(property, property.getTypeRef());
|
removeTypeAnnotation(property.getNameIdentifier(), property.getTypeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeTypeAnnotation(JetParameter parameter) {
|
public static void removeTypeAnnotation(JetParameter parameter) {
|
||||||
removeTypeAnnotation(parameter, parameter.getTypeReference());
|
removeTypeAnnotation(parameter.getNameIdentifier(), parameter.getTypeReference());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeTypeAnnotation(JetFunction function) {
|
||||||
|
removeTypeAnnotation(function.getValueParameterList(), function.getReturnTypeRef());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user