Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

WIP Simplifications #186

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

Merged
merged 17 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove the "value" field from ZSuper
  • Loading branch information
kddnewton committed Nov 2, 2022
commit 0059a828241892c84c83196c758da92a4e6bfdbf
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
- `Dot2` and `Dot3` are no longer nodes. Instead they have become a single new `RangeLiteral` node. This node looks the same as `Dot2` and `Dot3`, except that it additionally has an `operator` field that contains the operator that created the node. Consequently, the `visit_dot2` and `visit_dot3` methods have been removed from the visitor interface. If you were previously using these methods, you should now use `visit_range_literal` instead.
- `DefEndless` and `Defs` have both been folded into the `Def` node. The `Def` node now has the `target` and `operator` fields which originally came from `Defs` which can both be `nil`. It also now has an `endless?` method on it to tell if the original node was found in the endless form. Finally the `bodystmt` field can now either be a `BodyStmt` as it was or any other kind of node since that was the body of the `DefEndless` node. The `visit_defs` and `visit_def_endless` methods on the visitor have therefore been removed.
- `DoBlock` and `BraceBlock` have now been folded into a `Block` node. The `Block` node now has a `keywords?` method on it that returns true if the block was constructed with the `do`..`end` keywords. The `visit_do_block` and `visit_brace_block` methods on the visitor have therefore been removed and replaced with the `visit_block` method.
- The `ZSuper` node no longer has a `value` field associated with it (which was always a "super" string literal).

## [4.3.0] - 2022-10-28

Expand Down
10 changes: 3 additions & 7 deletions lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9830,14 +9830,10 @@ def format(q)
# super
#
class ZSuper < Node
# [String] the value of the keyword
attr_reader :value

# [Array[ Comment | EmbDoc ]] the comments attached to this node
attr_reader :comments

def initialize(value:, location:)
@value = value
def initialize(location:)
@location = location
@comments = []
end
Expand All @@ -9853,11 +9849,11 @@ def child_nodes
alias deconstruct child_nodes

def deconstruct_keys(_keys)
{ value: value, location: location, comments: comments }
{ location: location, comments: comments }
end

def format(q)
q.text(value)
q.text("super")
end
end
end
2 changes: 1 addition & 1 deletion lib/syntax_tree/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3908,7 +3908,7 @@ def on_yield0
def on_zsuper
keyword = consume_keyword(:super)

ZSuper.new(value: keyword.value, location: keyword.location)
ZSuper.new(location: keyword.location)
end
end
end
4 changes: 3 additions & 1 deletion lib/syntax_tree/visitor/field_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,9 @@ def visit_yield(node)
end

def visit_zsuper(node)
visit_token(node, "zsuper")
node(node, "zsuper") do
comments(node)
end
end

def visit___end__(node)
Expand Down