Search in sources :

Example 1 with PsiBasedFormatterModelWithShiftIndentInside

use of com.intellij.psi.impl.source.codeStyle.PsiBasedFormatterModelWithShiftIndentInside in project intellij-community by JetBrains.

the class JavaFormattingModelBuilder method createModel.

@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);
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) FileElement(com.intellij.psi.impl.source.tree.FileElement) Block(com.intellij.formatting.Block) AbstractJavaBlock(com.intellij.psi.formatter.java.AbstractJavaBlock) JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings) FormattingDocumentModelImpl(com.intellij.psi.formatter.FormattingDocumentModelImpl) PsiBasedFormatterModelWithShiftIndentInside(com.intellij.psi.impl.source.codeStyle.PsiBasedFormatterModelWithShiftIndentInside) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Block (com.intellij.formatting.Block)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 JavaCodeStyleSettings (com.intellij.psi.codeStyle.JavaCodeStyleSettings)1 FormattingDocumentModelImpl (com.intellij.psi.formatter.FormattingDocumentModelImpl)1 AbstractJavaBlock (com.intellij.psi.formatter.java.AbstractJavaBlock)1 PsiBasedFormatterModelWithShiftIndentInside (com.intellij.psi.impl.source.codeStyle.PsiBasedFormatterModelWithShiftIndentInside)1 FileElement (com.intellij.psi.impl.source.tree.FileElement)1 NotNull (org.jetbrains.annotations.NotNull)1