void (PsiMethod method, String newName, String type) { Project project = method.getProject(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); if (newName != null && !newName.equals(method.getName())) { final PsiIdentifier nameId = method.getNameIdentifier(); assert nameId != null : method; nameId.replace(factory.createIdentifier(newName)); } PsiTypeElement element = method.getReturnTypeElement(); if (element != null && !element.getType().equalsToText(type)) { JavaCodeStyleManager.getInstance(project).shortenClassReferences(element.replace(factory.createTypeElementFromText(type, method))); } }