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

Show location of type by method command #1537

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
5 changes: 3 additions & 2 deletions lib/rbs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,9 @@ def run_method(args, options)
stdout.puts " accessibility: #{method.accessibility}"
stdout.puts " types:"
separator = " "
for type in method.method_types
stdout.puts " #{separator} #{type}"
length_max = method.method_types.map { |type| type.to_s.length }.max or raise
method.method_types.each do |type|
stdout.puts format(" %s %-#{length_max}s at %s", separator, type, type.location)
separator = "|"
end
end
Expand Down
18 changes: 9 additions & 9 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ module Bar = Kernel
def test_method
with_cli do |cli|
cli.run(%w(method ::Object yield_self))
assert_equal <<-EOF, stdout.string
::Object#yield_self
defined_in: ::Kernel
implementation: ::Kernel
accessibility: public
types:
[X] () { (self) -> X } -> X
| () -> ::Enumerator[self, untyped]
EOF
assert_includes stdout.string, '::Object#yield_self'
assert_includes stdout.string, 'defined_in: ::Kernel'
assert_includes stdout.string, 'implementation: ::Kernel'
assert_includes stdout.string, 'accessibility: public'
assert_includes stdout.string, 'types:'
assert_includes stdout.string, ' [X] () { (self) -> X } -> X'
assert_includes stdout.string, 'rbs/core/kernel.rbs'
assert_includes stdout.string, '| () -> ::Enumerator[self, untyped]'
assert_includes stdout.string, 'rbs/core/kernel.rbs'
end

Dir.mktmpdir do |dir|
Expand Down