expressir 0.2.24-x86-linux → 0.2.25-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d64935a7949feaf7fab7c0a7ff7449a3fa928eb039022e2337b9bc59e9199f
4
- data.tar.gz: c12186761d6137f653dd086bc16ad1f897238b3cff81c58c31cf1fb0ac3b5463
3
+ metadata.gz: e9cb0e0cb2e4ee7bbc3aede592a860252a5f2b46c7edba21e68193459739a010
4
+ data.tar.gz: 9116208481a8d53adcbc0d9d0e64f1e38bd375041b05666a116d37653fe3f030
5
5
  SHA512:
6
- metadata.gz: 13fe4ec659b0f28b3af54e2cf1b3483b66714932f2a8ba93443748dbab6a73336baea63429c2fa10d326d1d32727f9a1a2e5f9d3909b89f130b8ad939f9825a5
7
- data.tar.gz: 791ba061150d4fe27631711fdd5993265fd53c51edf3a950eb99fcb79cd7016a59a714d400f4e3b6943c0e1d3ac8460a82380e473cec9ae50457ad5c66deebc0
6
+ metadata.gz: e4b35b6b806b2ca6d7b8b5a28a29904876370a5aa15f4ca52b7e6924a1868a7319a274a656fa029a07ad9d389cac87113f021b1c8dda9f68b1c95403c72bd0d6
7
+ data.tar.gz: 64021ee4a309325e6e2e98e291987c924ac9cb9c6e2d653ef9e3d74d3daba0a8be01b555518c4d9a9b16fb2f46f9bd7eb96c91b7b21cfebdb5cb552dc0b91714
@@ -1502,7 +1502,7 @@ module Expressir
1502
1502
  [
1503
1503
  '(*',
1504
1504
  '"',
1505
- node.path,
1505
+ node.path || node.id,
1506
1506
  '"',
1507
1507
  ].join(''),
1508
1508
  remark,
@@ -1512,7 +1512,7 @@ module Expressir
1512
1512
  [
1513
1513
  '--',
1514
1514
  '"',
1515
- node.path,
1515
+ node.path || node.id,
1516
1516
  '"',
1517
1517
  ' ',
1518
1518
  remark
@@ -2,25 +2,20 @@ module Expressir
2
2
  module ExpressExp
3
3
  module HyperlinkFormatter
4
4
  def format_expressions_simple_reference(node)
5
- return node.id if node.parent.is_a? Model::Expressions::AttributeReference
5
+ return node.id unless node.base_path
6
6
 
7
- # skip hyperlink if target node can't be found
8
- target_node = if node.parent.is_a? Model::InterfaceItem
9
- node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
10
- else
11
- node.find(node.id)
7
+ # find closest node with path
8
+ current_node = node
9
+ while !current_node.path
10
+ current_node = current_node.parent
12
11
  end
13
- return node.id unless target_node
14
12
 
15
- # skip hyperlink for implicit scopes
16
- return node.id if target_node.is_a? Model::Statements::Alias or target_node.is_a? Model::Statements::Repeat or target_node.is_a? Model::Expressions::QueryExpression
13
+ # skip if this reference and target node are in the same node with path
14
+ node_base_path_parts = node.base_path.split(".")
15
+ current_node_path_parts = current_node.path.split(".")
16
+ return node.id if node_base_path_parts[0..1] == current_node_path_parts[0..1]
17
17
 
18
- # skip hyperlink if this node and target node are in the same main item
19
- node_path_parts = node.path.split(".")
20
- target_node_path_parts = target_node.path.split(".")
21
- return node.id if node_path_parts[0..1] == target_node_path_parts[0..1]
22
-
23
- "{{{<<express:#{target_node.path},#{node.id}>>}}}"
18
+ "{{{<<express:#{node.base_path},#{node.id}>>}}}"
24
19
  end
25
20
  end
26
21
  end
@@ -0,0 +1,23 @@
1
+ require "expressir/model"
2
+
3
+ module Expressir
4
+ module ExpressExp
5
+ class ModelVisitor
6
+ def visit(node)
7
+ node.class.model_attrs.each do |variable|
8
+ value = node.send(variable)
9
+
10
+ if value.is_a? Array
11
+ value.each do |value|
12
+ if value.is_a? Model::ModelElement
13
+ visit(value)
14
+ end
15
+ end
16
+ elsif value.is_a? Model::ModelElement
17
+ visit(value)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -5,6 +5,7 @@ rescue LoadError
5
5
  require_relative "express_parser"
6
6
  end
7
7
  require 'expressir/express_exp/visitor'
8
+ require 'expressir/express_exp/resolve_references_model_visitor'
8
9
 
9
10
  =begin
10
11
  char_stream = Antlr4::Runtime::CharStreams.from_string(input, 'String')
@@ -25,6 +26,8 @@ module Expressir
25
26
  module ExpressExp
26
27
  class Parser
27
28
  def self.from_file(file, options = {})
29
+ skip_references = options[:skip_references]
30
+
28
31
  input = File.read(file)
29
32
 
30
33
  parser = ::ExpressParser::Parser.parse(input)
@@ -38,13 +41,20 @@ module Expressir
38
41
  schema.file = file.to_s
39
42
  end
40
43
 
44
+ unless skip_references
45
+ resolve_references_model_visitor = ResolveReferencesModelVisitor.new
46
+ resolve_references_model_visitor.visit(repository)
47
+ end
48
+
41
49
  repository
42
50
  end
43
51
 
44
52
  def self.from_files(files, options = {})
53
+ skip_references = options[:skip_references]
54
+
45
55
  schemas = files.each_with_index.map do |file, i|
46
56
  # start = Time.now
47
- repository = self.from_file(file, options)
57
+ repository = self.from_file(file, options.merge(skip_references: true))
48
58
  # STDERR.puts "#{i+1}/#{files.length} #{file} #{Time.now - start}"
49
59
  repository.schemas
50
60
  end.flatten
@@ -53,8 +63,9 @@ module Expressir
53
63
  schemas: schemas
54
64
  })
55
65
 
56
- repository.schemas.each do |schema|
57
- schema.parent = repository
66
+ unless skip_references
67
+ resolve_references_model_visitor = ResolveReferencesModelVisitor.new
68
+ resolve_references_model_visitor.visit(repository)
58
69
  end
59
70
 
60
71
  repository
@@ -0,0 +1,33 @@
1
+ require "expressir/express_exp/model_visitor"
2
+ require "expressir/model"
3
+
4
+ module Expressir
5
+ module ExpressExp
6
+ class ResolveReferencesModelVisitor < ModelVisitor
7
+ def visit(node)
8
+ if node.is_a? Model::Expressions::SimpleReference
9
+ visit_expressions_simple_reference(node)
10
+ end
11
+
12
+ super
13
+ end
14
+
15
+ def visit_expressions_simple_reference(node)
16
+ return if node.parent.is_a? Model::Expressions::AttributeReference
17
+
18
+ if node.parent.is_a? Model::InterfaceItem
19
+ base_item = node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
20
+ else
21
+ base_item = node.find(node.id)
22
+ end
23
+ return unless base_item
24
+
25
+ if base_item.is_a? Model::InterfacedItem
26
+ base_item = base_item.base_item
27
+ end
28
+
29
+ node.base_path = base_item.path
30
+ end
31
+ end
32
+ end
33
+ end
@@ -4,9 +4,13 @@ module Expressir
4
4
  class SimpleReference < ModelElement
5
5
  model_attr_accessor :id
6
6
 
7
+ model_attr_accessor :base_path
8
+
7
9
  def initialize(options = {})
8
10
  @id = options[:id]
9
11
 
12
+ @base_path = options[:base_path]
13
+
10
14
  super
11
15
  end
12
16
  end
@@ -17,10 +17,6 @@ module Expressir
17
17
  super
18
18
  end
19
19
 
20
- def path
21
- base_item.path
22
- end
23
-
24
20
  def children
25
21
  [
26
22
  *remark_items
@@ -14,12 +14,13 @@ module Expressir
14
14
  end
15
15
 
16
16
  def path
17
- return id if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
17
+ # this creates an implicit scope
18
+ return if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
18
19
 
19
20
  current_node = self
20
21
  path_parts = []
21
22
  loop do
22
- if current_node.class.method_defined? :id
23
+ if current_node.class.method_defined? :id and !(current_node.is_a? Expressions::SimpleReference)
23
24
  path_parts << current_node.id
24
25
  end
25
26
 
@@ -27,6 +28,8 @@ module Expressir
27
28
  break unless current_node
28
29
  end
29
30
 
31
+ return if path_parts.empty?
32
+
30
33
  path_parts.reverse.join(".")
31
34
  end
32
35
 
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "0.2.24".freeze
2
+ VERSION = "0.2.25".freeze
3
3
  end
@@ -10,26 +10,31 @@ schemas:
10
10
  schema:
11
11
  _class: Expressir::Model::Expressions::SimpleReference
12
12
  id: multiple_schema2
13
+ base_path: multiple_schema2
13
14
  - _class: Expressir::Model::Interface
14
15
  kind: :REFERENCE
15
16
  schema:
16
17
  _class: Expressir::Model::Expressions::SimpleReference
17
18
  id: multiple_schema3
19
+ base_path: multiple_schema3
18
20
  items:
19
21
  - _class: Expressir::Model::InterfaceItem
20
22
  ref:
21
23
  _class: Expressir::Model::Expressions::SimpleReference
22
24
  id: attribute_entity3
25
+ base_path: multiple_schema3.attribute_entity3
23
26
  - _class: Expressir::Model::Interface
24
27
  kind: :REFERENCE
25
28
  schema:
26
29
  _class: Expressir::Model::Expressions::SimpleReference
27
30
  id: multiple_schema4
31
+ base_path: multiple_schema4
28
32
  items:
29
33
  - _class: Expressir::Model::InterfaceItem
30
34
  ref:
31
35
  _class: Expressir::Model::Expressions::SimpleReference
32
36
  id: attribute_entity
37
+ base_path: multiple_schema4.attribute_entity
33
38
  id: attribute_entity4
34
39
  entities:
35
40
  - _class: Expressir::Model::Entity
@@ -49,11 +54,13 @@ schemas:
49
54
  subtype_of:
50
55
  - _class: Expressir::Model::Expressions::SimpleReference
51
56
  id: empty_entity
57
+ base_path: multiple_schema1.empty_entity
52
58
  - _class: Expressir::Model::Entity
53
59
  id: subtype_attribute_entity
54
60
  subtype_of:
55
61
  - _class: Expressir::Model::Expressions::SimpleReference
56
62
  id: attribute_entity
63
+ base_path: multiple_schema1.attribute_entity
57
64
  attributes:
58
65
  - _class: Expressir::Model::Attribute
59
66
  kind: :EXPLICIT
@@ -67,6 +74,7 @@ schemas:
67
74
  entity:
68
75
  _class: Expressir::Model::Expressions::SimpleReference
69
76
  id: attribute_entity
77
+ base_path: multiple_schema1.attribute_entity
70
78
  attribute:
71
79
  _class: Expressir::Model::Expressions::SimpleReference
72
80
  id: test
@@ -77,6 +85,7 @@ schemas:
77
85
  subtype_of:
78
86
  - _class: Expressir::Model::Expressions::SimpleReference
79
87
  id: attribute_entity2
88
+ base_path: multiple_schema2.attribute_entity2
80
89
  attributes:
81
90
  - _class: Expressir::Model::Attribute
82
91
  kind: :EXPLICIT
@@ -90,6 +99,7 @@ schemas:
90
99
  entity:
91
100
  _class: Expressir::Model::Expressions::SimpleReference
92
101
  id: attribute_entity2
102
+ base_path: multiple_schema2.attribute_entity2
93
103
  attribute:
94
104
  _class: Expressir::Model::Expressions::SimpleReference
95
105
  id: test
@@ -100,6 +110,7 @@ schemas:
100
110
  subtype_of:
101
111
  - _class: Expressir::Model::Expressions::SimpleReference
102
112
  id: attribute_entity3
113
+ base_path: multiple_schema3.attribute_entity3
103
114
  attributes:
104
115
  - _class: Expressir::Model::Attribute
105
116
  kind: :EXPLICIT
@@ -113,6 +124,7 @@ schemas:
113
124
  entity:
114
125
  _class: Expressir::Model::Expressions::SimpleReference
115
126
  id: attribute_entity3
127
+ base_path: multiple_schema3.attribute_entity3
116
128
  attribute:
117
129
  _class: Expressir::Model::Expressions::SimpleReference
118
130
  id: test
@@ -123,6 +135,7 @@ schemas:
123
135
  subtype_of:
124
136
  - _class: Expressir::Model::Expressions::SimpleReference
125
137
  id: attribute_entity4
138
+ base_path: multiple_schema4.attribute_entity
126
139
  attributes:
127
140
  - _class: Expressir::Model::Attribute
128
141
  kind: :EXPLICIT
@@ -136,6 +149,7 @@ schemas:
136
149
  entity:
137
150
  _class: Expressir::Model::Expressions::SimpleReference
138
151
  id: attribute_entity4
152
+ base_path: multiple_schema4.attribute_entity
139
153
  attribute:
140
154
  _class: Expressir::Model::Expressions::SimpleReference
141
155
  id: test
@@ -107,9 +107,11 @@ schemas:
107
107
  type:
108
108
  _class: Expressir::Model::Expressions::SimpleReference
109
109
  id: remark_entity
110
+ base_path: remark_schema.remark_entity
110
111
  expression:
111
112
  _class: Expressir::Model::Expressions::SimpleReference
112
113
  id: remark_attribute
114
+ base_path: remark_schema.remark_entity.remark_attribute
113
115
  unique:
114
116
  - _class: Expressir::Model::Unique
115
117
  id: UR1
@@ -120,6 +122,7 @@ schemas:
120
122
  attributes:
121
123
  - _class: Expressir::Model::Expressions::SimpleReference
122
124
  id: remark_attribute
125
+ base_path: remark_schema.remark_entity.remark_attribute
123
126
  where:
124
127
  - _class: Expressir::Model::Where
125
128
  id: WR1
@@ -152,6 +155,7 @@ schemas:
152
155
  applies_to:
153
156
  _class: Expressir::Model::Expressions::SimpleReference
154
157
  id: remark_entity
158
+ base_path: remark_schema.remark_entity
155
159
  functions:
156
160
  - _class: Expressir::Model::Function
157
161
  id: remark_function
@@ -218,6 +222,7 @@ schemas:
218
222
  expression:
219
223
  _class: Expressir::Model::Expressions::SimpleReference
220
224
  id: remark_variable
225
+ base_path: remark_schema.remark_function.remark_variable
221
226
  statements:
222
227
  - _class: Expressir::Model::Statements::Null
223
228
  - _class: Expressir::Model::Statements::Repeat
@@ -236,6 +241,7 @@ schemas:
236
241
  ref:
237
242
  _class: Expressir::Model::Expressions::SimpleReference
238
243
  id: remark_variable
244
+ base_path: remark_schema.remark_function.remark_variable
239
245
  expression:
240
246
  _class: Expressir::Model::Expressions::QueryExpression
241
247
  id: remark_query
@@ -244,6 +250,7 @@ schemas:
244
250
  aggregate_source:
245
251
  _class: Expressir::Model::Expressions::SimpleReference
246
252
  id: remark_variable
253
+ base_path: remark_schema.remark_function.remark_variable
247
254
  expression:
248
255
  _class: Expressir::Model::Literals::Logical
249
256
  value: :TRUE
@@ -256,6 +263,7 @@ schemas:
256
263
  applies_to:
257
264
  - _class: Expressir::Model::Expressions::SimpleReference
258
265
  id: remark_entity
266
+ base_path: remark_schema.remark_entity
259
267
  types:
260
268
  - _class: Expressir::Model::Type
261
269
  id: remark_type
@@ -304,6 +312,7 @@ schemas:
304
312
  expression:
305
313
  _class: Expressir::Model::Expressions::SimpleReference
306
314
  id: remark_variable
315
+ base_path: remark_schema.remark_rule.remark_variable
307
316
  statements:
308
317
  - _class: Expressir::Model::Statements::Null
309
318
  - _class: Expressir::Model::Statements::Repeat
@@ -322,6 +331,7 @@ schemas:
322
331
  ref:
323
332
  _class: Expressir::Model::Expressions::SimpleReference
324
333
  id: remark_variable
334
+ base_path: remark_schema.remark_rule.remark_variable
325
335
  expression:
326
336
  _class: Expressir::Model::Expressions::QueryExpression
327
337
  id: remark_query
@@ -330,6 +340,7 @@ schemas:
330
340
  aggregate_source:
331
341
  _class: Expressir::Model::Expressions::SimpleReference
332
342
  id: remark_variable
343
+ base_path: remark_schema.remark_rule.remark_variable
333
344
  expression:
334
345
  _class: Expressir::Model::Literals::Logical
335
346
  value: :TRUE
@@ -421,6 +432,7 @@ schemas:
421
432
  expression:
422
433
  _class: Expressir::Model::Expressions::SimpleReference
423
434
  id: remark_variable
435
+ base_path: remark_schema.remark_procedure.remark_variable
424
436
  statements:
425
437
  - _class: Expressir::Model::Statements::Null
426
438
  - _class: Expressir::Model::Statements::Repeat
@@ -439,6 +451,7 @@ schemas:
439
451
  ref:
440
452
  _class: Expressir::Model::Expressions::SimpleReference
441
453
  id: remark_variable
454
+ base_path: remark_schema.remark_procedure.remark_variable
442
455
  expression:
443
456
  _class: Expressir::Model::Expressions::QueryExpression
444
457
  id: remark_query
@@ -447,6 +460,7 @@ schemas:
447
460
  aggregate_source:
448
461
  _class: Expressir::Model::Expressions::SimpleReference
449
462
  id: remark_variable
463
+ base_path: remark_schema.remark_procedure.remark_variable
450
464
  expression:
451
465
  _class: Expressir::Model::Literals::Logical
452
466
  value: :TRUE
@@ -1,3 +1,4 @@
1
1
  SCHEMA single_schema;
2
2
  ENTITY empty_entity; END_ENTITY;
3
+ ENTITY subtype_empty_entity SUBTYPE OF (empty_entity); END_ENTITY;
3
4
  END_SCHEMA;
@@ -7,3 +7,9 @@ schemas:
7
7
  entities:
8
8
  - _class: Expressir::Model::Entity
9
9
  id: empty_entity
10
+ - _class: Expressir::Model::Entity
11
+ id: subtype_empty_entity
12
+ subtype_of:
13
+ - _class: Expressir::Model::Expressions::SimpleReference
14
+ id: empty_entity
15
+ base_path: single_schema.empty_entity