rtext 0.8.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +108 -84
- data/RText_Protocol +47 -4
- data/Rakefile +39 -46
- data/lib/rtext/context_builder.rb +49 -8
- data/lib/rtext/default_completer.rb +212 -163
- data/lib/rtext/default_service_provider.rb +3 -3
- data/lib/rtext/frontend/connector.rb +120 -53
- data/lib/rtext/frontend/context.rb +12 -12
- data/lib/rtext/instantiator.rb +11 -3
- data/lib/rtext/language.rb +5 -5
- data/lib/rtext/serializer.rb +1 -1
- data/lib/rtext/service.rb +264 -253
- data/lib/rtext/tokenizer.rb +1 -1
- data/test/completer_test.rb +606 -606
- data/test/context_builder_test.rb +952 -948
- data/test/frontend/context_test.rb +301 -205
- data/test/instantiator_test.rb +1773 -1691
- data/test/integration/model/test_metamodel3.ect4 +7 -0
- data/test/integration/test.rb +974 -918
- data/test/link_detector_test.rb +287 -287
- data/test/message_helper_test.rb +116 -118
- data/test/serializer_test.rb +1023 -1004
- data/test/tokenizer_test.rb +173 -173
- metadata +18 -19
- data/test/integration/backend.out +0 -13
- data/test/integration/frontend.log +0 -36049
@@ -1,205 +1,301 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
-
|
3
|
-
require '
|
4
|
-
require 'rtext/frontend/context'
|
5
|
-
|
6
|
-
class ContextTest < Test
|
7
|
-
|
8
|
-
def test_simple
|
9
|
-
assert_context(
|
10
|
-
%Q(
|
11
|
-
A {
|
12
|
-
B {
|
13
|
-
|F bla
|
14
|
-
),
|
15
|
-
%Q(
|
16
|
-
A {
|
17
|
-
B {
|
18
|
-
C a1: v1, a2: "v2"
|
19
|
-
D {
|
20
|
-
E a1: 5
|
21
|
-
}
|
22
|
-
|F bla
|
23
|
-
))
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_child_label
|
27
|
-
assert_context(
|
28
|
-
%Q(
|
29
|
-
A {
|
30
|
-
sub:
|
31
|
-
B {
|
32
|
-
F bla|
|
33
|
-
),
|
34
|
-
%Q(
|
35
|
-
A {
|
36
|
-
sub:
|
37
|
-
B {
|
38
|
-
C a1: v1, a2: "v2"
|
39
|
-
D {
|
40
|
-
E a1: 5
|
41
|
-
}
|
42
|
-
F bla|
|
43
|
-
))
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_child_label_array
|
47
|
-
assert_context(
|
48
|
-
%Q(
|
49
|
-
A {
|
50
|
-
sub: [
|
51
|
-
B {
|
52
|
-
F| bla
|
53
|
-
),
|
54
|
-
%Q(
|
55
|
-
A {
|
56
|
-
sub: [
|
57
|
-
B {
|
58
|
-
C
|
59
|
-
}
|
60
|
-
B {
|
61
|
-
C a1: v1, a2: "v2"
|
62
|
-
D {
|
63
|
-
E a1: 5
|
64
|
-
}
|
65
|
-
F| bla
|
66
|
-
))
|
67
|
-
end
|
68
|
-
|
69
|
-
def
|
70
|
-
assert_context(
|
71
|
-
%Q(
|
72
|
-
A {
|
73
|
-
B
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
B
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'rtext/frontend/context'
|
5
|
+
|
6
|
+
class ContextTest < MiniTest::Test
|
7
|
+
|
8
|
+
def test_simple
|
9
|
+
assert_context(
|
10
|
+
%Q(
|
11
|
+
A {
|
12
|
+
B {
|
13
|
+
|F bla
|
14
|
+
),
|
15
|
+
%Q(
|
16
|
+
A {
|
17
|
+
B {
|
18
|
+
C a1: v1, a2: "v2"
|
19
|
+
D {
|
20
|
+
E a1: 5
|
21
|
+
}
|
22
|
+
|F bla
|
23
|
+
))
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_child_label
|
27
|
+
assert_context(
|
28
|
+
%Q(
|
29
|
+
A {
|
30
|
+
sub:
|
31
|
+
B {
|
32
|
+
F bla|
|
33
|
+
),
|
34
|
+
%Q(
|
35
|
+
A {
|
36
|
+
sub:
|
37
|
+
B {
|
38
|
+
C a1: v1, a2: "v2"
|
39
|
+
D {
|
40
|
+
E a1: 5
|
41
|
+
}
|
42
|
+
F bla|
|
43
|
+
))
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_child_label_array
|
47
|
+
assert_context(
|
48
|
+
%Q(
|
49
|
+
A {
|
50
|
+
sub: [
|
51
|
+
B {
|
52
|
+
F| bla
|
53
|
+
),
|
54
|
+
%Q(
|
55
|
+
A {
|
56
|
+
sub: [
|
57
|
+
B {
|
58
|
+
C
|
59
|
+
}
|
60
|
+
B {
|
61
|
+
C a1: v1, a2: "v2"
|
62
|
+
D {
|
63
|
+
E a1: 5
|
64
|
+
}
|
65
|
+
F| bla
|
66
|
+
))
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_child_label_array2
|
70
|
+
assert_context(
|
71
|
+
%Q(
|
72
|
+
A {
|
73
|
+
B |
|
74
|
+
),
|
75
|
+
%Q(
|
76
|
+
A {
|
77
|
+
sub: [
|
78
|
+
]
|
79
|
+
B |
|
80
|
+
))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_child_label_array3
|
84
|
+
assert_context(
|
85
|
+
%Q(
|
86
|
+
A {
|
87
|
+
sub: [
|
88
|
+
] |
|
89
|
+
),
|
90
|
+
%Q(
|
91
|
+
A {
|
92
|
+
sub: [
|
93
|
+
] |
|
94
|
+
))
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def test_ignore_child_lables
|
99
|
+
assert_context(
|
100
|
+
%Q(
|
101
|
+
A {
|
102
|
+
B {
|
103
|
+
F bl|a
|
104
|
+
),
|
105
|
+
%Q(
|
106
|
+
A {
|
107
|
+
B {
|
108
|
+
sub:
|
109
|
+
C a1: v1, a2: "v2"
|
110
|
+
sub2: [
|
111
|
+
D {
|
112
|
+
E a1: 5
|
113
|
+
}
|
114
|
+
]
|
115
|
+
F bl|a
|
116
|
+
))
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_linebreak
|
120
|
+
assert_context(
|
121
|
+
%Q(
|
122
|
+
A {
|
123
|
+
B {
|
124
|
+
C name, a1: v1, a2: "v2"|
|
125
|
+
),
|
126
|
+
%Q(
|
127
|
+
A {
|
128
|
+
B {
|
129
|
+
C name,
|
130
|
+
a1: v1,
|
131
|
+
a2: "v2"|
|
132
|
+
))
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_linebreak_arg_array
|
136
|
+
assert_context(
|
137
|
+
%Q(
|
138
|
+
A {
|
139
|
+
B {
|
140
|
+
C name, a1: [ v1, v2 ], a2: |5
|
141
|
+
),
|
142
|
+
%Q(
|
143
|
+
A {
|
144
|
+
B {
|
145
|
+
C name,
|
146
|
+
a1: [
|
147
|
+
v1,
|
148
|
+
v2
|
149
|
+
],
|
150
|
+
a2: |5
|
151
|
+
))
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_linebreak_empty_last_line
|
155
|
+
assert_context(
|
156
|
+
%Q(
|
157
|
+
A {
|
158
|
+
B name, |
|
159
|
+
),
|
160
|
+
%Q(
|
161
|
+
A {
|
162
|
+
B name,
|
163
|
+
|
|
164
|
+
))
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_linebreak_empty_last_line2
|
168
|
+
assert_context(
|
169
|
+
%Q(
|
170
|
+
A {
|
171
|
+
B name, |
|
172
|
+
),
|
173
|
+
%Q(
|
174
|
+
A {
|
175
|
+
B name,
|
176
|
+
|
|
177
|
+
))
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_linebreak_empty_lines
|
181
|
+
assert_context(
|
182
|
+
%Q(
|
183
|
+
A {
|
184
|
+
B name, a1: |
|
185
|
+
),
|
186
|
+
%Q(
|
187
|
+
A {
|
188
|
+
B name,
|
189
|
+
|
190
|
+
a1: |
|
191
|
+
))
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_linebreak_first_arg_array
|
195
|
+
assert_context(
|
196
|
+
%Q(
|
197
|
+
A {
|
198
|
+
B [ |
|
199
|
+
),
|
200
|
+
%Q(
|
201
|
+
A {
|
202
|
+
B [
|
203
|
+
|
|
204
|
+
))
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_linebreak_first_arg_array2
|
208
|
+
assert_context(
|
209
|
+
%Q(
|
210
|
+
A {
|
211
|
+
B [ 2, |
|
212
|
+
),
|
213
|
+
%Q(
|
214
|
+
A {
|
215
|
+
B [
|
216
|
+
2,
|
217
|
+
|
|
218
|
+
))
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_linebreak_first_arg_array3
|
222
|
+
assert_context(
|
223
|
+
%Q(
|
224
|
+
A {
|
225
|
+
B [ 2 ], |
|
226
|
+
),
|
227
|
+
%Q(
|
228
|
+
A {
|
229
|
+
B [
|
230
|
+
2
|
231
|
+
], |
|
232
|
+
))
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_linebreak_backslash
|
236
|
+
assert_context(
|
237
|
+
%Q(
|
238
|
+
A {
|
239
|
+
B arg: 1,|
|
240
|
+
),
|
241
|
+
%Q(
|
242
|
+
A {
|
243
|
+
B \\
|
244
|
+
arg: 1,|
|
245
|
+
))
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_linebreak_whitespace_after_backslash
|
249
|
+
assert_context(
|
250
|
+
%Q(
|
251
|
+
A {
|
252
|
+
B arg: 1,|
|
253
|
+
),
|
254
|
+
%Q(
|
255
|
+
A {
|
256
|
+
B \\
|
257
|
+
arg: 1,|
|
258
|
+
))
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_comment_annotation
|
262
|
+
assert_context(
|
263
|
+
%Q(
|
264
|
+
A {
|
265
|
+
B {
|
266
|
+
|F bla
|
267
|
+
),
|
268
|
+
%Q(
|
269
|
+
A {
|
270
|
+
# bla
|
271
|
+
B {
|
272
|
+
C a1: v1, a2: "v2"
|
273
|
+
# bla
|
274
|
+
D {
|
275
|
+
E a1: 5
|
276
|
+
}
|
277
|
+
@ anno
|
278
|
+
|F bla
|
279
|
+
))
|
280
|
+
end
|
281
|
+
|
282
|
+
def assert_context(expected, text)
|
283
|
+
# remove first and last lines
|
284
|
+
# these are empty because of the use of %Q
|
285
|
+
exp_lines = expected.split("\n")[1..-2]
|
286
|
+
exp_col = exp_lines.last.index("|")
|
287
|
+
exp_lines.last.sub!("|","")
|
288
|
+
in_lines = text.split("\n")[1..-2]
|
289
|
+
in_col = in_lines.last.index("|")
|
290
|
+
in_lines.last.sub!("|","")
|
291
|
+
ctx = RText::Frontend::Context.new
|
292
|
+
lines, out_col = ctx.extract(in_lines, in_col)
|
293
|
+
assert_equal exp_lines, lines
|
294
|
+
if exp_col && in_col
|
295
|
+
assert_equal exp_col, out_col
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
|