Skip to content

Commit cf507cb

Browse files
committed
MLHSAddPost -> MLHS + MLHS
1 parent 174c3ec commit cf507cb

File tree

2 files changed

+10
-58
lines changed

2 files changed

+10
-58
lines changed

lib/syntax_tree.rb

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5060,8 +5060,7 @@ def on_lparen(value)
50605060
# first, = value
50615061
#
50625062
class MAssign
5063-
# [Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen] the target of the multiple
5064-
# assignment
5063+
# [Mlhs | MlhsParen] the target of the multiple assignment
50655064
attr_reader :target
50665065

50675066
# [untyped] the value being assigned
@@ -5096,10 +5095,7 @@ def to_json(*opts)
50965095
end
50975096

50985097
# :call-seq:
5099-
# on_massign: (
5100-
# (Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen) target,
5101-
# untyped value
5102-
# ) -> MAssign
5098+
# on_massign: ((Mlhs | MlhsParen) target, untyped value) -> MAssign
51035099
def on_massign(target, value)
51045100
comma_range = target.location.end_char...value.location.start_char
51055101
target.comma = true if source[comma_range].strip.start_with?(',')
@@ -5286,53 +5282,12 @@ def on_mlhs_add(mlhs, part)
52865282
MLHS.new(parts: mlhs.parts << part, location: location)
52875283
end
52885284

5289-
# MLHSAddPost represents adding another set of variables onto a list of
5290-
# assignments after a splat variable within a multiple assignment.
5291-
#
5292-
# left, *middle, right = values
5293-
#
5294-
class MLHSAddPost
5295-
# [MlhsAddStar] the value being starred
5296-
attr_reader :star
5297-
5298-
# [Mlhs] the values after the star
5299-
attr_reader :mlhs
5300-
5301-
# [Location] the location of this node
5302-
attr_reader :location
5303-
5304-
def initialize(star:, mlhs:, location:)
5305-
@star = star
5306-
@mlhs = mlhs
5307-
@location = location
5308-
end
5309-
5310-
def pretty_print(q)
5311-
q.group(2, '(', ')') do
5312-
q.text('mlhs_add_post')
5313-
5314-
q.breakable
5315-
q.pp(star)
5316-
5317-
q.breakable
5318-
q.pp(mlhs)
5319-
end
5320-
end
5321-
5322-
def to_json(*opts)
5323-
{ type: :mlhs_add_post, star: star, mlhs: mlhs, loc: location }.to_json(
5324-
*opts
5325-
)
5326-
end
5327-
end
5328-
53295285
# :call-seq:
5330-
# on_mlhs_add_post: (MLHS star, MLHS mlhs) -> MLHSAddPost
5331-
def on_mlhs_add_post(star, mlhs)
5332-
MLHSAddPost.new(
5333-
star: star,
5334-
mlhs: mlhs,
5335-
location: star.location.to(mlhs.location)
5286+
# on_mlhs_add_post: (MLHS left, MLHS right) -> MLHS
5287+
def on_mlhs_add_post(left, right)
5288+
MLHS.new(
5289+
parts: left.parts + right.parts,
5290+
location: left.location.to(right.location)
53365291
)
53375292
end
53385293

@@ -5364,8 +5319,7 @@ def on_mlhs_new
53645319
# (left, right) = value
53655320
#
53665321
class MLHSParen
5367-
# [Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen] the contents inside of the
5368-
# parentheses
5322+
# [Mlhs | MlhsParen] the contents inside of the parentheses
53695323
attr_reader :contents
53705324

53715325
# [Location] the location of this node
@@ -5391,9 +5345,7 @@ def to_json(*opts)
53915345
end
53925346

53935347
# :call-seq:
5394-
# on_mlhs_paren: (
5395-
# (Mlhs | MlhsAddPost | MlhsAddStar | MlhsParen) contents
5396-
# ) -> MLHSParen
5348+
# on_mlhs_paren: ((Mlhs | MlhsParen) contents) -> MLHSParen
53975349
def on_mlhs_paren(contents)
53985350
lparen = find_token(LParen)
53995351
rparen = find_token(RParen)

test/syntax_tree_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def test_mlhs_add_post
664664
source = 'left, *middle, right = values'
665665

666666
at = location(chars: 0..20)
667-
assert_node(MLHSAddPost, 'mlhs_add_post', source, at: at, &:target)
667+
assert_node(MLHS, 'mlhs', source, at: at, &:target)
668668
end
669669

670670
def test_mlhs_paren

0 commit comments

Comments
 (0)