LookupElementBuilder (PsiElement element, LookupElementBuilder builder, 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 ? builder.withTypeText(type.getPresentableText()) : builder; }