void (final PsiTypeElement typeElement, final PsiClassType superType) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(myProject); PsiClassType psiType = (PsiClassType) typeElement.getType(); PsiClassType.ClassResolveResult classResolveResult = psiType.resolveGenerics(); PsiType substType = classResolveResult.getSubstitutor().substitute(superType); assert myClass.isEquivalentTo(classResolveResult.getElement()); try { PsiElement replaced = typeElement.replace(factory.createTypeElement(substType)); JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(replaced); } catch(IncorrectOperationException e) { LOG.error(e); } }