From a880b2a6999d6c39e8b9cd163e290702f97eb79e Mon Sep 17 00:00:00 2001 From: Wojciech Lopata Date: Sat, 9 Feb 2013 11:01:11 +0100 Subject: [PATCH] Add removeTypeAnnotation(JetFunction function) utility. --- .../intentions/SpecifyTypeExplicitlyAction.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/SpecifyTypeExplicitlyAction.java b/idea/src/org/jetbrains/jet/plugin/intentions/SpecifyTypeExplicitlyAction.java index 21403b4dcfe..20ffc54e031 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/SpecifyTypeExplicitlyAction.java +++ b/idea/src/org/jetbrains/jet/plugin/intentions/SpecifyTypeExplicitlyAction.java @@ -265,21 +265,24 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction { 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; - PsiElement identifier = property.getNameIdentifier(); - if (identifier == null) return; - PsiElement sibling = identifier.getNextSibling(); + PsiElement sibling = removeAfter.getNextSibling(); if (sibling == null) return; PsiElement nextSibling = typeReference.getNextSibling(); sibling.getParent().getNode().removeRange(sibling.getNode(), nextSibling == null ? null : nextSibling.getNode()); } public static void removeTypeAnnotation(JetProperty property) { - removeTypeAnnotation(property, property.getTypeRef()); + removeTypeAnnotation(property.getNameIdentifier(), property.getTypeRef()); } 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()); } }