int (@NotNull LighterASTNode item, @NotNull Ref<LighterASTNode[]> into) { if (item instanceof LazyParseableToken) { FlyweightCapableTreeStructure<LighterASTNode> tree = ((LazyParseableToken)item).parseContents(); LighterASTNode root = tree.getRoot(); if (root instanceof ProductionMarker) { ((ProductionMarker)root).myParent = ((Token)item).myParentNode; } return tree.getChildren(root, into); // todo: set offset shift for kids? } if (item instanceof Token || item instanceof ErrorItem) return 0; StartMarker marker = (StartMarker)item; count = 0; ProductionMarker child = marker.myFirstChild; int lexIndex = marker.myLexemeIndex; while (child != null) { lexIndex = insertLeaves(lexIndex, child.myLexemeIndex, marker.myBuilder, marker); if (child instanceof StartMarker && child.myBuilder.isCollapsed(child)) { int lastIndex = child.getEndIndex(); insertLeaf(child.getTokenType(), marker.myBuilder, child.myLexemeIndex, lastIndex, true, marker); } else { ensureCapacity(); nodes[count++] = child; } if (child instanceof StartMarker) { lexIndex = child.getEndIndex(); } child = child.myNext; } insertLeaves(lexIndex, marker.getEndIndex(), marker.myBuilder, marker); into.set(nodes == null ? LighterASTNode.EMPTY_ARRAY : nodes); nodes = null; return count; }