rtext 0.8.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +120 -89
- data/Project.yaml +15 -0
- data/RText_Protocol +47 -4
- 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 +130 -56
- data/lib/rtext/instantiator.rb +11 -3
- data/lib/rtext/language.rb +5 -5
- data/lib/rtext/serializer.rb +3 -3
- data/lib/rtext/service.rb +281 -253
- data/lib/rtext/tokenizer.rb +2 -2
- metadata +33 -33
- data/Rakefile +0 -46
- data/test/completer_test.rb +0 -606
- data/test/context_builder_test.rb +0 -948
- data/test/frontend/context_test.rb +0 -301
- data/test/instantiator_test.rb +0 -1704
- data/test/integration/backend.out +0 -13
- data/test/integration/crash_on_request_editor.rb +0 -12
- data/test/integration/ecore_editor.rb +0 -50
- data/test/integration/frontend.log +0 -38203
- data/test/integration/model/invalid_encoding.invenc +0 -2
- data/test/integration/model/test.crash_on_request +0 -18
- data/test/integration/model/test.crashing_backend +0 -18
- data/test/integration/model/test.dont_open_socket +0 -0
- data/test/integration/model/test.invalid_cmd_line +0 -0
- data/test/integration/model/test.not_in_rtext +0 -0
- data/test/integration/model/test_large_with_errors.ect3 +0 -43523
- data/test/integration/model/test_metamodel.ect +0 -24
- data/test/integration/model/test_metamodel2.ect +0 -5
- data/test/integration/model/test_metamodel3.ect4 +0 -7
- data/test/integration/model/test_metamodel_error.ect2 +0 -3
- data/test/integration/model/test_metamodel_ok.ect2 +0 -18
- data/test/integration/test.rb +0 -966
- data/test/link_detector_test.rb +0 -287
- data/test/message_helper_test.rb +0 -118
- data/test/rtext_test.rb +0 -11
- data/test/serializer_test.rb +0 -1004
- data/test/tokenizer_test.rb +0 -173
@@ -1,301 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rtext/frontend/context'
|
5
|
-
|
6
|
-
class ContextTest < Test::Unit::TestCase
|
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
|
-
|