private static void fixCommaIfNeeded(@NotNull PsiElement element, boolean willBeLast) { PsiElement comma = getComma(element); if (willBeLast && comma != null) { comma.delete(); } else if (!willBeLast && comma == null) { PsiElement parent = element.getParent(); assert parent != null; parent.addAfter(JetPsiFactory(parent.getProject()).createComma(), element); } }