lib/analyst/entities/root.rb in analyst-1.0.1 vs lib/analyst/entities/root.rb in analyst-1.2.0

- old
+ new

@@ -4,45 +4,28 @@ class Root < Entity handles_node :analyst_root - def initialize(ast, source_data) - @source_data = source_data - super(ast, nil) - end - def full_name "" end - def source_data_for(entity) - source_data[actual_contents.index(entity)] - end - - def file_path - throw "Entity tree malformed - Source or File should have caught this call" - end - - def origin_source - throw "Entity tree malformed - Source or File hsould have caught this call" - end - def inspect "\#<#{self.class}>" end def contents - # skip all top-level entities, cuz they're all Files and Sources - @contents ||= actual_contents.map(&:contents).flatten + @contents ||= actual_contents.map do |child| + # skip top-level CodeBlocks + child.is_a?(Entities::CodeBlock) ? child.contents : child + end.flatten end private - attr_reader :source_data - def actual_contents - @actual_contents ||= ast.children.map { |child| process_node(child) } + @actual_contents ||= process_nodes(ast.children) end end end end