List<Block> () { 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; }