@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings codeStyleSettings) {
DBLanguage language = (DBLanguage) PsiUtil.getLanguage(element);
PsiFile psiFile = element.getContainingFile();
CodeStyleCustomSettings settings = language.getCodeStyleSettings(element.getProject());
boolean deliberate = CommonUtil.isCalledThrough(CodeFormatterFacade.class);
if (deliberate && settings.getCaseSettings().isEnabled()) {
DBLCodeStyleManager.getInstance(element.getProject()).formatCase(element.getContainingFile());
}
Block rootBlock = deliberate && settings.getFormattingSettings().isEnabled() ?
new FormattingBlock(codeStyleSettings, settings, element, null, 0) :
new PassiveFormattingBlock(element);
return FormattingModelProvider.createFormattingModelForPsiFile(psiFile, rootBlock, codeStyleSettings);
}