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

signature helps are not shown if the target code has comments #829

Merged
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
7 changes: 1 addition & 6 deletions lib/steep/services/signature_help_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ def env
def initialize(source:, subtyping:)
@source = source
@subtyping = subtyping

text =
if source.node
source.node.loc.expression.source
end
@buffer = RBS::Buffer.new(name: source.path, content: text || "")
@buffer = source.buffer
end

def run(line:, column:)
Expand Down
3 changes: 2 additions & 1 deletion test/signature_help_provider_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def self.foo: (String, Integer) -> Array[Symbol]
end
RBS
source = Source.parse(<<~RUBY, path: Pathname("a.rb"), factory: checker.factory)
# Show signature help for a commented method call
TestClass.foo("", 123)
RUBY

SignatureHelpProvider.new(source: source, subtyping: checker).tap do |provider|
items, index = provider.run(line: 1, column: 14)
items, index = provider.run(line: 2, column: 14)

assert_equal 0, index
assert_equal ["(::String, ::Integer) -> ::Array[::Symbol]", "() -> ::Array[::Symbol]"], items.map(&:method_type).map(&:to_s)
Expand Down