How to fix Freeze in EDT

The code new ReformatCodeProcessor(PsiDocumentManager.getInstance(myProject).getPsiFile(document),false).runWithoutProgress(); report Freeze in EDT for 12 seconds Sampled time: 3600ms, sampling rate: 100ms, GC time: 122ms (1%), Class loading: 0%, CPU load: 11%

How to fix it?

Document document = getDocument();
        ((DocumentImpl)document).setAcceptSlashR(true);

        WriteCommandAction.runWriteCommandAction(
                myProject,
                () -> {
                    document.setText(finalText);
                    PsiDocumentManager.getInstance(myProject).commitDocument(document);
                    if(formatFlag && StringUtils.isNotBlank(finalText)){
                        new ReformatCodeProcessor(PsiDocumentManager.getInstance(myProject).getPsiFile(document),false).runWithoutProgress();
                    }
                }
        );