lib/inch/language/elixir/provider/reader/parser.rb in inch-0.5.0.rc5 vs lib/inch/language/elixir/provider/reader/parser.rb in inch-0.5.0.rc6
- old
+ new
@@ -1,7 +1,7 @@
-require "json"
-require "inch/language/elixir/provider/reader/object"
+require 'json'
+require 'inch/language/elixir/provider/reader/object'
module Inch
module Language
module Elixir
module Provider
@@ -11,11 +11,12 @@
attr_reader :parsed_objects
# Helper method to parse an instance with the given +args+
#
# @see #parse
- # @return [CodeObject::Provider::Reader::Parser] the instance that ran
+ # @return [CodeObject::Provider::Reader::Parser] the instance that
+ # ran
def self.parse(*args)
parser = new
parser.parse(*args)
parser
end
@@ -30,19 +31,32 @@
end
end
# @return [Array<YARD::Object::Base>]
def objects
- @objects ||= parsed_objects.map do |o|
- Reader::Object.for(o) # unless IGNORE_TYPES.include?(o.type)
- end.compact
+ @objects ||= begin
+ list = parsed_objects.map do |o|
+ Reader::Object.for(o) # unless IGNORE_TYPES.include?(o.type)
+ end.compact
+ children_map = {}
+ list.each do |object|
+ if object.parent_fullname
+ children_map[object.parent_fullname] ||= []
+ children_map[object.parent_fullname] << object.fullname
+ end
+ end
+ list.each do |object|
+ object.children_fullnames = children_map[object.fullname]
+ end
+ list
+ end
end
private
def parse_objects(paths, excluded, read_dump_file = nil)
if read_dump_file.nil?
- raise "Elixir analysis only works with --read-from-dump."
+ fail 'Elixir analysis only works with --read-from-dump.'
else
output = File.read(read_dump_file)
end
@parsed_objects = JSON[output]['objects']
end