FormattingModel (@NotNull FormattingContext formattingContext) { PsiElement element = formattingContext.getPsiElement(); CodeStyleSettings settings = formattingContext.getCodeStyleSettings(); final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element)); LOG.assertTrue(fileElement != null, "File element should not be null for " + element); CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE); JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class); Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings, formattingContext.getFormattingMode()); FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile()); return new PsiBasedFormatterModelWithShiftIndentInside(element.getContainingFile(), block, model); }