Skip to content

Commit

Permalink
Gracefully handle misunderstood macros (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed May 3, 2020
1 parent 1b659d5 commit eb50c34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/solargraph/source_map/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def process_comment source_position, comment_position, comment
# @param comment [String]
# @return [Integer]
def find_directive_line_number comment, tag, start
# Avoid overruning the index
return start unless start < comment.lines.length
num = comment.lines[start..-1].find_index do |line|
# Legacy method directives might be `@method` instead of `@!method`
# @todo Legacy syntax should probably emit a warning
Expand Down
15 changes: 15 additions & 0 deletions spec/source_map/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1368,4 +1368,19 @@ def foo bar:, **splat
pin = map.first_pin('#foo')
expect(pin.parameters.last.full).to eq('**splat')
end

it 'gracefully handles misunderstood macros' do
expect {
Solargraph::SourceMap.load_string(%(
module Foo
# @!macro macro1
# @!macro macro2
# @!method macro_method
# @!macro macro1
class Bar; end
end
))
}.not_to raise_error
end
end

0 comments on commit eb50c34

Please sign in to comment.