Skip to content

Commit 2f1e1e8

Browse files
Change scopenames to more appropriate. Not sure about how to give multiple scopenames to one rule. Add tests with 'for' and 'while' which i need to fix.
1 parent 010b2fe commit 2f1e1e8

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

Syntaxes/Ruby.plist

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
</dict>
364364
</dict>
365365
<key>name</key>
366-
<string>meta.syntax.for-block.ruby</string>
366+
<string>meta.block.for.ruby</string>
367367
<key>patterns</key>
368368
<array>
369369
<dict>
@@ -443,7 +443,7 @@
443443
</dict>
444444
</dict>
445445
<key>name</key>
446-
<string>meta.syntax.do-block.ruby</string>
446+
<string>meta.block.do.ruby</string>
447447
<key>patterns</key>
448448
<array>
449449
<dict>
@@ -474,7 +474,7 @@
474474
</dict>
475475
</dict>
476476
<key>name</key>
477-
<string>meta.syntax.begin-block.ruby</string>
477+
<string>meta.block.begin.ruby</string>
478478
<key>patterns</key>
479479
<array>
480480
<dict>
@@ -505,7 +505,7 @@
505505
</dict>
506506
</dict>
507507
<key>name</key>
508-
<string>meta.syntax.case-block.ruby</string>
508+
<string>meta.block.case.ruby</string>
509509
<key>patterns</key>
510510
<array>
511511
<dict>
@@ -585,12 +585,12 @@
585585
<key>3</key>
586586
<dict>
587587
<key>name</key>
588-
<string>keyword.control.if-unless.modifier.ruby</string>
588+
<string>meta.control.modifier keyword.control.if-unless.ruby</string>
589589
</dict>
590590
<key>4</key>
591591
<dict>
592592
<key>name</key>
593-
<string>keyword.control.while-until.modifier.ruby</string>
593+
<string>meta.control.modifier keyword.control.while-until.ruby</string>
594594
</dict>
595595
</dict>
596596
<key>patterns</key>
@@ -607,7 +607,7 @@
607607
<key>1</key>
608608
<dict>
609609
<key>name</key>
610-
<string>keyword.control.if-unless.modifier.ruby</string>
610+
<string>meta.control.modifier keyword.control.if-unless.ruby</string>
611611
</dict>
612612
</dict>
613613
<key>match</key>
@@ -670,7 +670,7 @@
670670
</dict>
671671
</dict>
672672
<key>name</key>
673-
<string>meta.syntax.if-unless-block.ruby</string>
673+
<string>meta.block.if-unless.ruby</string>
674674
<key>patterns</key>
675675
<array>
676676
<dict>
@@ -700,7 +700,7 @@
700700
\s*\b(while|until)\b(?![?!])
701701
</string>
702702
<key>name</key>
703-
<string>keyword.control.while-until.modifier.ruby</string>
703+
<string>meta.control.modifier keyword.control.while-until.ruby</string>
704704
</dict>
705705
<dict>
706706
<key>begin</key>
@@ -742,7 +742,7 @@
742742
</dict>
743743
</dict>
744744
<key>name</key>
745-
<string>meta.syntax.while-until-block.ruby</string>
745+
<string>meta.block.while-until.ruby</string>
746746
<key>patterns</key>
747747
<array>
748748
<dict>

Tests/end_distinction.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ def i arg
213213
1..for i in [1,2,3] do break i if i == 2; end
214214
1...for i in [1,2,3] do break i if i == 2; end
215215
10 / for i in [1,2,3] do break i if i == 2; end
216+
[for i in [1,2,3] do break i if i == 2 end]
217+
[ for i in [1,2,3] do break i if i == 2 end, for i in [1,2,3] do break i if i == 3 end]
218+
{for i in [1,2,3] do break i if i == 2 end => 1}
219+
{ for i in [1,2,3] do break i if i == 2 end => 1 }
220+
{foo: for i in [1,2,3] do break i if i == 2 end}
221+
{ foo: for i in [1,2,3] do break i if i == 2 end, bar: for i in [1,2,3] do break i if i == 3 end }
222+
{:foo => for i in [1,2,3] do break i if i == 2 end}
223+
{ :foo => for i in [1,2,3] do break i if i == 2 end, :bar=>for i in [1,2,3] do break i if i == 3 end }
224+
(for i in [1,2,3] do break i if i == 2 end)
225+
( for i in [1,2,3] do break i if i == 2 end )
226+
216227
#you cant use do-end blocks inside in statement
217228
for i in 3.times.map do 1 end do puts i; end # shouldn't work
218229
for? i in [1,2,3] # shouldn't work
@@ -267,6 +278,16 @@ def i arg
267278
while false do [1,2,3].each do |e| puts e end; end
268279
while false do [(0..10), (10..20)].each do |r| puts r.end end end
269280
while false do puts end?; puts end! end
281+
[while i < 10 do break i if i == 5; i += 1; end]
282+
[ while i < 10 do break i if i == 5; i += 1 end, while i < 10 do break i if i == 6; i += 1 end ]
283+
{while i < 10 do break i if i == 5; i += 1 end => 1}
284+
{ while i < 10 do break i if i == 5; i += 1 end => 1 }
285+
{foo: while i < 10 do break i if i == 5; i += 1 end}
286+
{ foo: while i < 10 do break i if i == 5; i += 1 end, bar:while i < 10 do break i if i == 6; i += 1 end }
287+
{:foo => while i < 10 do break i if i == 5; i += 1 end}
288+
{ :foo => while i < 10 do break i if i == 5; i += 1 end, :bar=>while i < 10 do break i if i == 6; i += 1 end }
289+
(while i < 10 do break i if i == 5; i += 1 end)
290+
( while i < 10 do break i if i == 5; i += 1 end )
270291

271292
# singleline modifier
272293
foo::while false # shouldn't work
@@ -346,6 +367,16 @@ def i arg
346367
a = /hello/; if true then 1 else 2 end
347368
if true then puts (1..10).end else puts (1..20).end end
348369
if true then puts end? else puts end! end
370+
[if true then 1 else 2 end]
371+
[ if true then 1 else 2 end, if true then 2 else 3 end]
372+
{if true then :foo else :bar end => 1}
373+
{ if true then :foo else :bar end => 1 }
374+
{foo: if true then 1 else 2 end}
375+
{ foo: if true then 1 else 2 end, bar: if true then 2 else 3 end }
376+
{:foo => if true then 1 else 2 end}
377+
{ :foo => if true then 1 else 2 end, :bar=>if true then 2 else 3 end }
378+
(if true then 1 else 2 end)
379+
( if true then 1 else 2 end )
349380

350381
# singleline modifier
351382
foo::if something # shouldn't work
@@ -412,6 +443,16 @@ def i arg
412443
1...case 15 when 0..50 then 10 when 51..100 then 20 else 30 end
413444
case x = rand(1..100) when 0..50 then puts (1..10).end when 51..100 then puts (1..20).end end
414445
case x = rand(1..100) when 0..50 then puts end? when 51..100 then puts end! end
446+
[case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end]
447+
[ case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end, case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end]
448+
{case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end => 1}
449+
{ case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end => 1 }
450+
{foo: case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end}
451+
{ foo: case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end, bar: case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end }
452+
{:foo => case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end}
453+
{ :foo => case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end, :bar=>case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end }
454+
(case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end)
455+
( case x = rand(1..100) when 0..50 then (1..10).end when 51..100 then (1..20).end end )
415456

416457
self.case 15 when 0..50 then "foo" when 51..100 then "bar" else "baz" end # shouldn't work
417458
self::case 15 when 0..50 then "foo" when 51..100 then "bar" else "baz" end # shouldn't work

0 commit comments

Comments
 (0)