GrTypeElement (@Nullable PsiType newReturnType) { GrTypeElement typeElement = getReturnTypeElementGroovy(); if (newReturnType == null || newReturnType == PsiTypes.nullType()) { if (typeElement != null) typeElement.delete(); insertPlaceHolderToModifierList(); return null; } final GrTypeElement stub = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(newReturnType); GrTypeElement newTypeElement; if (typeElement == null) { final GrTypeParameterList typeParameterList = getTypeParameterList(); PsiElement anchor = typeParameterList != null ? typeParameterList : getModifierList(); newTypeElement = (GrTypeElement)addAfter(stub, anchor); } else { newTypeElement = (GrTypeElement)typeElement.replace(stub); } return newTypeElement; }