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

Commit b22cb5f

Browse files
committed
Fix up Ruby 2.7 pattern matching usage
1 parent ac41ba7 commit b22cb5f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ Style/PerlBackrefs:
7878

7979
Style/SpecialGlobalVars:
8080
Enabled: false
81+
82+
Style/StructInheritance:
83+
Enabled: false

lib/syntax_tree/language_server/inlay_hints.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def visit_binary(node)
7373
# a ? b : ₍c ? d : e₎
7474
#
7575
def visit_if_op(node)
76-
if stack[-2] in Assign | Binary | IfOp | OpAssign
76+
case stack[-2]
77+
in Assign | Binary | IfOp | OpAssign
7778
parentheses(node.location)
79+
else
7880
end
7981

8082
super

test/location_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ def test_deconstruct
1515
location = Location.fixed(line: 1, char: 0, column: 0)
1616

1717
case location
18-
in [1, 0, 0, *]
18+
in [start_line, 0, 0, *]
19+
assert_equal(1, start_line)
1920
end
2021
end
2122

2223
def test_deconstruct_keys
2324
location = Location.fixed(line: 1, char: 0, column: 0)
2425

2526
case location
26-
in start_line: 1
27+
in start_line:
28+
assert_equal(1, start_line)
2729
end
2830
end
2931
end

0 commit comments

Comments
 (0)