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