void (@Nullable PsiType type) { final GrTypeElement typeElement = getTypeElementGroovy(); if (type == null) { if (typeElement == null) return; if (getModifierList().getModifiers().length == 0) { getModifierList().setModifierProperty(GrModifier.DEF, true); } typeElement.delete(); return; } type = TypesUtil.unboxPrimitiveTypeWrapper(type); GrTypeElement newTypeElement; try { newTypeElement = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(type); } catch (IncorrectOperationException e) { LOG.error(e); return; } if (typeElement == null) { getModifierList().setModifierProperty(GrModifier.DEF, false); final GrVariable[] variables = getVariables(); if (variables.length == 0) return; newTypeElement = (GrTypeElement)addBefore(newTypeElement, variables[0]); } else { newTypeElement = (GrTypeElement)typeElement.replace(newTypeElement); } JavaCodeStyleManager.getInstance(getProject()).shortenClassReferences(newTypeElement); }