expressir 2.4.82 → 2.4.83

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lane-parity.yml +6 -1
  3. data/.github/workflows/rust-ext.yml +8 -1
  4. data/README.adoc +130 -1
  5. data/docs/_guides/formatter/formatter-architecture.adoc +169 -1
  6. data/docs/_guides/ruby-api/formatting-schemas.adoc +64 -0
  7. data/lib/expressir/express/builders/entity_decl_builder.rb +3 -0
  8. data/lib/expressir/express/builders/function_decl_builder.rb +1 -0
  9. data/lib/expressir/express/builders/procedure_decl_builder.rb +1 -0
  10. data/lib/expressir/express/builders/rule_decl_builder.rb +1 -0
  11. data/lib/expressir/express/builders/subtype_constraint_builder.rb +7 -1
  12. data/lib/expressir/express/formatter.rb +4 -3
  13. data/lib/expressir/express/formatters/data_types_formatter.rb +39 -21
  14. data/lib/expressir/express/formatters/declarations_formatter.rb +69 -57
  15. data/lib/expressir/express/formatters/remark_formatter.rb +53 -1
  16. data/lib/expressir/express/formatters/statements_formatter.rb +1 -0
  17. data/lib/expressir/express/formatters/supertype_expressions_formatter.rb +66 -1
  18. data/lib/expressir/express/line_map.rb +8 -0
  19. data/lib/expressir/express/node_position_index.rb +74 -4
  20. data/lib/expressir/express/pretty_formatter.rb +22 -5
  21. data/lib/expressir/express/remark_attacher.rb +665 -29
  22. data/lib/expressir/express/schema_compare.rb +2 -1
  23. data/lib/expressir/express/shtolo.rb +3 -0
  24. data/lib/expressir/model/declarations/entity.rb +5 -0
  25. data/lib/expressir/model/declarations/function.rb +4 -0
  26. data/lib/expressir/model/declarations/procedure.rb +4 -0
  27. data/lib/expressir/model/declarations/remark_item.rb +4 -0
  28. data/lib/expressir/model/declarations/rule.rb +4 -0
  29. data/lib/expressir/model/references/simple_reference.rb +1 -0
  30. data/lib/expressir/model/remark_placement.rb +6 -0
  31. data/lib/expressir/version.rb +1 -1
  32. metadata +2 -2
@@ -145,8 +145,7 @@ module Expressir
145
145
  "\n",
146
146
  indent([
147
147
  "ABSTRACT",
148
- " ",
149
- "SUPERTYPE",
148
+ *(node.abstract_entity ? [] : [" ", "SUPERTYPE"]),
150
149
  ].join),
151
150
  ].join
152
151
  end,
@@ -202,31 +201,37 @@ module Expressir
202
201
  *if explicit_attributes&.length&.positive?
203
202
  indent(format_grouped_declarations(explicit_attributes, method(:format_declarations_attribute)).join("\n"))
204
203
  end,
204
+ # A comment after the last member of a section closes it, before the
205
+ # keyword of the next section or END_ENTITY.
206
+ *format_closing_remarks(node, :attributes).map { |x| indent(x) },
205
207
  *if derived_attributes&.length&.positive?
206
208
  [
207
209
  "DERIVE",
208
210
  indent(derived_attributes.map { |x| format(x) }.join("\n")),
209
211
  ]
210
212
  end,
213
+ *format_closing_remarks(node, :derived_attributes).map { |x| indent(x) },
211
214
  *if inverse_attributes&.length&.positive?
212
215
  [
213
216
  "INVERSE",
214
217
  indent(inverse_attributes.map { |x| format(x) }.join("\n")),
215
218
  ]
216
219
  end,
220
+ *format_closing_remarks(node, :inverse_attributes).map { |x| indent(x) },
217
221
  *if node.unique_rules&.length&.positive?
218
222
  [
219
223
  "UNIQUE",
220
224
  indent(node.unique_rules.map { |x| format(x) }.join("\n")),
221
225
  ]
222
226
  end,
227
+ *format_closing_remarks(node, :unique_rules).map { |x| indent(x) },
223
228
  *if node.where_rules&.length&.positive?
224
229
  [
225
230
  "WHERE",
226
231
  indent(node.where_rules.map { |x| format(x) }.join("\n")),
227
232
  ]
228
233
  end,
229
- *format_closing_remarks(node, :attributes, :where_rules).map { |x| indent(x) },
234
+ *format_closing_remarks(node, :where_rules).map { |x| indent(x) },
230
235
  [
231
236
  "END_ENTITY",
232
237
  ";",
@@ -373,7 +378,11 @@ module Expressir
373
378
  name_padding = " " * (max_name_len - constant.id.length)
374
379
  type_padding = " " * (max_type_len - type_str.length)
375
380
 
376
- "#{constant.id}#{name_padding} : #{type_str}#{type_padding} := #{format(constant.expression)};"
381
+ # A comment on a line of its own above the constant leads it.
382
+ [
383
+ *format_leading_statement_remarks(constant),
384
+ "#{constant.id}#{name_padding} : #{type_str}#{type_padding} := #{format(constant.expression)};",
385
+ ].join("\n")
377
386
  end
378
387
 
379
388
  formatted.join("\n")
@@ -431,6 +440,9 @@ module Expressir
431
440
  "",
432
441
  ]
433
442
  end,
443
+ *format_trailing_region_remarks(node, :declarations).then do |x|
444
+ x.empty? || schema_declarations&.length&.positive? ? x : ["", *x]
445
+ end,
434
446
  [
435
447
  "END_SCHEMA",
436
448
  ";",
@@ -545,10 +557,15 @@ module Expressir
545
557
  ].join,
546
558
  ].join("\n"))
547
559
  end,
560
+ # A comment on its own line before LOCAL closes the declarations.
561
+ *format_trailing_region_remarks(node, :declarations).map { |x| indent(x) },
548
562
  *if node.variables&.length&.positive?
549
563
  indent([
550
564
  "LOCAL",
551
- indent(format_grouped_declarations(node.variables, method(:format_declarations_variable)).join("\n")),
565
+ indent([
566
+ *format_grouped_declarations(node.variables, method(:format_declarations_variable)),
567
+ *format_trailing_region_remarks(node, :variables),
568
+ ].join("\n")),
552
569
  [
553
570
  "END_LOCAL",
554
571
  ";",