Skip to content

Commit 20da209

Browse files
authored
Merge pull request #521 from ruby-syntax-tree/updates
Updates
2 parents 6642b40 + d0b3eaf commit 20da209

30 files changed

+1577
-1312
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
- '3.0'
1515
- '3.1'
1616
- '3.2'
17-
- head
17+
- '3.3'
18+
- '3.4'
1819
- truffleruby-head
1920
name: CI
2021
runs-on: ubuntu-latest

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ Style/KeywordParametersOrder:
136136
Style/MissingRespondToMissing:
137137
Enabled: false
138138

139+
Style/MultipleComparison:
140+
Enabled: false
141+
139142
Style/MutableConstant:
140143
Enabled: false
141144

@@ -157,6 +160,9 @@ Style/PerlBackrefs:
157160
Style/RedundantArrayConstructor:
158161
Enabled: false
159162

163+
Style/RedundantParentheses:
164+
Enabled: false
165+
160166
Style/SafeNavigation:
161167
Enabled: false
162168

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
source "https://rubygems.org"
44

55
gemspec
6+
7+
gem "fiddle"

Gemfile.lock

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,47 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
ast (2.4.2)
11-
docile (1.4.0)
12-
json (2.6.3)
13-
language_server-protocol (3.17.0.3)
10+
ast (2.4.3)
11+
docile (1.4.1)
12+
fiddle (1.1.8)
13+
json (2.12.2)
14+
language_server-protocol (3.17.0.5)
15+
lint_roller (1.1.0)
1416
minitest (5.25.5)
15-
parallel (1.23.0)
16-
parser (3.2.2.4)
17+
parallel (1.27.0)
18+
parser (3.3.8.0)
1719
ast (~> 2.4.1)
1820
racc
1921
prettier_print (1.2.1)
20-
racc (1.7.1)
22+
prism (1.4.0)
23+
racc (1.8.1)
2124
rainbow (3.1.1)
2225
rake (13.3.0)
23-
regexp_parser (2.8.2)
24-
rexml (3.2.6)
25-
rubocop (1.57.2)
26+
regexp_parser (2.10.0)
27+
rubocop (1.78.0)
2628
json (~> 2.3)
27-
language_server-protocol (>= 3.17.0)
29+
language_server-protocol (~> 3.17.0.2)
30+
lint_roller (~> 1.1.0)
2831
parallel (~> 1.10)
29-
parser (>= 3.2.2.4)
32+
parser (>= 3.3.0.2)
3033
rainbow (>= 2.2.2, < 4.0)
31-
regexp_parser (>= 1.8, < 3.0)
32-
rexml (>= 3.2.5, < 4.0)
33-
rubocop-ast (>= 1.28.1, < 2.0)
34+
regexp_parser (>= 2.9.3, < 3.0)
35+
rubocop-ast (>= 1.45.1, < 2.0)
3436
ruby-progressbar (~> 1.7)
35-
unicode-display_width (>= 2.4.0, < 3.0)
36-
rubocop-ast (1.30.0)
37-
parser (>= 3.2.1.0)
37+
unicode-display_width (>= 2.4.0, < 4.0)
38+
rubocop-ast (1.45.1)
39+
parser (>= 3.3.7.2)
40+
prism (~> 1.4)
3841
ruby-progressbar (1.13.0)
3942
simplecov (0.22.0)
4043
docile (~> 1.1)
4144
simplecov-html (~> 0.11)
4245
simplecov_json_formatter (~> 0.1)
43-
simplecov-html (0.12.3)
46+
simplecov-html (0.13.1)
4447
simplecov_json_formatter (0.1.4)
45-
unicode-display_width (2.5.0)
48+
unicode-display_width (3.1.4)
49+
unicode-emoji (~> 4.0, >= 4.0.4)
50+
unicode-emoji (4.0.4)
4651

4752
PLATFORMS
4853
arm64-darwin-21
@@ -53,6 +58,7 @@ PLATFORMS
5358

5459
DEPENDENCIES
5560
bundler
61+
fiddle
5662
minitest
5763
rake
5864
rubocop

lib/syntax_tree/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class CTags < Action
159159
attr_reader :entries
160160

161161
def initialize(options)
162-
super(options)
162+
super
163163
@entries = []
164164
end
165165

lib/syntax_tree/node.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11644,6 +11644,10 @@ def pin(parent, pin)
1164411644
elsif value.is_a?(Array) && (index = value.index(self))
1164511645
parent.public_send(key)[index] = replace
1164611646
break
11647+
elsif value.is_a?(Array) &&
11648+
(index = value.index { |(_k, v)| v == self })
11649+
parent.public_send(key)[index][1] = replace
11650+
break
1164711651
end
1164811652
end
1164911653
end

lib/syntax_tree/parser.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,11 @@ def visit(node)
670670

671671
visit_methods do
672672
def visit_var_ref(node)
673-
node.pin(stack[-2], pins.shift)
673+
if node.start_char > pins.first.start_char
674+
node.pin(stack[-2], pins.shift)
675+
else
676+
super
677+
end
674678
end
675679
end
676680

@@ -1732,13 +1736,13 @@ def on_fcall(value)
17321736
# :call-seq:
17331737
# on_field: (
17341738
# untyped parent,
1735-
# (:"::" | Op | Period) operator
1739+
# (:"::" | Op | Period | 73) operator
17361740
# (Const | Ident) name
17371741
# ) -> Field
17381742
def on_field(parent, operator, name)
17391743
Field.new(
17401744
parent: parent,
1741-
operator: operator,
1745+
operator: operator == 73 ? :"::" : operator,
17421746
name: name,
17431747
location: parent.location.to(name.location)
17441748
)

lib/syntax_tree/pattern.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def compile
7070
raise CompilationError, query
7171
end
7272

73+
raise CompilationError, query if program.nil?
7374
compile_node(program.statements.body.first.consequent.pattern)
7475
end
7576

lib/syntax_tree/yarv/assembler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def assemble_iseq(iseq, lines)
408408
def find_local(iseq, operands)
409409
name_string, level_string = operands.split(/,\s*/)
410410
name = name_string.to_sym
411-
level = level_string&.to_i || 0
411+
level = level_string.to_i
412412

413413
iseq.local_table.plain(name)
414414
iseq.local_table.find(name, level)
@@ -455,7 +455,7 @@ def parse_calldata(value)
455455
CallData::CALL_ARGS_SIMPLE
456456
end
457457

458-
YARV.calldata(message.to_sym, argc_value&.to_i || 0, flags)
458+
YARV.calldata(message.to_sym, argc_value.to_i, flags)
459459
end
460460
end
461461
end

0 commit comments

Comments
 (0)