Skip to content

Commit f4113a6

Browse files
authored
Merge pull request #170 from dorner/resolve-namespaces
Update Parlour and resolve root namespaces
2 parents e337ad6 + e3b6528 commit f4113a6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/sord/resolver.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,21 @@ def self.add_rbi_objects_to_paths(nodes, names_to_paths, path=[])
7070
klasses = [
7171
Parlour::RbiGenerator::Constant,
7272
Parlour::RbiGenerator::ModuleNamespace,
73-
Parlour::RbiGenerator::ClassNamespace
73+
Parlour::RbiGenerator::ClassNamespace,
74+
Parlour::RbiGenerator::Namespace
75+
]
76+
child_only_classes = [
77+
Parlour::RbiGenerator::Namespace
7478
]
7579
nodes.each do |node|
76-
next unless klasses.include?(node.class)
77-
new_path = path + [node.name]
78-
names_to_paths[node.name] ||= Set.new
79-
names_to_paths[node.name] << new_path.join('::')
80-
add_rbi_objects_to_paths(node.children, names_to_paths, new_path) if node.respond_to?(:children)
80+
if klasses.include?(node.class)
81+
new_path = path + [node.name]
82+
unless child_only_classes.include?(node.class)
83+
names_to_paths[node.name] ||= Set.new
84+
names_to_paths[node.name] << new_path.join('::')
85+
end
86+
add_rbi_objects_to_paths(node.children, names_to_paths, new_path) if node.respond_to?(:children)
87+
end
8188
end
8289
end
8390

0 commit comments

Comments
 (0)