Skip to content

Commit

Permalink
Merge pull request #68 from gazayas/features/comment-line-number
Browse files Browse the repository at this point in the history
Get location information directly from comment object
  • Loading branch information
gazayas authored Oct 19, 2023
2 parents 919ed82 + 96a95fe commit 3fe03c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/masamune/abstract_syntax_tree/prism/node_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,10 @@ class Comment
def comment? = true
def token_location = location
def token_value = location.slice
def start_line = location.start_line
def start_column = location.start_column
def end_line = location.end_line
def end_column = location.end_column
def line_number = start_line
end
end
6 changes: 5 additions & 1 deletion test/test_masamune.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ def test_find_comments

msmn = Masamune::AbstractSyntaxTree.new(comments)

assert_equal 2, msmn.comments.size, 2
assert_equal 2, msmn.comments.size
assert_equal "# First comment", msmn.comments.first.token_value

# Test location
assert_equal 1, msmn.comments.first.line_number
assert_equal 2, msmn.comments.last.line_number
end

def test_find_symbols
Expand Down

0 comments on commit 3fe03c4

Please sign in to comment.