Skip to content

Commit a8a857d

Browse files
committed
Extend marker DSL
Replace positional `## directive: file:line:col` references with named markers (`## directive: [A]`) throughout scenario files. This makes scenarios more readable and resilient to line-number changes.
1 parent 9adda8f commit a8a857d

20 files changed

Lines changed: 183 additions & 64 deletions

scenario/class/initialize.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class A
44

55
class B
66
def initialize(xxx) # 5
7+
# ^[A]
78
@xxx = xxx
89
end
910
end
@@ -13,6 +14,7 @@ class C
1314

1415
def foo
1516
B.new(1) # 14
17+
# ^[B]
1618
end
1719

1820
## assert
@@ -27,8 +29,8 @@ class Object
2729
def foo: -> B
2830
end
2931

30-
## hover: test.rb:5:19
32+
## hover: [A]
3133
Integer
3234

33-
## hover: test.rb:14:6
35+
## hover: [B]
3436
B#initialize : (Integer) -> void

scenario/definitions/definition-rbs.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ def call_1
1616
end
1717

1818
Animal::Cat.new.call_1
19+
# ^[A]
1920
Animal::Cat.new.call_2
21+
# ^[B]
2022

21-
## definition: test.rb:9:17
23+
## definition: [A]
2224
test.rbs:(3,8)-(3,14)
2325
test.rb:(3,8)-(3,14)
2426

25-
## definition: test.rb:10:17
27+
## definition: [B]
2628
test.rbs:(4,8)-(4,14)

scenario/definitions/definition.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ def call
88
end
99

1010
Animal::Cat.new.call
11+
#^[A] ^[B] ^[C]
1112

12-
## definition: test.rb:9:1
13+
## definition: [A]
1314
test.rb:(1,7)-(1,13)
1415

15-
## definition: test.rb:9:9
16+
## definition: [B]
1617
test.rb:(2,8)-(2,11)
1718

18-
## definition: test.rb:9:17
19+
## definition: [C]
1920
test.rb:(3,8)-(3,12)

scenario/definitions/definition_multibyte_characters.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ def 🐱🐱🐱
88
end
99

1010
A動物::B猫.new.🐱🐱🐱
11+
#^[A] ^[B] ^[C]
1112

12-
## definition: test.rb:9:1
13+
## definition: [A]
1314
test.rb:(1,7)-(1,10)
1415

15-
## definition: test.rb:9:6
16+
## definition: [B]
1617
test.rb:(2,8)-(2,10)
1718

18-
## definition: test.rb:9:13
19+
## definition: [C]
1920
test.rb:(3,8)-(3,14)

scenario/rbs/attr.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ class A
1010
def test1
1111
a = A.new
1212
a.foo = 42.0
13+
# ^[A]
1314
a.foo
15+
# ^[B]
1416
end
1517

1618
def test2
1719
a = A.new
1820
a.bar = "foo"
21+
# ^[C]
1922
a.bar
23+
# ^[D]
2024
end
2125

2226
## assert: test.rb
@@ -25,14 +29,14 @@ def test1: -> Integer
2529
def test2: -> String
2630
end
2731

28-
## hover: test.rb:3:4
32+
## hover: [A]
2933
A#foo= : (Integer | Float) -> Integer | Float
3034

31-
## hover: test.rb:4:4
35+
## hover: [B]
3236
A#foo : -> Integer
3337

34-
## hover: test.rb:9:4
38+
## hover: [C]
3539
A#bar= : (String) -> String
3640

37-
## hover: test.rb:10:4
41+
## hover: [D]
3842
A#bar : -> String

scenario/rbs/inline-hover.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
## update: test.rb
22
#: (Integer) -> void
33
def check(var)
4+
# ^[A]
45
var
6+
# ^[B]
57
end
68

7-
## hover: test.rb:2:11
9+
## hover: [A]
810
Integer
911

10-
## hover: test.rb:3:3
12+
## hover: [B]
1113
Integer
1214

1315
## update: test2.rb
1416
class Foo
1517
#: (String) -> void
1618
def bar(x)
19+
# ^[C]
1720
x
21+
# ^[D]
1822
end
1923
end
2024

21-
## hover: test2.rb:3:10
25+
## hover: [C]
2226
String
2327

24-
## hover: test2.rb:4:4
28+
## hover: [D]
2529
String

scenario/service/completion_dot.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ def baz(_)
1414

1515
def test1(x)
1616
x
17+
# ^[A]
1718
end
1819

1920
def test2
2021
test1(Foo.new)
22+
# ^[B]
2123
end
2224

2325
Foo.new.foo(1.0)
2426
test(Foo.new)
2527

26-
## completion: test.rb:15:2
28+
## completion: [A]
2729
Foo#foo : (Float) -> Integer
2830
Foo#bar : (untyped) -> String
2931
Foo#baz : (Foo) -> Foo
3032

31-
## completion: test.rb:19:15
33+
## completion: [B]
3234
Foo#foo : (Float) -> Integer
3335
Foo#bar : (untyped) -> String
3436
Foo#baz : (Foo) -> Foo

scenario/service/completion_dot_module.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ def foo = :FOO
1111
end
1212
x = C.new
1313
x
14+
#\
15+
^[A]
1416

15-
## completion: test.rb:12:0
17+
## completion: [A]
1618
C#foo : -> :FOO
1719
M#bar : -> :BAR
1820
P#baz : -> :BAZ

scenario/service/definition.rb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,55 @@ def foo(n)
1414
end
1515

1616
Foo.new(1).foo(1.0)
17+
#^[A]^[B] ^[C]
1718
Foo.new(1).bar_sym_reader
19+
# ^[D]
1820
Foo.new(1).baz_sym_reader
21+
# ^[E]
1922
Foo.new(1).bar_sym_accessor
23+
# ^[F]
2024
Foo.new(1).baz_sym_accessor
25+
# ^[G]
2126
Foo::BAR
27+
# ^[H]
2228
Foo::BBAR = 1
2329
Foo::BBAR
30+
# ^[I]
2431
Foo::CCAR, Foo::DDAR = [1, 2]
2532
Foo::CCAR
33+
# ^[J]
2634
Foo::DDAR
35+
# ^[K]
2736

28-
## definition: test.rb:15:1
37+
## definition: [A]
2938
test.rb:(1,6)-(1,9) # Jump to Foo class
3039

31-
## definition: test.rb:15:5
40+
## definition: [B]
3241
test.rb:(7,6)-(7,16) # Jump Foo.initialize from Foo.new
3342

34-
## definition: test.rb:15:12
43+
## definition: [C]
3544
test.rb:(11,6)-(11,9) # Jump to Foo#foo
3645

37-
## definition: test.rb:16:12
46+
## definition: [D]
3847
test.rb:(4,14)-(4,29) # Jump to Foo#bar_sym_reader (first sym arg of attr_reader)
3948

40-
## definition: test.rb:17:12
49+
## definition: [E]
4150
test.rb:(4,31)-(4,46) # Jump to Foo#baz_sym_reader (second sym arg of attr_reader)
4251

43-
## definition: test.rb:18:12
52+
## definition: [F]
4453
test.rb:(5,16)-(5,33) # Jump to Foo#bar_sym_accessor (first sym arg of attr_accessor)
4554

46-
## definition: test.rb:19:12
55+
## definition: [G]
4756
test.rb:(5,35)-(5,52) # Jump to Foo#baz_sym_accessor (second sym arg of attr_accessor)
4857

49-
## definition: test.rb:20:5
58+
## definition: [H]
5059
test.rb:(2,2)-(2,5) # Jump to Foo#BAR (constant_write_node)
5160

52-
## definition: test.rb:22:5
61+
## definition: [I]
5362
test.rb:(21,0)-(21,9) # Jump to Foo#BBAR (constant_path_write_node)
5463

55-
## definition: test.rb:24:5
64+
## definition: [J]
5665
test.rb:(23,0)-(23,9) # Jump to Foo#CCAR (first arg of constant_path_target_node)
5766

58-
## definition: test.rb:25:5
67+
## definition: [K]
5968
test.rb:(23,11)-(23,20) # Jump to Foo#DDAR (second arg of constant_path_target_node)

scenario/service/hover.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
## update
22
def foo(variable)
3+
# ^[A]
34
variable + 1
5+
# ^[B]
46
end
57

68
def main(_)
79
foo(2)
810
end
911

10-
## hover: test.rb:1:10
12+
## hover: [A]
1113
Integer
1214

13-
## hover: test.rb:2:3
15+
## hover: [B]
1416
Integer
1517

1618
## update
1719
def foo(nnn)
1820
nnn.times do |var|
1921
var
22+
# ^[C]
2023
end
2124
end
2225

2326
foo(42)
2427

25-
## hover: test.rb:3:4
28+
## hover: [C]
2629
Integer

0 commit comments

Comments
 (0)