rtext 0.9.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +108 -98
- data/RText_Protocol +1 -1
- data/Rakefile +39 -46
- data/lib/rtext/default_completer.rb +212 -208
- data/lib/rtext/frontend/connector.rb +120 -53
- data/lib/rtext/instantiator.rb +11 -3
- data/lib/rtext/service.rb +264 -260
- data/test/completer_test.rb +606 -607
- data/test/context_builder_test.rb +952 -949
- data/test/frontend/context_test.rb +301 -302
- data/test/instantiator_test.rb +1773 -1733
- data/test/integration/test.rb +974 -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 +17 -19
- data/test/integration/backend.out +0 -16
- data/test/integration/frontend.log +0 -40058
data/test/tokenizer_test.rb
CHANGED
@@ -1,174 +1,173 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
5
|
-
require 'rtext/
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Token.new(:
|
14
|
-
Token.new(
|
15
|
-
Token.new(
|
16
|
-
Token.new(
|
17
|
-
Token.new(
|
18
|
-
Token.new(
|
19
|
-
Token.new(
|
20
|
-
Token.new(:
|
21
|
-
Token.new(
|
22
|
-
Token.new(
|
23
|
-
Token.new(:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Token.new(:
|
31
|
-
Token.new(
|
32
|
-
Token.new(
|
33
|
-
Token.new(:integer,
|
34
|
-
Token.new(:
|
35
|
-
Token.new(:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Token.new(:
|
45
|
-
Token.new(:
|
46
|
-
Token.new(:
|
47
|
-
Token.new(:
|
48
|
-
Token.new(:
|
49
|
-
Token.new(:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal
|
61
|
-
assert_equal
|
62
|
-
assert_equal 1, tokens.first.
|
63
|
-
assert_equal
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
assert_equal
|
70
|
-
assert_equal
|
71
|
-
assert_equal 1, tokens.first.
|
72
|
-
assert_equal
|
73
|
-
assert_equal
|
74
|
-
assert_equal :
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
assert_equal
|
81
|
-
assert_equal
|
82
|
-
assert_equal 1, tokens.first.
|
83
|
-
assert_equal
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
assert_equal
|
90
|
-
assert_equal
|
91
|
-
assert_equal 1, tokens.first.
|
92
|
-
assert_equal
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
assert_equal
|
99
|
-
assert_equal
|
100
|
-
assert_equal 1, tokens.first.
|
101
|
-
assert_equal
|
102
|
-
assert_equal
|
103
|
-
assert_equal :
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
Token.new(:
|
110
|
-
Token.new(:
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
Token.new(:
|
120
|
-
Token.new(:
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
Token.new(:
|
128
|
-
Token.new(:
|
129
|
-
Token.new(:
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
Token.new(:identifier, "
|
151
|
-
Token.new(
|
152
|
-
Token.new(
|
153
|
-
Token.new(:
|
154
|
-
Token.new(:
|
155
|
-
Token.new(:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'rtext/tokenizer'
|
5
|
+
require 'rtext/generic'
|
6
|
+
|
7
|
+
class TokenizerTest < MiniTest::Test
|
8
|
+
include RText::Tokenizer
|
9
|
+
|
10
|
+
def test_simple
|
11
|
+
assert_tokens [
|
12
|
+
Token.new(:identifier, "TestNode", 1, 1, 8),
|
13
|
+
Token.new(:integer, 1, 1, 10, 10),
|
14
|
+
Token.new(",", nil, 1, 11, 11),
|
15
|
+
Token.new(:identifier, "bla", 1, 13, 15),
|
16
|
+
Token.new(",", nil, 1, 16, 16),
|
17
|
+
Token.new(:float, 0.4, 1, 18, 20),
|
18
|
+
Token.new(",", nil, 1, 21, 21),
|
19
|
+
Token.new(:label, "label", 1, 23, 28),
|
20
|
+
Token.new(:integer, 4, 1, 30, 30),
|
21
|
+
Token.new(",", nil, 1, 31, 31),
|
22
|
+
Token.new(:string, "string", 1, 33, 40),
|
23
|
+
Token.new(:newline, nil, 1, nil, nil)
|
24
|
+
], "TestNode 1, bla, 0.4, label: 4, \"string\""
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_more
|
28
|
+
assert_tokens [
|
29
|
+
Token.new(:identifier, "TestNode", 1, 1, 8),
|
30
|
+
Token.new(:boolean, true, 1, 10, 13),
|
31
|
+
Token.new(",", nil, 1, 14, 14),
|
32
|
+
Token.new(:integer, 0xfaa, 1, 16, 20),
|
33
|
+
Token.new(:integer, -3, 1, 22, 23),
|
34
|
+
Token.new(:reference, "/a/b", 1, 25, 28),
|
35
|
+
Token.new(:newline, nil, 1, nil, nil)
|
36
|
+
], <<-END
|
37
|
+
TestNode true, 0xfaa -3 /a/b
|
38
|
+
END
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_comments_and_annotation
|
42
|
+
assert_tokens [
|
43
|
+
Token.new(:comment, " comment", 1, 1, 9),
|
44
|
+
Token.new(:newline, nil, 1, nil, nil),
|
45
|
+
Token.new(:annotation, " annotation", 2, 1, 12),
|
46
|
+
Token.new(:newline, nil, 2, nil, nil),
|
47
|
+
Token.new(:identifier, "TestNode", 3, 1, 8),
|
48
|
+
Token.new(:comment, "comment2", 3, 10, 18),
|
49
|
+
Token.new(:newline, nil, 3, nil, nil)
|
50
|
+
], <<-END
|
51
|
+
# comment
|
52
|
+
@ annotation
|
53
|
+
TestNode #comment2
|
54
|
+
END
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_generic
|
58
|
+
tokens = do_tokenize("<name>")
|
59
|
+
assert_equal :generic, tokens.first.kind
|
60
|
+
assert_equal "name", tokens.first.value.string
|
61
|
+
assert_equal 1, tokens.first.line
|
62
|
+
assert_equal 1, tokens.first.scol
|
63
|
+
assert_equal 6, tokens.first.ecol
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_generic_bad
|
67
|
+
tokens = do_tokenize("<a>b>")
|
68
|
+
assert_equal :generic, tokens.first.kind
|
69
|
+
assert_equal "a", tokens.first.value.string
|
70
|
+
assert_equal 1, tokens.first.line
|
71
|
+
assert_equal 1, tokens.first.scol
|
72
|
+
assert_equal 3, tokens.first.ecol
|
73
|
+
assert_equal :identifier, tokens[1].kind
|
74
|
+
assert_equal :error, tokens[2].kind
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_generic_percent
|
78
|
+
tokens = do_tokenize("<%name%>")
|
79
|
+
assert_equal :generic, tokens.first.kind
|
80
|
+
assert_equal "name", tokens.first.value.string
|
81
|
+
assert_equal 1, tokens.first.line
|
82
|
+
assert_equal 1, tokens.first.scol
|
83
|
+
assert_equal 8, tokens.first.ecol
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_generic_percent_angle_close
|
87
|
+
tokens = do_tokenize("<% a > b < c %>")
|
88
|
+
assert_equal :generic, tokens.first.kind
|
89
|
+
assert_equal " a > b < c ", tokens.first.value.string
|
90
|
+
assert_equal 1, tokens.first.line
|
91
|
+
assert_equal 1, tokens.first.scol
|
92
|
+
assert_equal 15, tokens.first.ecol
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_generic_percent_bad
|
96
|
+
tokens = do_tokenize("<%= a %> b %>")
|
97
|
+
assert_equal :generic, tokens.first.kind
|
98
|
+
assert_equal "= a ", tokens.first.value.string
|
99
|
+
assert_equal 1, tokens.first.line
|
100
|
+
assert_equal 1, tokens.first.scol
|
101
|
+
assert_equal 8, tokens.first.ecol
|
102
|
+
assert_equal :identifier, tokens[1].kind
|
103
|
+
assert_equal :error, tokens[2].kind
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_error
|
107
|
+
assert_tokens [
|
108
|
+
Token.new(:error, "\"", 1, 1, 1),
|
109
|
+
Token.new(:identifier, "open", 1, 2, 5),
|
110
|
+
Token.new(:newline, nil, 1, nil, nil)
|
111
|
+
], <<-END
|
112
|
+
"open
|
113
|
+
END
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_with_bom
|
117
|
+
assert_tokens [
|
118
|
+
Token.new(:identifier, "TestNode", 1, 1, 8),
|
119
|
+
Token.new(:integer, 1, 1, 10, 10),
|
120
|
+
Token.new(:newline, nil, 1, nil, nil)
|
121
|
+
], "\xEF\xBB\xBFTestNode 1"
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_excessive_newline
|
125
|
+
assert_tokens [
|
126
|
+
Token.new(:identifier, "TestNode", 3, 1, 8),
|
127
|
+
Token.new(:newline, nil, 3, nil, nil),
|
128
|
+
Token.new(:identifier, "TestNode", 5, 1, 8),
|
129
|
+
Token.new(:newline, nil, 5, nil, nil)
|
130
|
+
], %Q(
|
131
|
+
|
132
|
+
TestNode
|
133
|
+
|
134
|
+
TestNode
|
135
|
+
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_only_newline
|
140
|
+
assert_tokens [
|
141
|
+
], %Q(
|
142
|
+
|
143
|
+
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_linebreak
|
148
|
+
assert_tokens [
|
149
|
+
Token.new(:identifier, "TestNode", 2, 1, 8),
|
150
|
+
Token.new(:identifier, "someNode", 2, 10, 17),
|
151
|
+
Token.new(",", nil, 2, 18, 18),
|
152
|
+
Token.new(:newline, nil, 2, nil, nil),
|
153
|
+
Token.new(:label, "label", 3, 3, 8),
|
154
|
+
Token.new(:identifier, "x", 3, 10, 10),
|
155
|
+
Token.new(:newline, nil, 3, nil, nil),
|
156
|
+
], %Q(
|
157
|
+
TestNode someNode,
|
158
|
+
label: x
|
159
|
+
)
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
def do_tokenize(str)
|
164
|
+
tokenize(str, /\A\/[\/\w]+/)
|
165
|
+
end
|
166
|
+
|
167
|
+
def assert_tokens(expected, str)
|
168
|
+
tokens = tokenize(str, /\A\/[\/\w]+/)
|
169
|
+
assert_equal(expected, tokens)
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Thiede
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rgen
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.8.
|
19
|
+
version: 0.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.8.
|
26
|
+
version: 0.8.0
|
27
27
|
description: RText can be used to derive textual languages from an RGen metamodel
|
28
28
|
with very little effort.
|
29
29
|
email: martin dot thiede at gmx de
|
@@ -36,6 +36,12 @@ extra_rdoc_files:
|
|
36
36
|
- RText_Users_Guide
|
37
37
|
- RText_Protocol
|
38
38
|
files:
|
39
|
+
- CHANGELOG
|
40
|
+
- MIT-LICENSE
|
41
|
+
- README.rdoc
|
42
|
+
- RText_Protocol
|
43
|
+
- RText_Users_Guide
|
44
|
+
- Rakefile
|
39
45
|
- lib/rtext/context_builder.rb
|
40
46
|
- lib/rtext/default_completer.rb
|
41
47
|
- lib/rtext/default_loader.rb
|
@@ -59,10 +65,8 @@ files:
|
|
59
65
|
- test/context_builder_test.rb
|
60
66
|
- test/frontend/context_test.rb
|
61
67
|
- test/instantiator_test.rb
|
62
|
-
- test/integration/backend.out
|
63
68
|
- test/integration/crash_on_request_editor.rb
|
64
69
|
- test/integration/ecore_editor.rb
|
65
|
-
- test/integration/frontend.log
|
66
70
|
- test/integration/model/invalid_encoding.invenc
|
67
71
|
- test/integration/model/test.crash_on_request
|
68
72
|
- test/integration/model/test.crashing_backend
|
@@ -81,36 +85,30 @@ files:
|
|
81
85
|
- test/rtext_test.rb
|
82
86
|
- test/serializer_test.rb
|
83
87
|
- test/tokenizer_test.rb
|
84
|
-
- README.rdoc
|
85
|
-
- CHANGELOG
|
86
|
-
- MIT-LICENSE
|
87
|
-
- RText_Users_Guide
|
88
|
-
- RText_Protocol
|
89
|
-
- Rakefile
|
90
88
|
homepage: http://ruby-gen.org
|
91
89
|
licenses: []
|
92
90
|
metadata: {}
|
93
91
|
post_install_message:
|
94
92
|
rdoc_options:
|
95
|
-
- --main
|
93
|
+
- "--main"
|
96
94
|
- README.rdoc
|
97
|
-
- -x
|
95
|
+
- "-x"
|
98
96
|
- test
|
99
97
|
require_paths:
|
100
98
|
- lib
|
101
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
100
|
requirements:
|
103
|
-
- -
|
101
|
+
- - ">="
|
104
102
|
- !ruby/object:Gem::Version
|
105
103
|
version: '0'
|
106
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
105
|
requirements:
|
108
|
-
- -
|
106
|
+
- - ">="
|
109
107
|
- !ruby/object:Gem::Version
|
110
108
|
version: '0'
|
111
109
|
requirements: []
|
112
110
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.5.2
|
114
112
|
signing_key:
|
115
113
|
specification_version: 4
|
116
114
|
summary: Ruby Textual Modelling
|
@@ -1,16 +0,0 @@
|
|
1
|
-
RText service, listening on port 9001
|
2
|
-
[15:34:36] INFO accepted connection
|
3
|
-
[15:34:36] DEBUG request: {"command"=>"load_model", "invocation_id"=>1, "type"=>"request"}
|
4
|
-
[15:34:36] DEBUG response: {"type"=>"response", "invocation_id"=>1, "problems"=>[], "total_problems"=>0}
|
5
|
-
[15:34:36] INFO request complete (0.014002s)
|
6
|
-
[15:34:36] DEBUG request: {"command"=>"link_targets", "context"=>[], "column"=>1, "invocation_id"=>2, "type"=>"request"}
|
7
|
-
C:/Users/mthiede/gitrepos/rtext/lib/rtext/link_detector.rb:20:in `detect': undefined method `concat' for nil:NilClass (NoMethodError)
|
8
|
-
from C:/Users/mthiede/gitrepos/rtext/lib/rtext/service.rb:196:in `link_targets'
|
9
|
-
from C:/Users/mthiede/gitrepos/rtext/lib/rtext/service.rb:109:in `message_received'
|
10
|
-
from C:/Users/mthiede/gitrepos/rtext/lib/rtext/service.rb:80:in `block in run'
|
11
|
-
from C:/Users/mthiede/gitrepos/rtext/lib/rtext/service.rb:59:in `each'
|
12
|
-
from C:/Users/mthiede/gitrepos/rtext/lib/rtext/service.rb:59:in `run'
|
13
|
-
from C:/Users/mthiede/gitrepos/rtext/test/integration/ecore_editor.rb:50:in `<top (required)>'
|
14
|
-
from c:/tools/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
|
15
|
-
from c:/tools/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
|
16
|
-
from ../crash_on_request_editor.rb:12:in `<main>'
|