herb 0.9.1-aarch64-linux-gnu → 0.9.3-aarch64-linux-gnu

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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/config.yml +125 -0
  4. data/ext/herb/error_helpers.c +172 -2
  5. data/ext/herb/extconf.rb +6 -0
  6. data/ext/herb/extension.c +16 -2
  7. data/ext/herb/extension_helpers.c +6 -5
  8. data/ext/herb/extension_helpers.h +4 -4
  9. data/ext/herb/nodes.c +89 -3
  10. data/lib/herb/3.0/herb.so +0 -0
  11. data/lib/herb/3.1/herb.so +0 -0
  12. data/lib/herb/3.2/herb.so +0 -0
  13. data/lib/herb/3.3/herb.so +0 -0
  14. data/lib/herb/3.4/herb.so +0 -0
  15. data/lib/herb/4.0/herb.so +0 -0
  16. data/lib/herb/ast/erb_content_node.rb +32 -0
  17. data/lib/herb/ast/nodes.rb +244 -3
  18. data/lib/herb/cli.rb +12 -2
  19. data/lib/herb/engine/compiler.rb +136 -97
  20. data/lib/herb/engine/validators/security_validator.rb +40 -0
  21. data/lib/herb/engine.rb +21 -0
  22. data/lib/herb/errors.rb +268 -0
  23. data/lib/herb/parser_options.rb +7 -2
  24. data/lib/herb/version.rb +1 -1
  25. data/lib/herb/visitor.rb +82 -0
  26. data/lib/herb.rb +1 -0
  27. data/sig/herb/ast/erb_content_node.rbs +13 -0
  28. data/sig/herb/ast/nodes.rbs +98 -2
  29. data/sig/herb/engine/compiler.rbs +18 -3
  30. data/sig/herb/engine/validators/security_validator.rbs +4 -0
  31. data/sig/herb/engine.rbs +4 -0
  32. data/sig/herb/errors.rbs +122 -0
  33. data/sig/herb/parser_options.rbs +6 -2
  34. data/sig/herb/visitor.rbs +12 -0
  35. data/sig/serialized_ast_errors.rbs +29 -0
  36. data/sig/serialized_ast_nodes.rbs +19 -0
  37. data/src/analyze/action_view/attribute_extraction_helpers.c +425 -87
  38. data/src/analyze/action_view/image_tag.c +87 -0
  39. data/src/analyze/action_view/javascript_include_tag.c +102 -0
  40. data/src/analyze/action_view/javascript_tag.c +55 -0
  41. data/src/analyze/action_view/registry.c +10 -3
  42. data/src/analyze/action_view/tag.c +19 -2
  43. data/src/analyze/action_view/tag_helper_node_builders.c +119 -37
  44. data/src/analyze/action_view/tag_helpers.c +1033 -32
  45. data/src/analyze/analyze.c +165 -10
  46. data/src/analyze/{helpers.c → analyze_helpers.c} +1 -1
  47. data/src/analyze/analyzed_ruby.c +1 -1
  48. data/src/analyze/builders.c +11 -8
  49. data/src/analyze/conditional_elements.c +6 -7
  50. data/src/analyze/conditional_open_tags.c +6 -7
  51. data/src/analyze/control_type.c +4 -2
  52. data/src/analyze/invalid_structures.c +5 -5
  53. data/src/analyze/missing_end.c +2 -2
  54. data/src/analyze/parse_errors.c +5 -5
  55. data/src/analyze/prism_annotate.c +7 -7
  56. data/src/analyze/render_nodes.c +6 -26
  57. data/src/analyze/strict_locals.c +637 -0
  58. data/src/analyze/transform.c +7 -0
  59. data/src/{ast_node.c → ast/ast_node.c} +8 -8
  60. data/src/{ast_nodes.c → ast/ast_nodes.c} +82 -11
  61. data/src/{ast_pretty_print.c → ast/ast_pretty_print.c} +113 -9
  62. data/src/{pretty_print.c → ast/pretty_print.c} +9 -9
  63. data/src/errors.c +398 -8
  64. data/src/extract.c +5 -5
  65. data/src/herb.c +15 -5
  66. data/src/include/analyze/action_view/attribute_extraction_helpers.h +3 -1
  67. data/src/include/analyze/action_view/tag_helper_handler.h +3 -3
  68. data/src/include/analyze/action_view/tag_helper_node_builders.h +34 -5
  69. data/src/include/analyze/action_view/tag_helpers.h +4 -3
  70. data/src/include/analyze/analyze.h +6 -4
  71. data/src/include/analyze/analyzed_ruby.h +2 -2
  72. data/src/include/analyze/builders.h +4 -4
  73. data/src/include/analyze/conditional_elements.h +2 -2
  74. data/src/include/analyze/conditional_open_tags.h +2 -2
  75. data/src/include/analyze/control_type.h +1 -1
  76. data/src/include/analyze/helpers.h +2 -2
  77. data/src/include/analyze/invalid_structures.h +1 -1
  78. data/src/include/analyze/prism_annotate.h +2 -2
  79. data/src/include/analyze/render_nodes.h +1 -1
  80. data/src/include/analyze/strict_locals.h +11 -0
  81. data/src/include/{ast_node.h → ast/ast_node.h} +4 -4
  82. data/src/include/{ast_nodes.h → ast/ast_nodes.h} +38 -14
  83. data/src/include/{ast_pretty_print.h → ast/ast_pretty_print.h} +3 -3
  84. data/src/include/{pretty_print.h → ast/pretty_print.h} +4 -4
  85. data/src/include/errors.h +65 -7
  86. data/src/include/extract.h +2 -2
  87. data/src/include/herb.h +5 -5
  88. data/src/include/{lex_helpers.h → lexer/lex_helpers.h} +5 -5
  89. data/src/include/{lexer.h → lexer/lexer.h} +1 -1
  90. data/src/include/{lexer_peek_helpers.h → lexer/lexer_peek_helpers.h} +2 -2
  91. data/src/include/{lexer_struct.h → lexer/lexer_struct.h} +2 -2
  92. data/src/include/{token.h → lexer/token.h} +3 -3
  93. data/src/include/{token_matchers.h → lexer/token_matchers.h} +1 -1
  94. data/src/include/{token_struct.h → lexer/token_struct.h} +3 -3
  95. data/src/include/{util → lib}/hb_foreach.h +1 -1
  96. data/src/include/{util → lib}/hb_string.h +5 -1
  97. data/src/include/{location.h → location/location.h} +1 -1
  98. data/src/include/parser/dot_notation.h +12 -0
  99. data/src/include/{parser.h → parser/parser.h} +11 -4
  100. data/src/include/{parser_helpers.h → parser/parser_helpers.h} +6 -6
  101. data/src/include/{prism_context.h → prism/prism_context.h} +2 -2
  102. data/src/include/{prism_helpers.h → prism/prism_helpers.h} +6 -6
  103. data/src/include/{html_util.h → util/html_util.h} +2 -1
  104. data/src/include/util/ruby_util.h +9 -0
  105. data/src/include/{utf8.h → util/utf8.h} +1 -1
  106. data/src/include/{util.h → util/util.h} +1 -1
  107. data/src/include/version.h +1 -1
  108. data/src/include/visitor.h +3 -3
  109. data/src/{lexer_peek_helpers.c → lexer/lexer_peek_helpers.c} +3 -3
  110. data/src/{token.c → lexer/token.c} +8 -8
  111. data/src/{token_matchers.c → lexer/token_matchers.c} +2 -2
  112. data/src/lexer.c +6 -6
  113. data/src/{util → lib}/hb_allocator.c +2 -2
  114. data/src/{util → lib}/hb_arena.c +4 -8
  115. data/src/{util → lib}/hb_arena_debug.c +2 -2
  116. data/src/{util → lib}/hb_array.c +2 -2
  117. data/src/{util → lib}/hb_buffer.c +2 -2
  118. data/src/{util → lib}/hb_narray.c +1 -1
  119. data/src/{util → lib}/hb_string.c +2 -2
  120. data/src/{location.c → location/location.c} +2 -2
  121. data/src/{position.c → location/position.c} +2 -2
  122. data/src/{range.c → location/range.c} +1 -1
  123. data/src/main.c +11 -11
  124. data/src/parser/dot_notation.c +100 -0
  125. data/src/{parser_match_tags.c → parser/match_tags.c} +34 -5
  126. data/src/{parser_helpers.c → parser/parser_helpers.c} +10 -10
  127. data/src/parser.c +68 -32
  128. data/src/{prism_helpers.c → prism/prism_helpers.c} +7 -7
  129. data/src/{ruby_parser.c → prism/ruby_parser.c} +1 -1
  130. data/src/{html_util.c → util/html_util.c} +54 -4
  131. data/src/{io.c → util/io.c} +3 -3
  132. data/src/util/ruby_util.c +42 -0
  133. data/src/{utf8.c → util/utf8.c} +2 -2
  134. data/src/{util.c → util/util.c} +4 -4
  135. data/src/visitor.c +35 -3
  136. data/templates/ext/herb/error_helpers.c.erb +2 -2
  137. data/templates/ext/herb/nodes.c.erb +1 -1
  138. data/templates/java/error_helpers.c.erb +1 -1
  139. data/templates/java/error_helpers.h.erb +2 -2
  140. data/templates/java/nodes.c.erb +4 -4
  141. data/templates/java/nodes.h.erb +1 -1
  142. data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +4 -4
  143. data/templates/javascript/packages/node/extension/nodes.cpp.erb +4 -4
  144. data/templates/lib/herb/visitor.rb.erb +14 -0
  145. data/templates/src/analyze/missing_end.c.erb +2 -2
  146. data/templates/src/{ast_nodes.c.erb → ast/ast_nodes.c.erb} +9 -9
  147. data/templates/src/{ast_pretty_print.c.erb → ast/ast_pretty_print.c.erb} +8 -8
  148. data/templates/src/errors.c.erb +8 -8
  149. data/templates/src/include/{ast_nodes.h.erb → ast/ast_nodes.h.erb} +11 -12
  150. data/templates/src/include/{ast_pretty_print.h.erb → ast/ast_pretty_print.h.erb} +2 -2
  151. data/templates/src/include/errors.h.erb +7 -7
  152. data/templates/src/{parser_match_tags.c.erb → parser/match_tags.c.erb} +4 -4
  153. data/templates/src/visitor.c.erb +3 -3
  154. data/templates/wasm/error_helpers.cpp.erb +4 -4
  155. data/templates/wasm/nodes.cpp.erb +5 -5
  156. metadata +78 -68
  157. data/src/include/element_source.h +0 -10
  158. /data/src/include/{util → lib}/hb_allocator.h +0 -0
  159. /data/src/include/{util → lib}/hb_arena.h +0 -0
  160. /data/src/include/{util → lib}/hb_arena_debug.h +0 -0
  161. /data/src/include/{util → lib}/hb_array.h +0 -0
  162. /data/src/include/{util → lib}/hb_buffer.h +0 -0
  163. /data/src/include/{util → lib}/hb_narray.h +0 -0
  164. /data/src/include/{util → lib}/string.h +0 -0
  165. /data/src/include/{position.h → location/position.h} +0 -0
  166. /data/src/include/{range.h → location/range.h} +0 -0
  167. /data/src/include/{herb_prism_node.h → prism/herb_prism_node.h} +0 -0
  168. /data/src/include/{prism_serialized.h → prism/prism_serialized.h} +0 -0
  169. /data/src/include/{ruby_parser.h → prism/ruby_parser.h} +0 -0
  170. /data/src/include/{io.h → util/io.h} +0 -0
  171. /data/templates/src/include/{util → lib}/hb_foreach.h.erb +0 -0
data/lib/herb/errors.rb CHANGED
@@ -1258,5 +1258,273 @@ module Herb
1258
1258
  end
1259
1259
  end
1260
1260
 
1261
+ class StrictLocalsPositionalArgumentError < Error
1262
+ include Colors
1263
+
1264
+ #| name: String?,
1265
+ #| }
1266
+
1267
+ attr_reader :name #: String?
1268
+
1269
+ #: (String, Location?, String, String) -> void
1270
+ def initialize(type, location, message, name)
1271
+ super(type, location, message)
1272
+ @name = name
1273
+ end
1274
+
1275
+ #: () -> String
1276
+ def inspect
1277
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1278
+ end
1279
+
1280
+ #: () -> serialized_strict_locals_positional_argument_error
1281
+ def to_hash
1282
+ super.merge(
1283
+ name: name
1284
+ ) #: Herb::serialized_strict_locals_positional_argument_error
1285
+ end
1286
+
1287
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1288
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1289
+ output = +""
1290
+
1291
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1292
+ output += white("├── message: #{green(message.inspect)}\n")
1293
+ output += white("└── name: #{green(name.inspect)}\n")
1294
+ output += %(\n)
1295
+
1296
+ output.gsub(/^/, " " * indent)
1297
+ end
1298
+ end
1299
+
1300
+ class StrictLocalsBlockArgumentError < Error
1301
+ include Colors
1302
+
1303
+ #| name: String?,
1304
+ #| }
1305
+
1306
+ attr_reader :name #: String?
1307
+
1308
+ #: (String, Location?, String, String) -> void
1309
+ def initialize(type, location, message, name)
1310
+ super(type, location, message)
1311
+ @name = name
1312
+ end
1313
+
1314
+ #: () -> String
1315
+ def inspect
1316
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1317
+ end
1318
+
1319
+ #: () -> serialized_strict_locals_block_argument_error
1320
+ def to_hash
1321
+ super.merge(
1322
+ name: name
1323
+ ) #: Herb::serialized_strict_locals_block_argument_error
1324
+ end
1325
+
1326
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1327
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1328
+ output = +""
1329
+
1330
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1331
+ output += white("├── message: #{green(message.inspect)}\n")
1332
+ output += white("└── name: #{green(name.inspect)}\n")
1333
+ output += %(\n)
1334
+
1335
+ output.gsub(/^/, " " * indent)
1336
+ end
1337
+ end
1338
+
1339
+ class StrictLocalsSplatArgumentError < Error
1340
+ include Colors
1341
+
1342
+ #| name: String?,
1343
+ #| }
1344
+
1345
+ attr_reader :name #: String?
1346
+
1347
+ #: (String, Location?, String, String) -> void
1348
+ def initialize(type, location, message, name)
1349
+ super(type, location, message)
1350
+ @name = name
1351
+ end
1352
+
1353
+ #: () -> String
1354
+ def inspect
1355
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1356
+ end
1357
+
1358
+ #: () -> serialized_strict_locals_splat_argument_error
1359
+ def to_hash
1360
+ super.merge(
1361
+ name: name
1362
+ ) #: Herb::serialized_strict_locals_splat_argument_error
1363
+ end
1364
+
1365
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1366
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1367
+ output = +""
1368
+
1369
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1370
+ output += white("├── message: #{green(message.inspect)}\n")
1371
+ output += white("└── name: #{green(name.inspect)}\n")
1372
+ output += %(\n)
1373
+
1374
+ output.gsub(/^/, " " * indent)
1375
+ end
1376
+ end
1377
+
1378
+ class StrictLocalsMissingParenthesisError < Error
1379
+ include Colors
1380
+
1381
+ #| rest: String?,
1382
+ #| }
1383
+
1384
+ attr_reader :rest #: String?
1385
+
1386
+ #: (String, Location?, String, String) -> void
1387
+ def initialize(type, location, message, rest)
1388
+ super(type, location, message)
1389
+ @rest = rest
1390
+ end
1391
+
1392
+ #: () -> String
1393
+ def inspect
1394
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1395
+ end
1396
+
1397
+ #: () -> serialized_strict_locals_missing_parenthesis_error
1398
+ def to_hash
1399
+ super.merge(
1400
+ rest: rest
1401
+ ) #: Herb::serialized_strict_locals_missing_parenthesis_error
1402
+ end
1403
+
1404
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1405
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1406
+ output = +""
1407
+
1408
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1409
+ output += white("├── message: #{green(message.inspect)}\n")
1410
+ output += white("└── rest: #{green(rest.inspect)}\n")
1411
+ output += %(\n)
1412
+
1413
+ output.gsub(/^/, " " * indent)
1414
+ end
1415
+ end
1416
+
1417
+ class StrictLocalsDuplicateDeclarationError < Error
1418
+ include Colors
1419
+
1420
+ #: () -> String
1421
+ def inspect
1422
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1423
+ end
1424
+
1425
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1426
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1427
+ output = +""
1428
+
1429
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1430
+ output += white("└── message: #{green(message.inspect)}\n")
1431
+ output += %(\n)
1432
+
1433
+ output.gsub(/^/, " " * indent)
1434
+ end
1435
+ end
1436
+
1437
+ class VoidElementContentError < Error
1438
+ include Colors
1439
+
1440
+ #| tag_name: Herb::Token?,
1441
+ #| helper_name: String?,
1442
+ #| content_type: String?,
1443
+ #| }
1444
+
1445
+ attr_reader :tag_name #: Herb::Token?
1446
+ attr_reader :helper_name #: String?
1447
+ attr_reader :content_type #: String?
1448
+
1449
+ #: (String, Location?, String, Herb::Token, String, String) -> void
1450
+ def initialize(type, location, message, tag_name, helper_name, content_type)
1451
+ super(type, location, message)
1452
+ @tag_name = tag_name
1453
+ @helper_name = helper_name
1454
+ @content_type = content_type
1455
+ end
1456
+
1457
+ #: () -> String
1458
+ def inspect
1459
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1460
+ end
1461
+
1462
+ #: () -> serialized_void_element_content_error
1463
+ def to_hash
1464
+ super.merge(
1465
+ tag_name: tag_name,
1466
+ helper_name: helper_name,
1467
+ content_type: content_type
1468
+ ) #: Herb::serialized_void_element_content_error
1469
+ end
1470
+
1471
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1472
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1473
+ output = +""
1474
+
1475
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1476
+ output += white("├── message: #{green(message.inspect)}\n")
1477
+ output += white("├── tag_name: ")
1478
+ output += tag_name ? tag_name.tree_inspect : magenta("∅")
1479
+ output += "\n"
1480
+ output += white("├── helper_name: #{green(helper_name.inspect)}\n")
1481
+ output += white("└── content_type: #{green(content_type.inspect)}\n")
1482
+ output += %(\n)
1483
+
1484
+ output.gsub(/^/, " " * indent)
1485
+ end
1486
+ end
1487
+
1488
+ class DotNotationCasingError < Error
1489
+ include Colors
1490
+
1491
+ #| segment: Herb::Token?,
1492
+ #| }
1493
+
1494
+ attr_reader :segment #: Herb::Token?
1495
+
1496
+ #: (String, Location?, String, Herb::Token) -> void
1497
+ def initialize(type, location, message, segment)
1498
+ super(type, location, message)
1499
+ @segment = segment
1500
+ end
1501
+
1502
+ #: () -> String
1503
+ def inspect
1504
+ tree_inspect.rstrip.gsub(/\s+$/, "")
1505
+ end
1506
+
1507
+ #: () -> serialized_dot_notation_casing_error
1508
+ def to_hash
1509
+ super.merge(
1510
+ segment: segment
1511
+ ) #: Herb::serialized_dot_notation_casing_error
1512
+ end
1513
+
1514
+ #: (?indent: Integer, ?depth: Integer, ?depth_limit: Integer) -> String
1515
+ def tree_inspect(indent: 0, depth: 0, depth_limit: 25)
1516
+ output = +""
1517
+
1518
+ output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect})\n")}")
1519
+ output += white("├── message: #{green(message.inspect)}\n")
1520
+ output += white("└── segment: ")
1521
+ output += segment ? segment.tree_inspect : magenta("∅")
1522
+ output += "\n"
1523
+ output += %(\n)
1524
+
1525
+ output.gsub(/^/, " " * indent)
1526
+ end
1527
+ end
1528
+
1261
1529
  end
1262
1530
  end
@@ -7,6 +7,7 @@ module Herb
7
7
  attr_reader :analyze #: bool
8
8
  attr_reader :action_view_helpers #: bool
9
9
  attr_reader :render_nodes #: bool
10
+ attr_reader :strict_locals #: bool
10
11
  attr_reader :prism_program #: bool
11
12
  attr_reader :prism_nodes #: bool
12
13
  attr_reader :prism_nodes_deep #: bool
@@ -16,17 +17,19 @@ module Herb
16
17
  DEFAULT_ANALYZE = true #: bool
17
18
  DEFAULT_ACTION_VIEW_HELPERS = false #: bool
18
19
  DEFAULT_RENDER_NODES = false #: bool
20
+ DEFAULT_STRICT_LOCALS = false #: bool
19
21
  DEFAULT_PRISM_PROGRAM = false #: bool
20
22
  DEFAULT_PRISM_NODES = false #: bool
21
23
  DEFAULT_PRISM_NODES_DEEP = false #: bool
22
24
 
23
- #: (?strict: bool, ?track_whitespace: bool, ?analyze: bool, ?action_view_helpers: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool) -> void
24
- def initialize(strict: DEFAULT_STRICT, track_whitespace: DEFAULT_TRACK_WHITESPACE, analyze: DEFAULT_ANALYZE, action_view_helpers: DEFAULT_ACTION_VIEW_HELPERS, render_nodes: DEFAULT_RENDER_NODES, prism_nodes: DEFAULT_PRISM_NODES, prism_nodes_deep: DEFAULT_PRISM_NODES_DEEP, prism_program: DEFAULT_PRISM_PROGRAM)
25
+ #: (?strict: bool, ?track_whitespace: bool, ?analyze: bool, ?action_view_helpers: bool, ?render_nodes: bool, ?strict_locals: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool) -> void
26
+ def initialize(strict: DEFAULT_STRICT, track_whitespace: DEFAULT_TRACK_WHITESPACE, analyze: DEFAULT_ANALYZE, action_view_helpers: DEFAULT_ACTION_VIEW_HELPERS, render_nodes: DEFAULT_RENDER_NODES, strict_locals: DEFAULT_STRICT_LOCALS, prism_nodes: DEFAULT_PRISM_NODES, prism_nodes_deep: DEFAULT_PRISM_NODES_DEEP, prism_program: DEFAULT_PRISM_PROGRAM)
25
27
  @strict = strict
26
28
  @track_whitespace = track_whitespace
27
29
  @analyze = analyze
28
30
  @action_view_helpers = action_view_helpers
29
31
  @render_nodes = render_nodes
32
+ @strict_locals = strict_locals
30
33
  @prism_nodes = prism_nodes
31
34
  @prism_nodes_deep = prism_nodes_deep
32
35
  @prism_program = prism_program
@@ -40,6 +43,7 @@ module Herb
40
43
  analyze: @analyze,
41
44
  action_view_helpers: @action_view_helpers,
42
45
  render_nodes: @render_nodes,
46
+ strict_locals: @strict_locals,
43
47
  prism_nodes: @prism_nodes,
44
48
  prism_nodes_deep: @prism_nodes_deep,
45
49
  prism_program: @prism_program,
@@ -54,6 +58,7 @@ module Herb
54
58
  "analyze=#{@analyze}\n " \
55
59
  "action_view_helpers=#{@action_view_helpers}\n " \
56
60
  "render_nodes=#{@render_nodes}\n " \
61
+ "strict_locals=#{@strict_locals}\n " \
57
62
  "prism_nodes=#{@prism_nodes}\n " \
58
63
  "prism_nodes_deep=#{@prism_nodes_deep}\n " \
59
64
  "prism_program=#{@prism_program}>"
data/lib/herb/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
- VERSION = "0.9.1"
5
+ VERSION = "0.9.3"
6
6
  end
data/lib/herb/visitor.rb CHANGED
@@ -23,203 +23,285 @@ module Herb
23
23
  node.compact_child_nodes.each { |node| node.accept(self) }
24
24
  end
25
25
 
26
+ #: (Herb::AST::Node) -> void
27
+ def visit_node(node)
28
+ # Default implementation does nothing
29
+ end
30
+
31
+ #: (Herb::AST::Node) -> void
32
+ def visit_erb_node(node)
33
+ # Default implementation does nothing
34
+ end
35
+
26
36
  #: (Herb::AST::DocumentNode) -> void
27
37
  def visit_document_node(node)
38
+ visit_node(node)
28
39
  visit_child_nodes(node)
29
40
  end
30
41
 
31
42
  #: (Herb::AST::LiteralNode) -> void
32
43
  def visit_literal_node(node)
44
+ visit_node(node)
33
45
  visit_child_nodes(node)
34
46
  end
35
47
 
36
48
  #: (Herb::AST::HTMLOpenTagNode) -> void
37
49
  def visit_html_open_tag_node(node)
50
+ visit_node(node)
38
51
  visit_child_nodes(node)
39
52
  end
40
53
 
41
54
  #: (Herb::AST::HTMLConditionalOpenTagNode) -> void
42
55
  def visit_html_conditional_open_tag_node(node)
56
+ visit_node(node)
43
57
  visit_child_nodes(node)
44
58
  end
45
59
 
46
60
  #: (Herb::AST::HTMLCloseTagNode) -> void
47
61
  def visit_html_close_tag_node(node)
62
+ visit_node(node)
48
63
  visit_child_nodes(node)
49
64
  end
50
65
 
51
66
  #: (Herb::AST::HTMLOmittedCloseTagNode) -> void
52
67
  def visit_html_omitted_close_tag_node(node)
68
+ visit_node(node)
53
69
  visit_child_nodes(node)
54
70
  end
55
71
 
56
72
  #: (Herb::AST::HTMLVirtualCloseTagNode) -> void
57
73
  def visit_html_virtual_close_tag_node(node)
74
+ visit_node(node)
58
75
  visit_child_nodes(node)
59
76
  end
60
77
 
61
78
  #: (Herb::AST::HTMLElementNode) -> void
62
79
  def visit_html_element_node(node)
80
+ visit_node(node)
63
81
  visit_child_nodes(node)
64
82
  end
65
83
 
66
84
  #: (Herb::AST::HTMLConditionalElementNode) -> void
67
85
  def visit_html_conditional_element_node(node)
86
+ visit_node(node)
68
87
  visit_child_nodes(node)
69
88
  end
70
89
 
71
90
  #: (Herb::AST::HTMLAttributeValueNode) -> void
72
91
  def visit_html_attribute_value_node(node)
92
+ visit_node(node)
73
93
  visit_child_nodes(node)
74
94
  end
75
95
 
76
96
  #: (Herb::AST::HTMLAttributeNameNode) -> void
77
97
  def visit_html_attribute_name_node(node)
98
+ visit_node(node)
78
99
  visit_child_nodes(node)
79
100
  end
80
101
 
81
102
  #: (Herb::AST::HTMLAttributeNode) -> void
82
103
  def visit_html_attribute_node(node)
104
+ visit_node(node)
83
105
  visit_child_nodes(node)
84
106
  end
85
107
 
86
108
  #: (Herb::AST::RubyLiteralNode) -> void
87
109
  def visit_ruby_literal_node(node)
110
+ visit_node(node)
88
111
  visit_child_nodes(node)
89
112
  end
90
113
 
91
114
  #: (Herb::AST::RubyHTMLAttributesSplatNode) -> void
92
115
  def visit_ruby_html_attributes_splat_node(node)
116
+ visit_node(node)
93
117
  visit_child_nodes(node)
94
118
  end
95
119
 
96
120
  #: (Herb::AST::ERBOpenTagNode) -> void
97
121
  def visit_erb_open_tag_node(node)
122
+ visit_node(node)
123
+ visit_erb_node(node)
98
124
  visit_child_nodes(node)
99
125
  end
100
126
 
101
127
  #: (Herb::AST::HTMLTextNode) -> void
102
128
  def visit_html_text_node(node)
129
+ visit_node(node)
103
130
  visit_child_nodes(node)
104
131
  end
105
132
 
106
133
  #: (Herb::AST::HTMLCommentNode) -> void
107
134
  def visit_html_comment_node(node)
135
+ visit_node(node)
108
136
  visit_child_nodes(node)
109
137
  end
110
138
 
111
139
  #: (Herb::AST::HTMLDoctypeNode) -> void
112
140
  def visit_html_doctype_node(node)
141
+ visit_node(node)
113
142
  visit_child_nodes(node)
114
143
  end
115
144
 
116
145
  #: (Herb::AST::XMLDeclarationNode) -> void
117
146
  def visit_xml_declaration_node(node)
147
+ visit_node(node)
118
148
  visit_child_nodes(node)
119
149
  end
120
150
 
121
151
  #: (Herb::AST::CDATANode) -> void
122
152
  def visit_cdata_node(node)
153
+ visit_node(node)
123
154
  visit_child_nodes(node)
124
155
  end
125
156
 
126
157
  #: (Herb::AST::WhitespaceNode) -> void
127
158
  def visit_whitespace_node(node)
159
+ visit_node(node)
128
160
  visit_child_nodes(node)
129
161
  end
130
162
 
131
163
  #: (Herb::AST::ERBContentNode) -> void
132
164
  def visit_erb_content_node(node)
165
+ visit_node(node)
166
+ visit_erb_node(node)
133
167
  visit_child_nodes(node)
134
168
  end
135
169
 
136
170
  #: (Herb::AST::ERBEndNode) -> void
137
171
  def visit_erb_end_node(node)
172
+ visit_node(node)
173
+ visit_erb_node(node)
138
174
  visit_child_nodes(node)
139
175
  end
140
176
 
141
177
  #: (Herb::AST::ERBElseNode) -> void
142
178
  def visit_erb_else_node(node)
179
+ visit_node(node)
180
+ visit_erb_node(node)
143
181
  visit_child_nodes(node)
144
182
  end
145
183
 
146
184
  #: (Herb::AST::ERBIfNode) -> void
147
185
  def visit_erb_if_node(node)
186
+ visit_node(node)
187
+ visit_erb_node(node)
148
188
  visit_child_nodes(node)
149
189
  end
150
190
 
151
191
  #: (Herb::AST::ERBBlockNode) -> void
152
192
  def visit_erb_block_node(node)
193
+ visit_node(node)
194
+ visit_erb_node(node)
153
195
  visit_child_nodes(node)
154
196
  end
155
197
 
156
198
  #: (Herb::AST::ERBWhenNode) -> void
157
199
  def visit_erb_when_node(node)
200
+ visit_node(node)
201
+ visit_erb_node(node)
158
202
  visit_child_nodes(node)
159
203
  end
160
204
 
161
205
  #: (Herb::AST::ERBCaseNode) -> void
162
206
  def visit_erb_case_node(node)
207
+ visit_node(node)
208
+ visit_erb_node(node)
163
209
  visit_child_nodes(node)
164
210
  end
165
211
 
166
212
  #: (Herb::AST::ERBCaseMatchNode) -> void
167
213
  def visit_erb_case_match_node(node)
214
+ visit_node(node)
215
+ visit_erb_node(node)
168
216
  visit_child_nodes(node)
169
217
  end
170
218
 
171
219
  #: (Herb::AST::ERBWhileNode) -> void
172
220
  def visit_erb_while_node(node)
221
+ visit_node(node)
222
+ visit_erb_node(node)
173
223
  visit_child_nodes(node)
174
224
  end
175
225
 
176
226
  #: (Herb::AST::ERBUntilNode) -> void
177
227
  def visit_erb_until_node(node)
228
+ visit_node(node)
229
+ visit_erb_node(node)
178
230
  visit_child_nodes(node)
179
231
  end
180
232
 
181
233
  #: (Herb::AST::ERBForNode) -> void
182
234
  def visit_erb_for_node(node)
235
+ visit_node(node)
236
+ visit_erb_node(node)
183
237
  visit_child_nodes(node)
184
238
  end
185
239
 
186
240
  #: (Herb::AST::ERBRescueNode) -> void
187
241
  def visit_erb_rescue_node(node)
242
+ visit_node(node)
243
+ visit_erb_node(node)
188
244
  visit_child_nodes(node)
189
245
  end
190
246
 
191
247
  #: (Herb::AST::ERBEnsureNode) -> void
192
248
  def visit_erb_ensure_node(node)
249
+ visit_node(node)
250
+ visit_erb_node(node)
193
251
  visit_child_nodes(node)
194
252
  end
195
253
 
196
254
  #: (Herb::AST::ERBBeginNode) -> void
197
255
  def visit_erb_begin_node(node)
256
+ visit_node(node)
257
+ visit_erb_node(node)
198
258
  visit_child_nodes(node)
199
259
  end
200
260
 
201
261
  #: (Herb::AST::ERBUnlessNode) -> void
202
262
  def visit_erb_unless_node(node)
263
+ visit_node(node)
264
+ visit_erb_node(node)
203
265
  visit_child_nodes(node)
204
266
  end
205
267
 
206
268
  #: (Herb::AST::RubyRenderLocalNode) -> void
207
269
  def visit_ruby_render_local_node(node)
270
+ visit_node(node)
208
271
  visit_child_nodes(node)
209
272
  end
210
273
 
211
274
  #: (Herb::AST::ERBRenderNode) -> void
212
275
  def visit_erb_render_node(node)
276
+ visit_node(node)
277
+ visit_erb_node(node)
278
+ visit_child_nodes(node)
279
+ end
280
+
281
+ #: (Herb::AST::RubyStrictLocalNode) -> void
282
+ def visit_ruby_strict_local_node(node)
283
+ visit_node(node)
284
+ visit_child_nodes(node)
285
+ end
286
+
287
+ #: (Herb::AST::ERBStrictLocalsNode) -> void
288
+ def visit_erb_strict_locals_node(node)
289
+ visit_node(node)
290
+ visit_erb_node(node)
213
291
  visit_child_nodes(node)
214
292
  end
215
293
 
216
294
  #: (Herb::AST::ERBYieldNode) -> void
217
295
  def visit_erb_yield_node(node)
296
+ visit_node(node)
297
+ visit_erb_node(node)
218
298
  visit_child_nodes(node)
219
299
  end
220
300
 
221
301
  #: (Herb::AST::ERBInNode) -> void
222
302
  def visit_erb_in_node(node)
303
+ visit_node(node)
304
+ visit_erb_node(node)
223
305
  visit_child_nodes(node)
224
306
  end
225
307
 
data/lib/herb.rb CHANGED
@@ -17,6 +17,7 @@ require_relative "herb/parse_result"
17
17
  require_relative "herb/ast"
18
18
  require_relative "herb/ast/node"
19
19
  require_relative "herb/ast/nodes"
20
+ require_relative "herb/ast/erb_content_node"
20
21
  require_relative "herb/ast/helpers"
21
22
 
22
23
  require_relative "herb/errors"
@@ -0,0 +1,13 @@
1
+ # Generated from lib/herb/ast/erb_content_node.rb with RBS::Inline
2
+
3
+ module Herb
4
+ module AST
5
+ class ERBContentNode < Node
6
+ # : () -> Prism::node?
7
+ def parsed_prism_node: () -> Prism::node?
8
+
9
+ # : () -> Prism::node?
10
+ def prism: () -> Prism::node?
11
+ end
12
+ end
13
+ end