rtext 0.8.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +116 -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 +8 -4
- 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 +1 -1
- metadata +32 -44
- 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 -1735
- 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 -40502
- 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
data/test/integration/test.rb
DELETED
@@ -1,966 +0,0 @@
|
|
1
|
-
# encoding: binary
|
2
|
-
$:.unshift(File.dirname(__FILE__)+"/../../lib")
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rtext/frontend/connector_manager'
|
5
|
-
require 'rtext/frontend/context'
|
6
|
-
require 'logger'
|
7
|
-
|
8
|
-
class IntegrationTest < Test::Unit::TestCase
|
9
|
-
|
10
|
-
ModelFile = File.dirname(__FILE__)+"/model/test_metamodel.ect"
|
11
|
-
ModelFile2 = File.dirname(__FILE__)+"/model/test_metamodel2.ect"
|
12
|
-
ModelFile3 = File.dirname(__FILE__)+"/model/test_metamodel3.ect4"
|
13
|
-
LargeWithErrorsFile = File.dirname(__FILE__)+"/model/test_large_with_errors.ect3"
|
14
|
-
InvalidEncodingFile = File.dirname(__FILE__)+"/model/invalid_encoding.invenc"
|
15
|
-
NotInRTextFile = File.dirname(__FILE__)+"/model/test.not_in_rtext"
|
16
|
-
InvalidCmdLineFile = File.dirname(__FILE__)+"/model/test.invalid_cmd_line"
|
17
|
-
CrashingBackendFile = File.dirname(__FILE__)+"/model/test.crashing_backend"
|
18
|
-
DontOpenSocketFile = File.dirname(__FILE__)+"/model/test.dont_open_socket"
|
19
|
-
CrashOnRequestFile = File.dirname(__FILE__)+"/model/test.crash_on_request"
|
20
|
-
|
21
|
-
def setup_connector(file)
|
22
|
-
@infile = file
|
23
|
-
outfile = File.dirname(__FILE__)+"/backend.out"
|
24
|
-
logfile = File.dirname(__FILE__)+"/frontend.log"
|
25
|
-
logger = Logger.new(logfile)
|
26
|
-
File.unlink(outfile) if File.exist?(outfile)
|
27
|
-
@connection_timeout = false
|
28
|
-
man = RText::Frontend::ConnectorManager.new(
|
29
|
-
:logger => logger,
|
30
|
-
:keep_outfile => true,
|
31
|
-
:connection_timeout => 1,
|
32
|
-
:outfile_provider => lambda { File.expand_path(outfile) },
|
33
|
-
:connect_callback => lambda do |connector, state|
|
34
|
-
@connection_timeout = true if state == :timeout
|
35
|
-
end)
|
36
|
-
@con = man.connector_for_file(@infile)
|
37
|
-
end
|
38
|
-
|
39
|
-
def teardown
|
40
|
-
@con.stop if @con
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_non_existing_file
|
44
|
-
setup_connector("this is not a file")
|
45
|
-
assert_nil @con
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_not_in_rtext_file
|
49
|
-
setup_connector(NotInRTextFile)
|
50
|
-
assert_nil @con
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_invalid_command_line
|
54
|
-
setup_connector(InvalidCmdLineFile)
|
55
|
-
assert @con
|
56
|
-
response = load_model
|
57
|
-
assert @connection_timeout
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_crashing_backend
|
61
|
-
setup_connector(CrashingBackendFile)
|
62
|
-
assert @con
|
63
|
-
response = load_model
|
64
|
-
assert @connection_timeout
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_backend_doesnt_open_socket
|
68
|
-
setup_connector(DontOpenSocketFile)
|
69
|
-
assert @con
|
70
|
-
response = load_model
|
71
|
-
assert @connection_timeout
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_backend_crash_on_request
|
75
|
-
setup_connector(CrashOnRequestFile)
|
76
|
-
assert @con
|
77
|
-
response = load_model
|
78
|
-
assert_equal [], response["problems"]
|
79
|
-
response = @con.execute_command({"command" => "link_targets", "context" => [], "column" => 1})
|
80
|
-
assert_equal :timeout, response
|
81
|
-
end
|
82
|
-
|
83
|
-
# simulate external encoding utf-8 (-E in .rext) containing a iso-8859-1 character
|
84
|
-
def test_invalid_encoding
|
85
|
-
setup_connector(InvalidEncodingFile)
|
86
|
-
response = load_model
|
87
|
-
assert_equal "response", response["type"]
|
88
|
-
assert_equal [], response["problems"]
|
89
|
-
text = %Q(EPackage "iso-8859-1 umlaut: \xe4",| nsPrefix: "")
|
90
|
-
context = build_context(text)
|
91
|
-
assert_completions context, [
|
92
|
-
"nsPrefix:",
|
93
|
-
"nsURI:"
|
94
|
-
]
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_loadmodel
|
98
|
-
setup_connector(ModelFile)
|
99
|
-
response = load_model
|
100
|
-
assert_equal "response", response["type"]
|
101
|
-
assert_equal [], response["problems"]
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_loadmodel_large_with_errors
|
105
|
-
setup_connector(LargeWithErrorsFile)
|
106
|
-
response = load_model
|
107
|
-
assert_equal "response", response["type"]
|
108
|
-
assert_equal 43523, response["problems"].first["problems"].size
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_unknown_command
|
112
|
-
setup_connector(ModelFile)
|
113
|
-
response = load_model
|
114
|
-
response = @con.execute_command({"command" => "unknown"})
|
115
|
-
assert_equal "unknown_command_error", response["type"]
|
116
|
-
end
|
117
|
-
|
118
|
-
#TODO: connector restart when .rtext file changes
|
119
|
-
|
120
|
-
def test_complete_first_line
|
121
|
-
setup_connector(ModelFile)
|
122
|
-
load_model
|
123
|
-
context = build_context <<-END
|
124
|
-
|EPackage StatemachineMM {
|
125
|
-
END
|
126
|
-
assert_completions context, [
|
127
|
-
"EPackage"
|
128
|
-
]
|
129
|
-
context = build_context <<-END
|
130
|
-
EPackage| StatemachineMM {
|
131
|
-
END
|
132
|
-
assert_completions context, [
|
133
|
-
"EPackage"
|
134
|
-
]
|
135
|
-
context = build_context <<-END
|
136
|
-
EPackage |StatemachineMM {
|
137
|
-
END
|
138
|
-
assert_completions context, [
|
139
|
-
"name",
|
140
|
-
"nsPrefix:",
|
141
|
-
"nsURI:"
|
142
|
-
]
|
143
|
-
context = build_context <<-END
|
144
|
-
EPackage S|tatemachineMM {
|
145
|
-
END
|
146
|
-
assert_completions context, [
|
147
|
-
"name",
|
148
|
-
"nsPrefix:",
|
149
|
-
"nsURI:"
|
150
|
-
]
|
151
|
-
context = build_context <<-END
|
152
|
-
EPackage StatemachineMM| {
|
153
|
-
END
|
154
|
-
assert_completions context, [
|
155
|
-
"name",
|
156
|
-
"nsPrefix:",
|
157
|
-
"nsURI:"
|
158
|
-
]
|
159
|
-
context = build_context <<-END
|
160
|
-
EPackage StatemachineMM |{
|
161
|
-
END
|
162
|
-
assert_completions context, [
|
163
|
-
]
|
164
|
-
context = build_context <<-END
|
165
|
-
EPackage StatemachineMM {|
|
166
|
-
END
|
167
|
-
# these columns don't exist
|
168
|
-
assert_completions context, []
|
169
|
-
context = build_context({:col => 27}, "EPackage StatemachineMM {")
|
170
|
-
assert_completions context, []
|
171
|
-
context = build_context({:col => 28}, "EPackage StatemachineMM {")
|
172
|
-
assert_completions context, []
|
173
|
-
context = build_context({:col => 100}, "EPackage StatemachineMM {")
|
174
|
-
assert_completions context, []
|
175
|
-
# before first column is like first column
|
176
|
-
context = build_context({:col => 0}, "EPackage StatemachineMM {")
|
177
|
-
assert_completions context, [
|
178
|
-
"EPackage"
|
179
|
-
]
|
180
|
-
context = build_context({:col => -1}, "EPackage StatemachineMM {")
|
181
|
-
assert_completions context, [
|
182
|
-
"EPackage"
|
183
|
-
]
|
184
|
-
context = build_context({:col => -100}, "EPackage StatemachineMM {")
|
185
|
-
assert_completions context, [
|
186
|
-
"EPackage"
|
187
|
-
]
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_nested_command
|
191
|
-
setup_connector(ModelFile)
|
192
|
-
load_model
|
193
|
-
context = build_context <<-END
|
194
|
-
EPackage StatemachineMM {
|
195
|
-
| EClass State, abstract: true {
|
196
|
-
END
|
197
|
-
assert_completions context, [
|
198
|
-
"EAnnotation",
|
199
|
-
"EClass",
|
200
|
-
"EClassifier",
|
201
|
-
"EDataType",
|
202
|
-
"EEnum",
|
203
|
-
"EGenericType",
|
204
|
-
"EPackage"
|
205
|
-
]
|
206
|
-
context = build_context <<-END
|
207
|
-
EPackage StatemachineMM {
|
208
|
-
|EClass State, abstract: true {
|
209
|
-
END
|
210
|
-
assert_completions context, [
|
211
|
-
"EAnnotation",
|
212
|
-
"EClass",
|
213
|
-
"EClassifier",
|
214
|
-
"EDataType",
|
215
|
-
"EEnum",
|
216
|
-
"EGenericType",
|
217
|
-
"EPackage"
|
218
|
-
]
|
219
|
-
context = build_context <<-END
|
220
|
-
EPackage StatemachineMM {
|
221
|
-
EC|lass State, abstract: true {
|
222
|
-
END
|
223
|
-
assert_completions context, [
|
224
|
-
"EAnnotation",
|
225
|
-
"EClass",
|
226
|
-
"EClassifier",
|
227
|
-
"EDataType",
|
228
|
-
"EEnum",
|
229
|
-
"EGenericType",
|
230
|
-
"EPackage"
|
231
|
-
]
|
232
|
-
context = build_context <<-END
|
233
|
-
EPackage StatemachineMM {
|
234
|
-
EClass| State, abstract: true {
|
235
|
-
END
|
236
|
-
assert_completions context, [
|
237
|
-
"EAnnotation",
|
238
|
-
"EClass",
|
239
|
-
"EClassifier",
|
240
|
-
"EDataType",
|
241
|
-
"EEnum",
|
242
|
-
"EGenericType",
|
243
|
-
"EPackage"
|
244
|
-
]
|
245
|
-
context = build_context <<-END
|
246
|
-
EPackage StatemachineMM {
|
247
|
-
EClass |State, abstract: true {
|
248
|
-
END
|
249
|
-
assert_completions context, [
|
250
|
-
"name",
|
251
|
-
"abstract:",
|
252
|
-
"interface:",
|
253
|
-
"eSuperTypes:",
|
254
|
-
"instanceClassName:"
|
255
|
-
]
|
256
|
-
context = build_context <<-END
|
257
|
-
EPackage StatemachineMM {
|
258
|
-
EClass S|tate, abstract: true {
|
259
|
-
END
|
260
|
-
assert_completions context, [
|
261
|
-
"name",
|
262
|
-
"abstract:",
|
263
|
-
"interface:",
|
264
|
-
"eSuperTypes:",
|
265
|
-
"instanceClassName:"
|
266
|
-
]
|
267
|
-
context = build_context <<-END
|
268
|
-
EPackage StatemachineMM {
|
269
|
-
EClass State|, abstract: true {
|
270
|
-
END
|
271
|
-
assert_completions context, [
|
272
|
-
"name",
|
273
|
-
"abstract:",
|
274
|
-
"interface:",
|
275
|
-
"eSuperTypes:",
|
276
|
-
"instanceClassName:"
|
277
|
-
]
|
278
|
-
context = build_context <<-END
|
279
|
-
EPackage StatemachineMM {
|
280
|
-
EClass State,| abstract: true {
|
281
|
-
END
|
282
|
-
assert_completions context, [
|
283
|
-
"abstract:",
|
284
|
-
"interface:",
|
285
|
-
"eSuperTypes:",
|
286
|
-
"instanceClassName:"
|
287
|
-
]
|
288
|
-
context = build_context <<-END
|
289
|
-
EPackage StatemachineMM {
|
290
|
-
EClass State, |abstract: true {
|
291
|
-
END
|
292
|
-
assert_completions context, [
|
293
|
-
"abstract:",
|
294
|
-
"interface:",
|
295
|
-
"eSuperTypes:",
|
296
|
-
"instanceClassName:"
|
297
|
-
]
|
298
|
-
context = build_context <<-END
|
299
|
-
EPackage StatemachineMM {
|
300
|
-
EClass State, a|bstract: true {
|
301
|
-
END
|
302
|
-
assert_completions context, [
|
303
|
-
"abstract:",
|
304
|
-
"interface:",
|
305
|
-
"eSuperTypes:",
|
306
|
-
"instanceClassName:"
|
307
|
-
]
|
308
|
-
context = build_context <<-END
|
309
|
-
EPackage StatemachineMM {
|
310
|
-
EClass State, abstract:| true {
|
311
|
-
END
|
312
|
-
assert_completions context, [
|
313
|
-
"true",
|
314
|
-
"false"
|
315
|
-
]
|
316
|
-
context = build_context <<-END
|
317
|
-
EPackage StatemachineMM {
|
318
|
-
EClass State, abstract: |true {
|
319
|
-
END
|
320
|
-
assert_completions context, [
|
321
|
-
"true",
|
322
|
-
"false"
|
323
|
-
]
|
324
|
-
context = build_context <<-END
|
325
|
-
EPackage StatemachineMM {
|
326
|
-
EClass State, abstract: t|rue {
|
327
|
-
END
|
328
|
-
assert_completions context, [
|
329
|
-
"true",
|
330
|
-
"false"
|
331
|
-
]
|
332
|
-
context = build_context <<-END
|
333
|
-
EPackage StatemachineMM {
|
334
|
-
EClass State, abstract: true| {
|
335
|
-
END
|
336
|
-
assert_completions context, [
|
337
|
-
"true",
|
338
|
-
"false"
|
339
|
-
]
|
340
|
-
context = build_context <<-END
|
341
|
-
EPackage StatemachineMM {
|
342
|
-
EClass State, abstract: true |{
|
343
|
-
END
|
344
|
-
assert_completions context, [
|
345
|
-
]
|
346
|
-
context = build_context <<-END
|
347
|
-
EPackage StatemachineMM {
|
348
|
-
EClass State, abstract: true {|
|
349
|
-
END
|
350
|
-
assert_completions context, [
|
351
|
-
]
|
352
|
-
end
|
353
|
-
|
354
|
-
def test_complete_feature_after_linebreak
|
355
|
-
setup_connector(ModelFile)
|
356
|
-
load_model
|
357
|
-
context = build_context <<-END
|
358
|
-
EPackage StatemachineMM {
|
359
|
-
EClass State, abstract: true {
|
360
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
361
|
-
EReference parent,
|
362
|
-
|eType: /StatemachineMM/CompositeState,
|
363
|
-
END
|
364
|
-
assert_completions context, [
|
365
|
-
"containment:",
|
366
|
-
"resolveProxies:",
|
367
|
-
"eOpposite:",
|
368
|
-
"changeable:",
|
369
|
-
"defaultValueLiteral:",
|
370
|
-
"derived:",
|
371
|
-
"transient:",
|
372
|
-
"unsettable:",
|
373
|
-
"volatile:",
|
374
|
-
"lowerBound:",
|
375
|
-
"ordered:",
|
376
|
-
"unique:",
|
377
|
-
"upperBound:",
|
378
|
-
"eType:"
|
379
|
-
]
|
380
|
-
end
|
381
|
-
|
382
|
-
def test_complete_reference_after_linebreak
|
383
|
-
setup_connector(ModelFile)
|
384
|
-
load_model
|
385
|
-
context = build_context <<-END
|
386
|
-
EPackage StatemachineMM {
|
387
|
-
EClass State, abstract: true {
|
388
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
389
|
-
EReference parent,
|
390
|
-
eType: |/StatemachineMM/CompositeState,
|
391
|
-
END
|
392
|
-
assert_completions context, [
|
393
|
-
"/StatemachineMM/CompositeState",
|
394
|
-
"/StatemachineMM/SimpleState",
|
395
|
-
"/StatemachineMM/State",
|
396
|
-
"/StatemachineMM/StringType",
|
397
|
-
"/StatemachineMM/Transition",
|
398
|
-
"/StatemachineMM2/SimpleState",
|
399
|
-
"/StatemachineMM2/State"
|
400
|
-
]
|
401
|
-
end
|
402
|
-
|
403
|
-
def test_complete_command_after_linebreak
|
404
|
-
setup_connector(ModelFile)
|
405
|
-
load_model
|
406
|
-
context = build_context <<-END
|
407
|
-
EPackage StatemachineMM {
|
408
|
-
EClass State, abstract: true {
|
409
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
410
|
-
EReference parent,
|
411
|
-
eType: /StatemachineMM/CompositeState,
|
412
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
413
|
-
}
|
414
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
415
|
-
EClass CompositeState,
|
416
|
-
eSuperTypes: [
|
417
|
-
/StatemachineMM/State
|
418
|
-
],
|
419
|
-
abstract: false {
|
420
|
-
|EReference substates, upperBound: -1, containment: true, eType: /StatemachineMM/State, eOpposite: /StatemachineMM/State/parent
|
421
|
-
END
|
422
|
-
assert_completions context, [
|
423
|
-
"EAnnotation",
|
424
|
-
"EAttribute",
|
425
|
-
"EOperation",
|
426
|
-
"EReference",
|
427
|
-
"EStructuralFeature"
|
428
|
-
]
|
429
|
-
end
|
430
|
-
|
431
|
-
def test_complete_value_after_linebreak
|
432
|
-
setup_connector(ModelFile)
|
433
|
-
load_model
|
434
|
-
context = build_context <<-END
|
435
|
-
EPackage StatemachineMM {
|
436
|
-
EClass State, abstract: true {
|
437
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
438
|
-
EReference parent,
|
439
|
-
eType: /StatemachineMM/CompositeState,
|
440
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
441
|
-
}
|
442
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
443
|
-
EClass CompositeState,
|
444
|
-
eSuperTypes: [
|
445
|
-
/StatemachineMM/State
|
446
|
-
],
|
447
|
-
abstract: |false {
|
448
|
-
END
|
449
|
-
assert_completions context, [
|
450
|
-
"true",
|
451
|
-
"false"
|
452
|
-
]
|
453
|
-
end
|
454
|
-
|
455
|
-
def test_complete_in_array_after_linebreak
|
456
|
-
setup_connector(ModelFile)
|
457
|
-
load_model
|
458
|
-
context = build_context <<-END
|
459
|
-
EPackage StatemachineMM {
|
460
|
-
EClass State, abstract: true {
|
461
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
462
|
-
EReference parent,
|
463
|
-
eType: /StatemachineMM/CompositeState,
|
464
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
465
|
-
}
|
466
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
467
|
-
EClass CompositeState,
|
468
|
-
eSuperTypes: [
|
469
|
-
|/StatemachineMM/State
|
470
|
-
END
|
471
|
-
assert_completions context, [
|
472
|
-
"/StatemachineMM/CompositeState",
|
473
|
-
"/StatemachineMM/SimpleState",
|
474
|
-
"/StatemachineMM/State",
|
475
|
-
"/StatemachineMM/Transition",
|
476
|
-
"/StatemachineMM2/SimpleState",
|
477
|
-
"/StatemachineMM2/State"
|
478
|
-
]
|
479
|
-
end
|
480
|
-
|
481
|
-
def test_complete_in_array_after_linebreak2
|
482
|
-
setup_connector(ModelFile)
|
483
|
-
load_model
|
484
|
-
context = build_context <<-END
|
485
|
-
EPackage StatemachineMM {
|
486
|
-
EClass State, abstract: true {
|
487
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
488
|
-
EReference parent,
|
489
|
-
eType: /StatemachineMM/CompositeState,
|
490
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
491
|
-
}
|
492
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
493
|
-
EClass CompositeState,
|
494
|
-
eSuperTypes: [
|
495
|
-
/StatemachineMM/State
|
496
|
-
|],
|
497
|
-
END
|
498
|
-
assert_completions context, [
|
499
|
-
]
|
500
|
-
end
|
501
|
-
|
502
|
-
def test_complete_after_backslash
|
503
|
-
setup_connector(ModelFile3)
|
504
|
-
load_model
|
505
|
-
context = build_context <<-END
|
506
|
-
EPackage StatemachineMM3 {
|
507
|
-
EClass State
|
508
|
-
EClass \\
|
509
|
-
|SimpleState,
|
510
|
-
END
|
511
|
-
assert_completions context, [
|
512
|
-
"name",
|
513
|
-
"abstract:",
|
514
|
-
"interface:",
|
515
|
-
"eSuperTypes:",
|
516
|
-
"instanceClassName:"
|
517
|
-
]
|
518
|
-
end
|
519
|
-
|
520
|
-
def test_complete_after_backslash2
|
521
|
-
setup_connector(ModelFile3)
|
522
|
-
load_model
|
523
|
-
context = build_context <<-END
|
524
|
-
EPackage StatemachineMM3 {
|
525
|
-
EClass State
|
526
|
-
EClass \\
|
527
|
-
SimpleState,
|
528
|
-
|eSuperTypes: [/StatemachineMM3/State]
|
529
|
-
END
|
530
|
-
assert_completions context, [
|
531
|
-
"abstract:",
|
532
|
-
"interface:",
|
533
|
-
"eSuperTypes:",
|
534
|
-
"instanceClassName:"
|
535
|
-
]
|
536
|
-
end
|
537
|
-
|
538
|
-
def test_link_target_after_backslash
|
539
|
-
setup_connector(ModelFile3)
|
540
|
-
load_model
|
541
|
-
context = build_context <<-END
|
542
|
-
EPackage StatemachineMM3 {
|
543
|
-
EClass State
|
544
|
-
EClass \\
|
545
|
-
SimpleState,
|
546
|
-
eSuperTypes: [/S|tatemachineMM3/State]
|
547
|
-
END
|
548
|
-
assert_link_targets context, :file => ModelFile3, :begin => 45, :end => 66, :targets => [
|
549
|
-
{"file"=> File.expand_path(ModelFile3),
|
550
|
-
"line"=>2,
|
551
|
-
"display"=>"/StatemachineMM3/State [EClass]"}
|
552
|
-
]
|
553
|
-
end
|
554
|
-
|
555
|
-
def test_reference_completion
|
556
|
-
setup_connector(ModelFile)
|
557
|
-
load_model
|
558
|
-
context = build_context <<-END
|
559
|
-
EPackage StatemachineMM {
|
560
|
-
EClass State, abstract: true {
|
561
|
-
EAttribute name, eType: |/StatemachineMM/StringType
|
562
|
-
END
|
563
|
-
assert_completions context, [
|
564
|
-
"/StatemachineMM/CompositeState",
|
565
|
-
"/StatemachineMM/SimpleState",
|
566
|
-
"/StatemachineMM/State",
|
567
|
-
"/StatemachineMM/StringType",
|
568
|
-
"/StatemachineMM/Transition",
|
569
|
-
"/StatemachineMM2/SimpleState",
|
570
|
-
"/StatemachineMM2/State",
|
571
|
-
]
|
572
|
-
context = build_context <<-END
|
573
|
-
EPackage StatemachineMM {
|
574
|
-
EClass State, abstract: true {
|
575
|
-
EAttribute name, eType: /StatemachineMM/|StringType
|
576
|
-
END
|
577
|
-
assert_completions context, [
|
578
|
-
"/StatemachineMM/CompositeState",
|
579
|
-
"/StatemachineMM/SimpleState",
|
580
|
-
"/StatemachineMM/State",
|
581
|
-
"/StatemachineMM/StringType",
|
582
|
-
"/StatemachineMM/Transition",
|
583
|
-
"/StatemachineMM2/SimpleState",
|
584
|
-
"/StatemachineMM2/State",
|
585
|
-
]
|
586
|
-
context = build_context <<-END
|
587
|
-
EPackage StatemachineMM {
|
588
|
-
EClass State, abstract: true {
|
589
|
-
EAttribute name, eType: /StatemachineMM/St|ringType
|
590
|
-
END
|
591
|
-
assert_completions context, [
|
592
|
-
"/StatemachineMM/CompositeState",
|
593
|
-
"/StatemachineMM/SimpleState",
|
594
|
-
"/StatemachineMM/State",
|
595
|
-
"/StatemachineMM/StringType",
|
596
|
-
"/StatemachineMM/Transition",
|
597
|
-
"/StatemachineMM2/SimpleState",
|
598
|
-
"/StatemachineMM2/State",
|
599
|
-
]
|
600
|
-
context = build_context <<-END
|
601
|
-
EPackage StatemachineMM {
|
602
|
-
EClass State, abstract: true {
|
603
|
-
EAttribute name, eType: /StatemachineMM/StringType|
|
604
|
-
END
|
605
|
-
assert_completions context, [
|
606
|
-
"/StatemachineMM/CompositeState",
|
607
|
-
"/StatemachineMM/SimpleState",
|
608
|
-
"/StatemachineMM/State",
|
609
|
-
"/StatemachineMM/StringType",
|
610
|
-
"/StatemachineMM/Transition",
|
611
|
-
"/StatemachineMM2/SimpleState",
|
612
|
-
"/StatemachineMM2/State",
|
613
|
-
]
|
614
|
-
end
|
615
|
-
|
616
|
-
def test_reference_completion_in_array
|
617
|
-
setup_connector(ModelFile)
|
618
|
-
load_model
|
619
|
-
context = build_context <<-END
|
620
|
-
EPackage StatemachineMM {
|
621
|
-
EClass State, abstract: true {
|
622
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
623
|
-
EReference parent,
|
624
|
-
eType: /StatemachineMM/CompositeState,
|
625
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
626
|
-
}
|
627
|
-
EClass SimpleState, eSuperTypes: [|/StatemachineMM/State]
|
628
|
-
END
|
629
|
-
assert_completions context, [
|
630
|
-
"/StatemachineMM/CompositeState",
|
631
|
-
"/StatemachineMM/SimpleState",
|
632
|
-
"/StatemachineMM/State",
|
633
|
-
"/StatemachineMM/Transition",
|
634
|
-
"/StatemachineMM2/SimpleState",
|
635
|
-
"/StatemachineMM2/State",
|
636
|
-
]
|
637
|
-
context = build_context <<-END
|
638
|
-
EPackage StatemachineMM {
|
639
|
-
EClass State, abstract: true {
|
640
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
641
|
-
EReference parent,
|
642
|
-
eType: /StatemachineMM/CompositeState,
|
643
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
644
|
-
}
|
645
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/S|tate]
|
646
|
-
END
|
647
|
-
assert_completions context, [
|
648
|
-
"/StatemachineMM/CompositeState",
|
649
|
-
"/StatemachineMM/SimpleState",
|
650
|
-
"/StatemachineMM/State",
|
651
|
-
"/StatemachineMM/Transition",
|
652
|
-
"/StatemachineMM2/SimpleState",
|
653
|
-
"/StatemachineMM2/State",
|
654
|
-
]
|
655
|
-
context = build_context <<-END
|
656
|
-
EPackage StatemachineMM {
|
657
|
-
EClass State, abstract: true {
|
658
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
659
|
-
EReference parent,
|
660
|
-
eType: /StatemachineMM/CompositeState,
|
661
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
662
|
-
}
|
663
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State|]
|
664
|
-
END
|
665
|
-
assert_completions context, [
|
666
|
-
"/StatemachineMM/CompositeState",
|
667
|
-
"/StatemachineMM/SimpleState",
|
668
|
-
"/StatemachineMM/State",
|
669
|
-
"/StatemachineMM/Transition",
|
670
|
-
"/StatemachineMM2/SimpleState",
|
671
|
-
"/StatemachineMM2/State",
|
672
|
-
]
|
673
|
-
context = build_context <<-END
|
674
|
-
EPackage StatemachineMM {
|
675
|
-
EClass State, abstract: true {
|
676
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
677
|
-
EReference parent,
|
678
|
-
eType: /StatemachineMM/CompositeState,
|
679
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
680
|
-
}
|
681
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]|
|
682
|
-
END
|
683
|
-
assert_completions context, [
|
684
|
-
]
|
685
|
-
end
|
686
|
-
|
687
|
-
def test_integer_completion
|
688
|
-
setup_connector(ModelFile)
|
689
|
-
load_model
|
690
|
-
context = build_context <<-END
|
691
|
-
EPackage StatemachineMM {
|
692
|
-
EClass State, abstract: true {
|
693
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
694
|
-
EReference parent,
|
695
|
-
eType: /StatemachineMM/CompositeState,
|
696
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
697
|
-
}
|
698
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
699
|
-
EClass CompositeState,
|
700
|
-
eSuperTypes: [
|
701
|
-
/StatemachineMM/State
|
702
|
-
],
|
703
|
-
abstract: false {
|
704
|
-
EReference substates, upperBound: |-1, containment: true, eType: /StatemachineMM/State, eOpposite: /StatemachineMM/State/parent
|
705
|
-
END
|
706
|
-
assert_completions context, [
|
707
|
-
"0",
|
708
|
-
]
|
709
|
-
context = build_context <<-END
|
710
|
-
EPackage StatemachineMM {
|
711
|
-
EClass State, abstract: true {
|
712
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
713
|
-
EReference parent,
|
714
|
-
eType: /StatemachineMM/CompositeState,
|
715
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
716
|
-
}
|
717
|
-
EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
718
|
-
EClass CompositeState,
|
719
|
-
eSuperTypes: [
|
720
|
-
/StatemachineMM/State
|
721
|
-
],
|
722
|
-
abstract: false {
|
723
|
-
EReference substates, upperBound: -1|, containment: true, eType: /StatemachineMM/State, eOpposite: /StatemachineMM/State/parent
|
724
|
-
END
|
725
|
-
assert_completions context, [
|
726
|
-
"0",
|
727
|
-
]
|
728
|
-
end
|
729
|
-
|
730
|
-
def test_link_targets
|
731
|
-
setup_connector(ModelFile)
|
732
|
-
load_model
|
733
|
-
context = build_context <<-END
|
734
|
-
EPackage StatemachineMM {
|
735
|
-
EClass State, abstract: true {
|
736
|
-
EAttribute name, eType: /St|atemachineMM/StringType
|
737
|
-
END
|
738
|
-
assert_link_targets context, :begin => 29, :end => 54, :targets => [
|
739
|
-
{"file"=> File.expand_path(@infile),
|
740
|
-
"line"=>20,
|
741
|
-
"display"=>"/StatemachineMM/StringType [EDataType]"}
|
742
|
-
]
|
743
|
-
context = build_context <<-END
|
744
|
-
EPackage StatemachineMM {
|
745
|
-
EClass State, abstract: true {
|
746
|
-
EAttribute name, eType: |/StatemachineMM/StringType
|
747
|
-
END
|
748
|
-
assert_link_targets context, :begin => 29, :end => 54, :targets => [
|
749
|
-
{"file"=> File.expand_path(@infile),
|
750
|
-
"line"=>20,
|
751
|
-
"display"=>"/StatemachineMM/StringType [EDataType]"}
|
752
|
-
]
|
753
|
-
context = build_context <<-END
|
754
|
-
EPackage StatemachineMM {
|
755
|
-
EClass State, abstract: true {
|
756
|
-
EAttribute name, eType: /StatemachineMM/StringTyp|e
|
757
|
-
END
|
758
|
-
assert_link_targets context, :begin => 29, :end => 54, :targets => [
|
759
|
-
{"file"=> File.expand_path(@infile),
|
760
|
-
"line"=>20,
|
761
|
-
"display"=>"/StatemachineMM/StringType [EDataType]"}
|
762
|
-
]
|
763
|
-
context = build_context <<-END
|
764
|
-
EPackage StatemachineMM {
|
765
|
-
EClass State, abstract: true {
|
766
|
-
EAttribute name, eType: /StatemachineMM/StringType|
|
767
|
-
END
|
768
|
-
assert_link_targets context, :begin => nil, :end => nil, :targets => []
|
769
|
-
context = build_context <<-END
|
770
|
-
EPackage StatemachineMM {
|
771
|
-
EClass State, abstract: true {
|
772
|
-
EAttribute name, eType:| /StatemachineMM/StringType
|
773
|
-
END
|
774
|
-
assert_link_targets context, :begin => nil, :end => nil, :targets => []
|
775
|
-
# backward ref
|
776
|
-
context = build_context <<-END
|
777
|
-
EPackage StatemachineMM {
|
778
|
-
E|Class State, abstract: true {
|
779
|
-
END
|
780
|
-
assert_link_targets context, :begin => 3, :end => 8, :targets => [
|
781
|
-
{"file"=> File.expand_path(@infile),
|
782
|
-
"line"=>8,
|
783
|
-
"display"=>"/StatemachineMM/SimpleState [EClass]"},
|
784
|
-
{"file"=> File.expand_path(@infile),
|
785
|
-
"line"=>9,
|
786
|
-
"display"=>"/StatemachineMM/CompositeState [EClass]"}
|
787
|
-
]
|
788
|
-
context = build_context <<-END
|
789
|
-
EPackage StatemachineMM {
|
790
|
-
EClass State, abstract: true {
|
791
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
792
|
-
EReference parent,
|
793
|
-
eType: /StatemachineMM/CompositeState,
|
794
|
-
eOpposite: /StatemachineMM/CompositeState/substates
|
795
|
-
}
|
796
|
-
|EClass SimpleState, eSuperTypes: [/StatemachineMM/State]
|
797
|
-
END
|
798
|
-
assert_link_targets context, :begin => 3, :end => 8, :targets => []
|
799
|
-
# bad location
|
800
|
-
context = build_context <<-END
|
801
|
-
EPackage S|tatemachineMM {
|
802
|
-
END
|
803
|
-
assert_link_targets context, :begin => 10, :end => 23, :targets => []
|
804
|
-
end
|
805
|
-
|
806
|
-
def test_link_targets_no_text_after_name
|
807
|
-
setup_connector(ModelFile)
|
808
|
-
load_model
|
809
|
-
context = build_context({:infile => ModelFile2}, <<-END
|
810
|
-
EPackage StatemachineMM2 {
|
811
|
-
ECl|ass State
|
812
|
-
END
|
813
|
-
)
|
814
|
-
assert_link_targets context, :file => ModelFile2, :begin => 3, :end => 8, :targets => [
|
815
|
-
{"file"=> File.expand_path(ModelFile2),
|
816
|
-
"line"=>3,
|
817
|
-
"display"=>"/StatemachineMM2/SimpleState [EClass]"}
|
818
|
-
]
|
819
|
-
end
|
820
|
-
|
821
|
-
def test_link_targets_after_linebreak
|
822
|
-
setup_connector(ModelFile)
|
823
|
-
load_model
|
824
|
-
context = build_context <<-END
|
825
|
-
EPackage StatemachineMM {
|
826
|
-
EClass State, abstract: true {
|
827
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
828
|
-
EReference parent,
|
829
|
-
eType: /St|atemachineMM/CompositeState,
|
830
|
-
END
|
831
|
-
# in case of linebreaks, the begin and end column refer to the string which
|
832
|
-
# was passed to the backend as the context; in this case the context extractor
|
833
|
-
# appends each broken line to the previous line with all the leading whitespace removed
|
834
|
-
assert_link_targets context, :begin => 37, :end => 66, :targets => [
|
835
|
-
{"file"=> File.expand_path(@infile),
|
836
|
-
"line"=>9,
|
837
|
-
"display"=>"/StatemachineMM/CompositeState [EClass]"}
|
838
|
-
]
|
839
|
-
context = build_context <<-END
|
840
|
-
EPackage StatemachineMM {
|
841
|
-
EClass State, abstract: true {
|
842
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
843
|
-
EReference parent,
|
844
|
-
eType: |/StatemachineMM/CompositeState,
|
845
|
-
END
|
846
|
-
assert_link_targets context, :begin => 37, :end => 66, :targets => [
|
847
|
-
{"file"=> File.expand_path(@infile),
|
848
|
-
"line"=>9,
|
849
|
-
"display"=>"/StatemachineMM/CompositeState [EClass]"}
|
850
|
-
]
|
851
|
-
context = build_context <<-END
|
852
|
-
EPackage StatemachineMM {
|
853
|
-
EClass State, abstract: true {
|
854
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
855
|
-
EReference parent,
|
856
|
-
eType: /StatemachineMM/CompositeStat|e,
|
857
|
-
END
|
858
|
-
assert_link_targets context, :begin => 37, :end => 66, :targets => [
|
859
|
-
{"file"=> File.expand_path(@infile),
|
860
|
-
"line"=>9,
|
861
|
-
"display"=>"/StatemachineMM/CompositeState [EClass]"}
|
862
|
-
]
|
863
|
-
context = build_context <<-END
|
864
|
-
EPackage StatemachineMM {
|
865
|
-
EClass State, abstract: true {
|
866
|
-
EAttribute name, eType: /StatemachineMM/StringType
|
867
|
-
EReference parent,
|
868
|
-
eType: /StatemachineMM/CompositeState|,
|
869
|
-
END
|
870
|
-
assert_link_targets context, :begin => nil, :end => nil, :targets => []
|
871
|
-
end
|
872
|
-
|
873
|
-
def test_find_elements
|
874
|
-
setup_connector(ModelFile)
|
875
|
-
load_model
|
876
|
-
response = @con.execute_command(
|
877
|
-
{"command" => "find_elements", "search_pattern" => "Sta"})
|
878
|
-
assert_equal \
|
879
|
-
[{"display"=>"State [EClass] - /StatemachineMM",
|
880
|
-
"file"=> File.expand_path(@infile),
|
881
|
-
"line"=>2},
|
882
|
-
{"display"=>"State [EClass] - /StatemachineMM2",
|
883
|
-
"file"=> File.expand_path(ModelFile2),
|
884
|
-
"line"=>2},
|
885
|
-
{"display"=>"StatemachineMM [EPackage] - /StatemachineMM",
|
886
|
-
"file"=> File.expand_path(@infile),
|
887
|
-
"line"=>1},
|
888
|
-
{"display"=>"StatemachineMM2 [EPackage] - /StatemachineMM2",
|
889
|
-
"file"=> File.expand_path(ModelFile2),
|
890
|
-
"line"=>1}], response["elements"]
|
891
|
-
response = @con.execute_command(
|
892
|
-
{"command" => "find_elements", "search_pattern" => "target"})
|
893
|
-
assert_equal \
|
894
|
-
[{"display"=>"target [EReference] - /StatemachineMM/Transition",
|
895
|
-
"file"=> File.expand_path(@infile),
|
896
|
-
"line"=>17}], response["elements"]
|
897
|
-
response = @con.execute_command(
|
898
|
-
{"command" => "find_elements", "search_pattern" => ""})
|
899
|
-
assert_equal [], response["elements"]
|
900
|
-
response = @con.execute_command(
|
901
|
-
{"command" => "find_elements", "search_pattern" => "xxx"})
|
902
|
-
assert_equal [], response["elements"]
|
903
|
-
end
|
904
|
-
|
905
|
-
TestContext = Struct.new(:line, :col)
|
906
|
-
|
907
|
-
def build_context(text, text2=nil)
|
908
|
-
if text.is_a?(Hash)
|
909
|
-
context_lines = text2.split("\n")
|
910
|
-
pos_in_line = text[:col] || context_lines.last.index("|") + 1
|
911
|
-
infile = text[:infile] || @infile
|
912
|
-
else
|
913
|
-
context_lines = text.split("\n")
|
914
|
-
pos_in_line = context_lines.last.index("|") + 1
|
915
|
-
infile = @infile
|
916
|
-
end
|
917
|
-
context_lines.last.sub!("|", "")
|
918
|
-
|
919
|
-
# check that the context data actally matches the real file in the filesystem
|
920
|
-
content = File.open(infile, "rb"){|f| f.read}
|
921
|
-
ref_lines = content.split(/\r?\n/)[0..context_lines.size-1]
|
922
|
-
raise "inconsistent test data, expected\n:#{ref_lines.join("\n")}\ngot:\n#{context_lines.join("\n")}\n" \
|
923
|
-
unless ref_lines == context_lines
|
924
|
-
|
925
|
-
# column numbers start at 1
|
926
|
-
TestContext.new(context_lines.size, pos_in_line)
|
927
|
-
end
|
928
|
-
|
929
|
-
def assert_link_targets(context, options)
|
930
|
-
infile = options[:file] || @infile
|
931
|
-
content = File.open(infile, "rb") {|f| f.read}
|
932
|
-
lines = content.split(/\r?\n/)[0..context.line-1]
|
933
|
-
lines, col = RText::Frontend::Context.new.extract(lines, context.col)
|
934
|
-
response = @con.execute_command(
|
935
|
-
{"command" => "link_targets", "context" => lines, "column" => col})
|
936
|
-
assert_equal "response", response["type"]
|
937
|
-
assert_equal options[:targets], response["targets"]
|
938
|
-
assert_equal options[:begin], response["begin_column"]
|
939
|
-
assert_equal options[:end], response["end_column"]
|
940
|
-
end
|
941
|
-
|
942
|
-
def assert_completions(context, expected)
|
943
|
-
content = File.open(@infile, "rb"){|f| f.read}
|
944
|
-
lines = content.split(/\r?\n/)[0..context.line-1]
|
945
|
-
lines, col = RText::Frontend::Context.new.extract(lines, context.col)
|
946
|
-
response = @con.execute_command(
|
947
|
-
{"command" => "content_complete", "context" => lines, "column" => col})
|
948
|
-
assert_equal expected, response["options"].collect{|o| o["insert"]}
|
949
|
-
end
|
950
|
-
|
951
|
-
def load_model
|
952
|
-
done = false
|
953
|
-
response = nil
|
954
|
-
while !done
|
955
|
-
response = @con.execute_command({"command" => "load_model"})
|
956
|
-
if response == :connecting && !@connection_timeout
|
957
|
-
sleep(0.1)
|
958
|
-
@con.resume
|
959
|
-
else
|
960
|
-
done = true
|
961
|
-
end
|
962
|
-
end
|
963
|
-
response
|
964
|
-
end
|
965
|
-
|
966
|
-
end
|