private static @Nullable String getTypeText(@NotNull PsiElement element,
                                              @NotNull PsiSubstitutor substitutor,
                                              @Nullable PsiElement position) {
    PsiType type = null;
    if (element instanceof GrVariable) {
      type = TypeInferenceHelper.getVariableTypeInContext(position, (GrVariable)element);
    }
    else if (element instanceof PsiVariable) {
      type = ((PsiVariable)element).getType();
    }
    else if (element instanceof PsiMethod) {
      type = substitutor.substitute(((PsiMethod)element).getReturnType());
    }
    else if (element instanceof GroovyProperty) {
      type = ((GroovyProperty)element).getPropertyType();
    }
    return type != null ? type.getPresentableText() : null;
  }
private static @Nullable String getTypeText(@NotNull PsiElement element,
                                              @NotNull PsiSubstitutor substitutor,
                                              @Nullable PsiElement position)