Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Parlour and resolve root namespaces #170

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions lib/sord/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.load_gem_objects(hash)
end
add_rbs_objects_to_paths(env, hash)

gem_paths = Bundler.load.specs.map(&:full_gem_path)
gem_paths = Bundler.load.specs.map(&:full_gem_path) + ["#{Dir.pwd}/sorbet"]
gem_paths.each do |path|
next unless File.exist?("#{path}/rbi")

Expand Down Expand Up @@ -70,14 +70,21 @@ def self.add_rbi_objects_to_paths(nodes, names_to_paths, path=[])
klasses = [
Parlour::RbiGenerator::Constant,
Parlour::RbiGenerator::ModuleNamespace,
Parlour::RbiGenerator::ClassNamespace
Parlour::RbiGenerator::ClassNamespace,
Parlour::RbiGenerator::Namespace
]
child_only_classes = [
Parlour::RbiGenerator::Namespace
]
nodes.each do |node|
next unless klasses.include?(node.class)
new_path = path + [node.name]
names_to_paths[node.name] ||= Set.new
names_to_paths[node.name] << new_path.join('::')
add_rbi_objects_to_paths(node.children, names_to_paths, new_path) if node.respond_to?(:children)
if klasses.include?(node.class)
new_path = path + [node.name]
unless child_only_classes.include?(node.class)
names_to_paths[node.name] ||= Set.new
names_to_paths[node.name] << new_path.join('::')
end
add_rbi_objects_to_paths(node.children, names_to_paths, new_path) if node.respond_to?(:children)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion sord.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'yard'
spec.add_dependency 'sorbet-runtime'
spec.add_dependency 'commander', '~> 4.5'
spec.add_dependency 'parlour', '~> 5.0'
spec.add_dependency 'parlour', '~> 8.0'
spec.add_dependency 'rbs', '~> 3.0'

spec.add_development_dependency "bundler", "~> 2.0"
Expand Down
2 changes: 1 addition & 1 deletion spec/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ class B

it 'resolves included gem rbi files' do
subject.prepare
expect(subject.path_for('Parlour::TypeLoader')).to eq 'Parlour::TypeLoader'
expect(subject.path_for('Parlour::RbiGenerator')).to eq 'Parlour::RbiGenerator'
end
end
Loading