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

Implement And/Or Node locations #57

Merged
merged 1 commit into from
Oct 2, 2024
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
24 changes: 12 additions & 12 deletions lib/ast_to_prism/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1176,25 +1176,25 @@ def convert_node(node, block: nil)
)
when :AND
nd_1st, nd_2nd = node.children
loc, operator_loc = node.locations

# (source, left, right, operator_loc, location)
Prism::AndNode.new(
source,
convert_node(nd_1st),
convert_node(nd_2nd),
null_location,
location(node)
source, # source
convert_node(nd_1st), # left
convert_node(nd_2nd), # right
location(operator_loc), # operator_loc
location(loc), # location
)
when :OR
nd_1st, nd_2nd = node.children
loc, operator_loc = node.locations

# (source, left, right, operator_loc, location)
Prism::OrNode.new(
source,
convert_node(nd_1st),
convert_node(nd_2nd),
null_location,
location(node)
source, # source
convert_node(nd_1st), # left
convert_node(nd_2nd), # right
location(operator_loc), # operator_loc
location(loc), # location
)
when :MASGN
not_supported(node)
Expand Down
8 changes: 0 additions & 8 deletions spec/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -897,28 +897,20 @@ def test_code(code)

describe "and" do
it "tests" do
pending "operator_loc is not supported"

test_code("1 && 2")
end

it "tests" do
pending "operator_loc is not supported"

test_code("1 and 2")
end
end

describe "or" do
it "tests" do
pending "operator_loc is not supported"

test_code("1 || 2")
end

it "tests" do
pending "operator_loc is not supported"

test_code("1 or 2")
end
end
Expand Down