Search in sources :

Example 6 with FormattingModel

use of com.intellij.formatting.FormattingModel in project intellij-community by JetBrains.

the class AbstractNewLineBlocksIteratorTest method newLineBlockIterator.

@NotNull
protected static Iterator<Block> newLineBlockIterator() {
    FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(myFile);
    Assert.assertNotNull(builder);
    CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    FormattingModel model = builder.createModel(myFile, settings);
    Block root = model.getRootBlock();
    Document document = PsiDocumentManager.getInstance(getProject()).getDocument(myFile);
    Assert.assertNotNull(document);
    return new NewLineBlocksIterator(root, document);
}
Also used : FormattingModel(com.intellij.formatting.FormattingModel) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) FormattingModelBuilder(com.intellij.formatting.FormattingModelBuilder) Block(com.intellij.formatting.Block) Document(com.intellij.openapi.editor.Document) NewLineBlocksIterator(com.intellij.psi.formatter.common.NewLineBlocksIterator) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FormattingModel (com.intellij.formatting.FormattingModel)6 FormattingModelBuilder (com.intellij.formatting.FormattingModelBuilder)5 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)4 Block (com.intellij.formatting.Block)3 Document (com.intellij.openapi.editor.Document)3 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 PsiFile (com.intellij.psi.PsiFile)1 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)1 NewLineBlocksIterator (com.intellij.psi.formatter.common.NewLineBlocksIterator)1