rtext 0.9.0 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +113 -98
  3. data/Project.yaml +14 -0
  4. data/RText_Protocol +1 -1
  5. data/lib/rtext/default_completer.rb +212 -208
  6. data/lib/rtext/frontend/connector.rb +122 -55
  7. data/lib/rtext/instantiator.rb +11 -3
  8. data/lib/rtext/service.rb +264 -260
  9. metadata +18 -44
  10. data/Rakefile +0 -46
  11. data/test/completer_test.rb +0 -607
  12. data/test/context_builder_test.rb +0 -949
  13. data/test/frontend/context_test.rb +0 -302
  14. data/test/instantiator_test.rb +0 -1733
  15. data/test/integration/backend.out +0 -16
  16. data/test/integration/crash_on_request_editor.rb +0 -12
  17. data/test/integration/ecore_editor.rb +0 -50
  18. data/test/integration/frontend.log +0 -40058
  19. data/test/integration/model/invalid_encoding.invenc +0 -2
  20. data/test/integration/model/test.crash_on_request +0 -18
  21. data/test/integration/model/test.crashing_backend +0 -18
  22. data/test/integration/model/test.dont_open_socket +0 -0
  23. data/test/integration/model/test.invalid_cmd_line +0 -0
  24. data/test/integration/model/test.not_in_rtext +0 -0
  25. data/test/integration/model/test_large_with_errors.ect3 +0 -43523
  26. data/test/integration/model/test_metamodel.ect +0 -24
  27. data/test/integration/model/test_metamodel2.ect +0 -5
  28. data/test/integration/model/test_metamodel3.ect4 +0 -7
  29. data/test/integration/model/test_metamodel_error.ect2 +0 -3
  30. data/test/integration/model/test_metamodel_ok.ect2 +0 -18
  31. data/test/integration/test.rb +0 -968
  32. data/test/link_detector_test.rb +0 -288
  33. data/test/message_helper_test.rb +0 -117
  34. data/test/rtext_test.rb +0 -11
  35. data/test/serializer_test.rb +0 -1024
  36. data/test/tokenizer_test.rb +0 -174
data/Rakefile DELETED
@@ -1,46 +0,0 @@
1
- require 'rubygems/package_task'
2
- require 'rdoc/task'
3
-
4
- DocFiles = [
5
- "README.rdoc", "CHANGELOG", "MIT-LICENSE",
6
- "RText_Users_Guide",
7
- "RText_Protocol"]
8
-
9
- RTextGemSpec = Gem::Specification.new do |s|
10
- s.name = %q{rtext}
11
- s.version = "0.9.0"
12
- s.date = Time.now.strftime("%Y-%m-%d")
13
- s.summary = %q{Ruby Textual Modelling}
14
- s.email = %q{martin dot thiede at gmx de}
15
- s.homepage = %q{http://ruby-gen.org}
16
- s.description = %q{RText can be used to derive textual languages from an RGen metamodel with very little effort.}
17
- s.authors = ["Martin Thiede"]
18
- s.add_dependency('rgen', '>= 0.8.2')
19
- gemfiles = Rake::FileList.new
20
- gemfiles.include("{lib,test}/**/*")
21
- gemfiles.include(DocFiles)
22
- gemfiles.include("Rakefile")
23
- gemfiles.exclude(/\b\.bak\b/)
24
- s.files = gemfiles
25
- s.rdoc_options = ["--main", "README.rdoc", "-x", "test"]
26
- s.extra_rdoc_files = DocFiles
27
- end
28
-
29
- RDoc::Task.new do |rd|
30
- rd.main = "README.rdoc"
31
- rd.rdoc_files.include(DocFiles)
32
- rd.rdoc_files.include("lib/**/*.rb")
33
- rd.rdoc_dir = "doc"
34
- end
35
-
36
- RTextPackageTask = Gem::PackageTask.new(RTextGemSpec) do |p|
37
- p.need_zip = false
38
- end
39
-
40
- task :prepare_package_rdoc => :rdoc do
41
- RTextPackageTask.package_files.include("doc/**/*")
42
- end
43
-
44
- task :release => [:prepare_package_rdoc, :package]
45
-
46
- task :clobber => [:clobber_rdoc, :clobber_package]
@@ -1,607 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
3
- gem 'minitest'
4
- require 'minitest/autorun'
5
- require 'rgen/metamodel_builder'
6
- require 'rtext/language'
7
- require 'rtext/context_builder'
8
- require 'rtext/default_completer'
9
-
10
- class CompleterTest < MiniTest::Test
11
-
12
- module TestMM
13
- extend RGen::MetamodelBuilder::ModuleExtension
14
- class TestNode2 < RGen::MetamodelBuilder::MMBase
15
- has_attr 'text', String
16
- has_attr 'unlabled', String
17
- end
18
- class TestNode3 < RGen::MetamodelBuilder::MMBase
19
- end
20
- class TestNode < RGen::MetamodelBuilder::MMBase
21
- has_attr 'text', String
22
- has_attr 'unlabled1', String
23
- has_attr 'unlabled2', Integer
24
- has_many_attr 'nums', Integer
25
- has_one 'related', TestNode
26
- has_many 'others', TestNode
27
- contains_many 'childs', TestNode, 'parent'
28
- contains_one 'child2RoleA', TestNode2, 'parentA'
29
- contains_many 'child2RoleB', TestNode2, 'parentB'
30
- contains_one_uni 'testNode3', TestNode3
31
- end
32
- SomeEnum = RGen::MetamodelBuilder::DataTypes::Enum.new(
33
- :name => "SomeEnum", :literals => [:A, :B, :'non-word*chars'])
34
- class TestNode3 < RGen::MetamodelBuilder::MMBase
35
- has_attr 'bool', Boolean
36
- has_attr 'float', Float
37
- has_attr 'enum', SomeEnum
38
- end
39
- class TextNode < RGen::MetamodelBuilder::MMBase
40
- end
41
- end
42
-
43
- def test_after_command
44
- options = complete TestMM, <<-END
45
- TestNode |
46
- END
47
- assert_options([
48
- ["\"\"", "[unlabled1] <EString>"],
49
- ["text:", "<EString>"],
50
- ["nums:", "<EInt>"],
51
- ["related:", "<TestNode>"],
52
- ["others:", "<TestNode>"]
53
- ], options)
54
- end
55
-
56
- def test_lable_prefix
57
- options = complete TestMM, <<-END
58
- TestNode t|
59
- END
60
- assert_options([
61
- ["\"\"", "[unlabled1] <EString>"],
62
- ["text:", "<EString>"],
63
- ["nums:", "<EInt>"],
64
- ["related:", "<TestNode>"],
65
- ["others:", "<TestNode>"]
66
- ], options)
67
- end
68
-
69
- def test_lable_within
70
- options = complete TestMM, <<-END
71
- TestNode t|ext
72
- END
73
- assert_options([
74
- ["\"\"", "[unlabled1] <EString>"],
75
- ["text:", "<EString>"],
76
- ["nums:", "<EInt>"],
77
- ["related:", "<TestNode>"],
78
- ["others:", "<TestNode>"]
79
- ], options)
80
- end
81
-
82
- def test_unlabled_prefix
83
- options = complete TestMM, <<-END
84
- TestNode u|
85
- END
86
- assert_options([
87
- ["\"\"", "[unlabled1] <EString>"],
88
- ["text:", "<EString>"],
89
- ["nums:", "<EInt>"],
90
- ["related:", "<TestNode>"],
91
- ["others:", "<TestNode>"]
92
- ], options)
93
- end
94
-
95
- def test_after_labled_value
96
- options = complete TestMM, <<-END
97
- TestNode nums: 1, |
98
- END
99
- assert_options([
100
- ["text:", "<EString>"],
101
- ["related:", "<TestNode>"],
102
- ["others:", "<TestNode>"]
103
- ], options)
104
- end
105
-
106
- def test_after_labled_value_directly_after_comma
107
- options = complete TestMM, <<-END
108
- TestNode nums: 1,|
109
- END
110
- assert_options([
111
- ["text:", "<EString>"],
112
- ["related:", "<TestNode>"],
113
- ["others:", "<TestNode>"]
114
- ], options)
115
- end
116
-
117
- def test_after_second_labled_value_directly_after_comma
118
- options = complete TestMM, <<-END
119
- TestNode nums: 1, text: "a",|
120
- END
121
- assert_options([
122
- ["related:", "<TestNode>"],
123
- ["others:", "<TestNode>"]
124
- ], options)
125
- end
126
-
127
- def test_after_unlabled_value
128
- options = complete TestMM, <<-END
129
- TestNode "bla", |
130
- END
131
- assert_options([
132
- ["0", "[unlabled2] <EInt>"],
133
- ["text:", "<EString>"],
134
- ["nums:", "<EInt>"],
135
- ["related:", "<TestNode>"],
136
- ["others:", "<TestNode>"]
137
- ], options)
138
- end
139
-
140
- def test_after_unlabled_value_directly_after_comma
141
- options = complete TestMM, <<-END
142
- TestNode "bla",|
143
- END
144
- assert_options([
145
- ["0", "[unlabled2] <EInt>"],
146
- ["text:", "<EString>"],
147
- ["nums:", "<EInt>"],
148
- ["related:", "<TestNode>"],
149
- ["others:", "<TestNode>"]
150
- ], options)
151
- end
152
-
153
- def test_after_unlabled_value2
154
- options = complete TestMM, <<-END
155
- TestNode "bla", 1, |
156
- END
157
- assert_options([
158
- ["text:", "<EString>"],
159
- ["nums:", "<EInt>"],
160
- ["related:", "<TestNode>"],
161
- ["others:", "<TestNode>"]
162
- ], options)
163
- end
164
-
165
- def test_after_unlabled_value3
166
- options = complete TestMM, <<-END
167
- TestNode "bla", 1,|
168
- END
169
- assert_options([
170
- ["text:", "<EString>"],
171
- ["nums:", "<EInt>"],
172
- ["related:", "<TestNode>"],
173
- ["others:", "<TestNode>"]
174
- ], options)
175
- end
176
-
177
- def test_after_array
178
- options = complete TestMM, <<-END
179
- TestNode nums: [1, 2], |
180
- END
181
- assert_options([
182
- ["text:", "<EString>"],
183
- ["related:", "<TestNode>"],
184
- ["others:", "<TestNode>"]
185
- ], options)
186
- end
187
-
188
- def test_after_array_direct
189
- options = complete TestMM, <<-END
190
- TestNode nums: [1, 2]|
191
- END
192
- assert_options([
193
- ], options)
194
- end
195
-
196
- def test_value_int
197
- options = complete TestMM, <<-END
198
- TestNode nums: |
199
- END
200
- assert_options([
201
- ["0", "<EInt>"],
202
- ], options)
203
- end
204
-
205
- def test_value_int_part
206
- options = complete TestMM, <<-END
207
- TestNode nums: 0|
208
- END
209
- assert_options([
210
- ["0", "<EInt>"]
211
- ], options)
212
- end
213
-
214
- def test_value_boolean
215
- options = complete TestMM, <<-END
216
- TestNode3 bool: |
217
- END
218
- assert_options([
219
- ["true", "<EBoolean>"],
220
- ["false", "<EBoolean>"],
221
- ], options)
222
- end
223
-
224
- def test_value_boolean_part
225
- options = complete TestMM, <<-END
226
- TestNode3 bool: t|
227
- END
228
- assert_options([
229
- ["true", "<EBoolean>"],
230
- ["false", "<EBoolean>"],
231
- ], options)
232
- end
233
-
234
- def test_value_boolean_full
235
- options = complete TestMM, <<-END
236
- TestNode3 bool: true|
237
- END
238
- assert_options([
239
- ["true", "<EBoolean>"],
240
- ["false", "<EBoolean>"],
241
- ], options)
242
- end
243
-
244
- def test_value_float
245
- options = complete TestMM, <<-END
246
- TestNode3 float: |
247
- END
248
- assert_options([
249
- ["0.0", "<EFloat>"],
250
- ], options)
251
- end
252
-
253
- def test_value_float_part
254
- options = complete TestMM, <<-END
255
- TestNode3 float: 0|
256
- END
257
- assert_options([
258
- ["0.0", "<EFloat>"],
259
- ], options)
260
- end
261
-
262
- def test_value_float_full
263
- options = complete TestMM, <<-END
264
- TestNode3 float: 0.0|
265
- END
266
- assert_options([
267
- ["0.0", "<EFloat>"],
268
- ], options)
269
- end
270
-
271
- def test_value_enum
272
- options = complete TestMM, <<-END
273
- TestNode3 enum: |
274
- END
275
- assert_options([
276
- ["A", "<SomeEnum>"],
277
- ["B", "<SomeEnum>"],
278
- ["\"non-word*chars\"", "<SomeEnum>"]
279
- ], options)
280
- end
281
-
282
- def test_value_enum_part
283
- options = complete TestMM, <<-END
284
- TestNode3 enum: A|
285
- END
286
- assert_options([
287
- ["A", "<SomeEnum>"],
288
- ["B", "<SomeEnum>"],
289
- ["\"non-word*chars\"", "<SomeEnum>"]
290
- ], options)
291
- end
292
-
293
- def test_array_value
294
- options = complete TestMM, <<-END
295
- TestNode nums: [|
296
- END
297
- assert_options([
298
- ["0", "<EInt>"],
299
- ], options)
300
- end
301
-
302
- def test_array_value2
303
- options = complete TestMM, <<-END
304
- TestNode nums: [1,|
305
- END
306
- assert_options([
307
- ["0", "<EInt>"],
308
- ], options)
309
- end
310
-
311
- def test_reference_value
312
- options = complete(TestMM, %Q(\
313
- TestNode related: |\
314
- ), lambda { |r| [
315
- RText::DefaultCompleter::CompletionOption.from_text_extra("A", "a"),
316
- RText::DefaultCompleter::CompletionOption.from_text_extra("B", "b") ] })
317
- assert_options([
318
- ["A", "a"],
319
- ["B", "b"],
320
- ], options)
321
- end
322
-
323
- def test_reference_value_part
324
- options = complete(TestMM, %Q(\
325
- TestNode related: /My/|\
326
- ), lambda { |r| [
327
- RText::DefaultCompleter::CompletionOption.from_text_extra("/My/Target", "a"),
328
- RText::DefaultCompleter::CompletionOption.from_text_extra("/MyOther/Target", "b") ] })
329
- assert_options([
330
- ["/My/Target", "a"],
331
- ["/MyOther/Target", "b"]
332
- ], options)
333
- end
334
-
335
- def test_reference_value_no_ref_completion_provider
336
- options = complete TestMM, <<-END
337
- TestNode related: |
338
- END
339
- assert_options([
340
- ], options)
341
- end
342
-
343
- def test_reference_value_in_array
344
- options = complete(TestMM, %Q(\
345
- TestNode others: |
346
- ), lambda { |r| [
347
- RText::DefaultCompleter::CompletionOption.from_text_extra("A", "a"),
348
- RText::DefaultCompleter::CompletionOption.from_text_extra("B", "b") ] })
349
- assert_options([
350
- ["A", "a"],
351
- ["B", "b"],
352
- ], options)
353
- end
354
-
355
- def test_reference_value_in_array_after_bracket
356
- options = complete(TestMM, %Q(\
357
- TestNode others: [|
358
- ), lambda { |r| [
359
- RText::DefaultCompleter::CompletionOption.from_text_extra("A", "a"),
360
- RText::DefaultCompleter::CompletionOption.from_text_extra("B", "b") ] })
361
- assert_options([
362
- ["A", "a"],
363
- ["B", "b"],
364
- ], options)
365
- end
366
-
367
- def test_reference_value_in_array_second_value
368
- options = complete(TestMM, %Q(\
369
- TestNode others: [xxx, |
370
- ), lambda { |r| [
371
- RText::DefaultCompleter::CompletionOption.from_text_extra("A", "a"),
372
- RText::DefaultCompleter::CompletionOption.from_text_extra("B", "b") ] })
373
- assert_options([
374
- ["A", "a"],
375
- ["B", "b"],
376
- ], options)
377
- end
378
-
379
- def test_reference_value_nested
380
- options = complete(TestMM, %Q(\
381
- TestNode {
382
- TestNode SimpleState, others: [|/StatemachineMM/State]
383
- ), lambda { |r| [
384
- RText::DefaultCompleter::CompletionOption.from_text_extra("A", "a"),
385
- RText::DefaultCompleter::CompletionOption.from_text_extra("B", "b") ] })
386
- assert_options([
387
- ["A", "a"],
388
- ["B", "b"],
389
- ], options)
390
- end
391
-
392
- def test_after_curly
393
- options = complete TestMM, <<-END
394
- TestNode {|
395
- END
396
- assert_options([
397
- ], options)
398
- end
399
-
400
- def test_children
401
- options = complete TestMM, <<-END
402
- TestNode {
403
- |
404
- END
405
- assert_options([
406
- ["TestNode", "<unlabled1>, <unlabled2>"],
407
- ["child2RoleA:", "<TestNode2>"],
408
- ["child2RoleB:", "<TestNode2>"],
409
- ["testNode3:", "<TestNode3>"]
410
- ], options)
411
- end
412
-
413
- def test_children_with_role
414
- options = complete TestMM, <<-END
415
- TestNode {
416
- child2RoleA:
417
- |
418
- END
419
- assert_options([
420
- ["TestNode2", "<unlabled>"],
421
- ], options)
422
- end
423
-
424
- def test_after_child_role
425
- options = complete TestMM, <<-END
426
- TestNode {
427
- child2RoleA:|
428
- END
429
- assert_options([
430
- ], options)
431
- end
432
-
433
- def test_after_child_role2
434
- options = complete TestMM, <<-END
435
- TestNode {
436
- child2RoleA: |
437
- END
438
- assert_options([
439
- ], options)
440
- end
441
-
442
- def test_after_child_role3
443
- options = complete TestMM, <<-END
444
- TestNode {
445
- child2RoleA: [|
446
- END
447
- assert_options([
448
- ], options)
449
- end
450
-
451
- def test_after_child_role4
452
- options = complete TestMM, <<-END
453
- TestNode {
454
- child2RoleA: [ |
455
- END
456
- assert_options([
457
- ], options)
458
- end
459
-
460
- def test_children_with_role_array
461
- options = complete TestMM, <<-END
462
- TestNode {
463
- child2RoleB: [
464
- |
465
- END
466
- assert_options([
467
- ["TestNode2", "<unlabled>"],
468
- ], options)
469
- end
470
-
471
- def test_children_prefix
472
- options = complete TestMM, <<-END
473
- TestNode {
474
- child2RoleB: [
475
- X|
476
- END
477
- assert_options([
478
- ["TestNode2", "<unlabled>"],
479
- ], options)
480
- end
481
-
482
- def test_children_inside_childrole
483
- options = complete TestMM, <<-END
484
- TestNode {
485
- child2RoleA:
486
- TestNode2 |
487
- END
488
- assert_options([
489
- ["unlabled", "[unlabled] <EString>"],
490
- ["text:", "<EString>"]
491
- ], options)
492
- end
493
-
494
- def test_children_inside_childrole_array
495
- options = complete TestMM, <<-END
496
- TestNode {
497
- child2RoleB: [
498
- TestNode2 |
499
- END
500
- assert_options([
501
- ["unlabled", "[unlabled] <EString>"],
502
- ["text:", "<EString>"]
503
- ], options)
504
- end
505
-
506
- def test_unquoted_argument
507
- options = complete TestMM, <<-END
508
- TestNode {
509
- child2RoleB: [
510
- TestNode2 text: |
511
- END
512
- assert_options([
513
- ["text", "<EString>"]
514
- ], options)
515
- end
516
-
517
- def test_root
518
- options = complete TestMM, <<-END
519
- |
520
- END
521
- assert_options([
522
- ["TestNode", "<unlabled1>, <unlabled2>"],
523
- ["TestNode2", "<unlabled>"],
524
- ["TestNode3", ""],
525
- ["TextNode", ""]
526
- ], options)
527
- end
528
-
529
- def test_root_no_context_lines
530
- options = complete TestMM, ""
531
- assert_options([
532
- ["TestNode", "<unlabled1>, <unlabled2>"],
533
- ["TestNode2", "<unlabled>"],
534
- ["TestNode3", ""],
535
- ["TextNode", ""]
536
- ], options)
537
- end
538
-
539
- def test_root_prefix
540
- options = complete TestMM, <<-END
541
- Text|
542
- END
543
- assert_options([
544
- ["TestNode", "<unlabled1>, <unlabled2>"],
545
- ["TestNode2", "<unlabled>"],
546
- ["TestNode3", ""],
547
- ["TextNode", ""]
548
- ], options)
549
- end
550
-
551
- def test_within_command
552
- options = complete TestMM, <<-END
553
- Text|Node
554
- END
555
- assert_options([
556
- ["TestNode", "<unlabled1>, <unlabled2>"],
557
- ["TestNode2", "<unlabled>"],
558
- ["TestNode3", ""],
559
- ["TextNode", ""]
560
- ], options)
561
- end
562
-
563
- def test_within_command2
564
- options = complete TestMM, <<-END
565
- |TextNode
566
- END
567
- assert_options([
568
- ["TestNode", "<unlabled1>, <unlabled2>"],
569
- ["TestNode2", "<unlabled>"],
570
- ["TestNode3", ""],
571
- ["TextNode", ""]
572
- ], options)
573
- end
574
-
575
- def assert_options(expected, options)
576
- assert_equal(expected, options.collect { |o| [o.insert, o.extra] })
577
- end
578
-
579
- def complete(mm, text, ref_comp_option_provider=nil)
580
- context_lines = text.split("\n")
581
- if context_lines.last
582
- pos_in_line = context_lines.last.index("|")
583
- context_lines.last.sub!("|", "")
584
- end
585
- lang = RText::Language.new(mm.ecore,
586
- :root_classes => mm.ecore.eAllClasses,
587
- :unlabled_arguments => lambda {|c| ["unlabled1", "unlabled2", "unlabled"]},
588
- :unquoted_arguments => lambda {|c| c.name == "TestNode2" ? ["text", "unlabled"] : []},
589
- :labeled_containments => lambda {|c| ["testNode3"]})
590
- context = RText::ContextBuilder.build_context(lang, context_lines, pos_in_line)
591
- completer = RText::DefaultCompleter.new(lang)
592
- class << completer
593
- attr_accessor :ref_comp_option_provider
594
- def reference_options(context)
595
- if ref_comp_option_provider
596
- ref_comp_option_provider.call(context.feature)
597
- else
598
- super
599
- end
600
- end
601
- end
602
- completer.ref_comp_option_provider = ref_comp_option_provider
603
- completer.complete(context)
604
- end
605
-
606
- end
607
-