Document (@NotNull Project project) { PsiFile psiFile = createFileFromText(project, myTextToReformat); prepareForReformat(psiFile); CodeStyle.doWithTemporarySettings( project, mySettings, settings -> { settings.setRightMargin(getDefaultLanguage(), getAdjustedRightMargin()); doReformat(project, psiFile); }); return getDocumentBeforeChanges(project, psiFile); }