Method: AppMap::ClassMap.build_from_methods
- Defined in:
- lib/appmap/class_map.rb
.build_from_methods(methods) ⇒ Object
rubocop:enable Metrics/MethodLength
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/appmap/class_map.rb', line 93 def build_from_methods(methods) root = Types::Root.new methods.each do |method| add_function root, method end collapse_package = lambda do |package| next unless package.type == "package" while package.children.length == 1 && package.children.all? { |child| child.type == "package" } child = package.children[0] package.children.clear child.children.each { |child| package.children << child } package.name = [package.name, child.name].join("/") end package.tap do package.children.map(&collapse_package) end end root.children.map(&collapse_package).map(&:to_h) end |