in ktfmt_idea_plugin/src/main/java/com/facebook/ktfmt/intellij/KtfmtCodeStyleManager.java [101:119]
private void formatInternal(PsiFile file, Collection<TextRange> ranges) {
ApplicationManager.getApplication().assertWriteAccessAllowed();
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
documentManager.commitAllDocuments();
CheckUtil.checkWritable(file);
Document document = documentManager.getDocument(file);
if (document == null) {
return;
}
// If there are postponed PSI changes (e.g., during a refactoring), just abort.
// If we apply them now, then the incoming text ranges may no longer be valid.
if (documentManager.isDocumentBlockedByPsi(document)) {
return;
}
format(document, ranges);
}