void (PsiTypeParameterListOwner original, PsiTypeParameterListOwner query, PsiTypeParameterListOwner replacement) { final PsiTypeParameterList originalTypeParameterList = original.getTypeParameterList(); final PsiTypeParameterList queryTypeParameterList = query.getTypeParameterList(); final PsiTypeParameterList replacementTypeParameterList = replacement.getTypeParameterList(); if (originalTypeParameterList == null || queryTypeParameterList == null || replacementTypeParameterList == null) { return; } if (originalTypeParameterList.getTypeParameters().length != 0 && queryTypeParameterList.getTypeParameters().length == 0 && replacementTypeParameterList.getTypeParameters().length == 0) { final PsiElement newElement = replacementTypeParameterList.replace(originalTypeParameterList); final PsiElement prev = originalTypeParameterList.getPrevSibling(); if (prev instanceof PsiWhiteSpace) { newElement.getParent().addBefore(prev, newElement); } } }