TextRange (@NotNull ASTNode element, @NotNull TextRange range) { PsiElement rootPsi = element.getPsi(); if (rootPsi.getLanguage() != JsonLanguage.INSTANCE) { return range; } JsonCodeStyleSettings settings = CodeStyle.getCustomSettings(rootPsi.getContainingFile(), JsonCodeStyleSettings.class); if (settings.KEEP_TRAILING_COMMA) { return range; } PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(rootPsi.getProject()); Document document = psiDocumentManager.getDocument(rootPsi.getContainingFile()); if (document == null) { return range; } DocumentUtil.executeInBulk(document, () -> { psiDocumentManager.doPostponedOperationsAndUnblockDocument(document); PsiElementVisitor visitor = new Visitor(document); rootPsi.accept(visitor); psiDocumentManager.commitDocument(document); }); return range; }