void (@NotNull RangeMarker bounds, @NotNull PsiFile psiFile, @NotNull PsiDocumentManager manager) { PsiElement endElement = skipWhitespaces(psiFile.findElementAt(bounds.getEndOffset() - 1)); if (endElement != null && endElement.getTextOffset() >= bounds.getEndOffset()) { endElement = PsiTreeUtil.skipWhitespacesBackward(endElement); } if (endElement instanceof LeafPsiElement && ((LeafPsiElement)endElement).getElementType() == JsonElementTypes.COMMA) { final PsiElement nextNext = skipWhitespaces(endElement.getNextSibling()); if (nextNext instanceof LeafPsiElement && (((LeafPsiElement)nextNext).getElementType() == JsonElementTypes.R_CURLY || ((LeafPsiElement)nextNext).getElementType() == JsonElementTypes.R_BRACKET)) { PsiElement finalEndElement = endElement; ApplicationManager.getApplication().runWriteAction(() -> finalEndElement.delete()); } } else { final PsiElement property = getParentPropertyOrArrayItem(endElement); if (endElement instanceof PsiErrorElement || property != null && skipWhitespaces(property.getNextSibling()) instanceof PsiErrorElement) { PsiElement finalEndElement1 = endElement; ApplicationManager.getApplication().runWriteAction(() -> bounds.getDocument().insertString(getOffset(property, finalEndElement1), ",")); manager.commitDocument(bounds.getDocument()); } } }