use of com.intellij.psi.formatter.common.NewLineBlocksIterator in project intellij-community by JetBrains.
the class NewLineBlocksIteratorTest method testFirstBlockOnNewLineNotStartsIt.
public void testFirstBlockOnNewLineNotStartsIt() throws IOException, JDOMException {
String text = "[]varx []=r'''\n" + "'''";
TestData data = FormatterEngineTestsKt.extractFormattingTestData(text);
Document document = EditorFactory.getInstance().createDocument(data.getTextToFormat());
NewLineBlocksIterator iterator = new NewLineBlocksIterator(data.getRootBlock(), document);
checkStartOffsets(new int[] { 0 }, iterator);
}
use of com.intellij.psi.formatter.common.NewLineBlocksIterator 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);
}
use of com.intellij.psi.formatter.common.NewLineBlocksIterator in project intellij-community by JetBrains.
the class FormatterBasedLineIndentInfoBuilder method getBlocksStartingNewLine.
@NotNull
private List<Block> getBlocksStartingNewLine() {
NewLineBlocksIterator newLineBlocksIterator = new NewLineBlocksIterator(myRootBlock, myDocument, myProgressIndicator);
List<Block> newLineBlocks = new ArrayList<>();
int currentLine = 0;
while (newLineBlocksIterator.hasNext() && currentLine < MAX_NEW_LINE_BLOCKS_TO_PROCESS) {
Block next = newLineBlocksIterator.next();
if (next instanceof ASTBlock && ((ASTBlock) next).getNode() instanceof PsiComment) {
continue;
}
newLineBlocks.add(next);
currentLine++;
}
return newLineBlocks;
}
Aggregations