method directives are not parsed when comment block starts with double hash (##)
tatthurs opened this issue · 5 comments
tatthurs commented
Problem
YARD method directives are not parsed when the defining comment block begins with a double hash ##
.
Reproduction
Paste the following into https://solargraph.org/demo and note that foos
will autocomplete with signature information, but foobar
will not:
# This editor uses solargraph-rails to provide Ruby code completion.
# Code suggestions include the core Ruby library, local class and variable
# definitions, and hints from YARD documentation.
# Hit ctrl+space anywhere in code to get context-aware suggestions.
str = 'Hello, world!'
# Try entering `str.` and hitting ctrl+space to see String instance methods.
class Bar
##
# @!method foobar()
# @return [String]
define_method :foobar do
"foobar"
end
#
# @!method foos()
# @return [String]
define_method :foos do
"foos"
end
end
class Foo
include Bar
def bar
# this will autocomplete with type signature information
foos
# this will not
foobar
end
end
foo = Foo.new
# Try entering `foo.` and hitting ctrl+space to see Foo instance methods.
tatthurs commented
There is an existing parsing test for multiple hash prefixes:
solargraph/spec/source_spec.rb
Lines 290 to 300 in d48f396
tatthurs commented
There isn't anything special about double hash -- any number of hashes > 1 will reproduce the issue.
tatthurs commented
Interestingly, type annotations seem unaffected by this. Eg:
##
# @return [Number]
def baz
"baz"
end
works as expected and shows signature information.
castwide commented
Confirmed. I'll work on a fix.
castwide commented
Fix released in v0.50.0.