@Override @NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { 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); FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile()); return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model); }
@Override @NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element)); LOG.assertTrue(fileElement != null, "File element should not be null for " + element); CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE); Block block = AbstractJavaBlock.createJavaBlock(fileElement, javaSettings); FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile()); return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model); }
@Override @NotNull @RequiredReadAction public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { 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); FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile()); return new PsiBasedFormatterModelWithShiftIndentInside(element.getContainingFile(), block, model); }