Skip to content

Commit

Permalink
Clarify macros vs. directives
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Nov 24, 2023
1 parent 2ab41c1 commit 06680cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/solargraph/source_map/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Mapper

private_class_method :new

MACRO_REGEXP = /(@\!method|@\!attribute|@\!visibility|@\!domain|@\!macro|@\!parse|@\!override)/.freeze
DIRECTIVE_REGEXP = /(@\!method|@\!attribute|@\!visibility|@\!domain|@\!macro|@\!parse|@\!override)/.freeze

# Generate the data.
#
Expand Down Expand Up @@ -65,7 +65,7 @@ def closure_at(position)
end

def process_comment source_position, comment_position, comment
return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~ MACRO_REGEXP
return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
cmnt = remove_inline_comment_hashes(comment)
parse = Solargraph::Source.parse_docstring(cmnt)
last_line = 0
Expand Down Expand Up @@ -198,6 +198,8 @@ def process_directive source_position, comment_position, directive
namespace.domains.concat directive.tag.types unless directive.tag.types.nil?
when 'override'
pins.push Pin::Reference::Override.new(location, directive.tag.name, docstring.tags)
when 'macro'
# @todo Handle macros
end
end

Expand Down Expand Up @@ -226,7 +228,7 @@ def remove_inline_comment_hashes comment

# @return [void]
def process_comment_directives
return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~ MACRO_REGEXP
return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP
code_lines = @code.lines
@source.associated_comments.each do |line, comments|
src_pos = line ? Position.new(line, code_lines[line].to_s.chomp.index(/[^\s]/) || 0) : Position.new(code_lines.length, 0)
Expand Down

0 comments on commit 06680cf

Please sign in to comment.