herb 0.11.0-arm-linux-gnu → 0.11.2-arm-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.
- checksums.yaml +4 -4
- data/Rakefile +4 -2
- data/config.yml +9 -0
- data/ext/herb/extconf.rb +8 -31
- data/ext/herb/nodes.c +90 -73
- data/ext/herb/parser_options_helpers.c +26 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/4.0/herb.so +0 -0
- data/lib/herb/analysis/partial_index.rb +1 -1
- data/lib/herb/analysis/partial_resolution.rb +27 -0
- data/lib/herb/ast/helpers.rb +1 -1
- data/lib/herb/ast/nodes.rb +32 -6
- data/lib/herb/bootstrap.rb +6 -2
- data/lib/herb/configuration.rb +11 -1
- data/lib/herb/dev/classifier.rb +1 -1
- data/lib/herb/dev/runner.rb +6 -1
- data/lib/herb/engine/compiler.rb +52 -19
- data/lib/herb/engine/slots/dynamics_compiler.rb +63 -14
- data/lib/herb/engine/slots/markers.rb +24 -0
- data/lib/herb/engine/slots/state_compiler.rb +1 -2
- data/lib/herb/engine/slots/subtree_compiler.rb +1 -1
- data/lib/herb/engine/slots/visitor.rb +71 -32
- data/lib/herb/engine/visitors/instrumentation_visitor.rb +18 -6
- data/lib/herb/engine.rb +0 -2
- data/lib/herb/parser_options.rb +6 -3
- data/lib/herb/project.rb +19 -8
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +1 -1
- data/sig/herb/analysis/partial_resolution.rbs +8 -0
- data/sig/herb/ast/nodes.rbs +10 -4
- data/sig/herb/bootstrap.rbs +2 -0
- data/sig/herb/configuration.rbs +3 -0
- data/sig/herb/dev/runner.rbs +3 -0
- data/sig/herb/engine/compiler.rbs +14 -3
- data/sig/herb/engine/slots/dynamics_compiler.rbs +27 -7
- data/sig/herb/engine/slots/markers.rbs +14 -0
- data/sig/herb/engine/slots/visitor.rbs +31 -13
- data/sig/herb/engine/visitors/instrumentation_visitor.rbs +5 -1
- data/sig/herb/parser_options.rbs +6 -4
- data/sig/herb.rbs +2 -2
- data/sig/serialized_ast_nodes.rbs +1 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +40 -21
- data/src/analyze/action_view/generated_handlers.c +36 -36
- data/src/analyze/action_view/image_tag.c +7 -3
- data/src/analyze/action_view/javascript_include_tag.c +6 -3
- data/src/analyze/action_view/link_to.c +23 -23
- data/src/analyze/action_view/registry.c +7 -3
- data/src/analyze/action_view/tag_helper_node_builders.c +12 -16
- data/src/analyze/action_view/tag_helpers.c +215 -110
- data/src/analyze/action_view/turbo_frame_tag.c +5 -4
- data/src/analyze/analyze.c +41 -45
- data/src/analyze/analyze_helpers.c +240 -405
- data/src/analyze/analyzed_ruby.c +10 -7
- data/src/analyze/builders.c +1 -0
- data/src/analyze/control_type.c +46 -29
- data/src/analyze/herb_directives.c +16 -20
- data/src/analyze/iteration_nodes.c +69 -24
- data/src/analyze/parse_errors.c +32 -22
- data/src/analyze/postfix_conditionals.c +23 -13
- data/src/analyze/prism_annotate.c +56 -32
- data/src/analyze/render_nodes.c +51 -41
- data/src/analyze/strict_locals.c +14 -15
- data/src/analyze/ternary_conditionals.c +14 -10
- data/src/ast/ast_nodes.c +3 -1
- data/src/ast/ast_pretty_print.c +5 -1
- data/src/extract.c +204 -143
- data/src/herb.c +10 -8
- data/src/include/analyze/action_view/tag_helper_handler.h +1 -1
- data/src/include/analyze/action_view/tag_helper_node_builders.h +1 -0
- data/src/include/analyze/action_view/tag_helpers.h +1 -1
- data/src/include/analyze/analyze.h +3 -24
- data/src/include/analyze/analyzed_ruby.h +29 -2
- data/src/include/analyze/helpers.h +7 -27
- data/src/include/ast/ast_nodes.h +2 -1
- data/src/include/herb.h +3 -2
- data/src/include/lexer/lexer.h +1 -0
- data/src/include/parser/parser_options.h +5 -0
- data/src/include/prism/herb_prism_node.h +6 -1
- data/src/include/prism/prism_context.h +12 -12
- data/src/include/prism/prism_helpers.h +30 -0
- data/src/include/prism_version.h +11 -0
- data/src/include/version.h +1 -1
- data/src/lexer.c +32 -0
- data/src/parser/parser_helpers.c +1 -2
- data/src/parser.c +6 -7
- data/src/parser_options_defaults.c +1 -0
- data/src/prism/prism_helpers.c +167 -42
- data/src/prism/ruby_parser.c +20 -20
- data/templates/ext/herb/nodes.c.erb +5 -5
- data/templates/ext/herb/parser_options_helpers.c.erb +33 -0
- data/templates/java/nodes.c.erb +6 -6
- data/templates/java/parser_options_helpers.c.erb +41 -2
- data/templates/java/parser_options_helpers.h.erb +2 -1
- data/templates/javascript/packages/core/src/nodes.ts.erb +21 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +5 -5
- data/templates/javascript/packages/node/extension/parser_options_helpers.cpp.erb +34 -2
- data/templates/javascript/packages/node/extension/parser_options_helpers.h.erb +1 -1
- data/templates/lib/herb/parser_options.rb.erb +1 -1
- data/templates/rust/src/ast/nodes.rs.erb +1 -4
- data/templates/rust/src/prism/generated_deserialize.rs.erb +90 -44
- data/templates/rust/src/prism/generated_prettyprint.rs.erb +18 -27
- data/templates/src/analyze/action_view/generated_handlers.c.erb +23 -22
- data/templates/src/include/parser/parser_options.h.erb +10 -0
- data/templates/src/include/prism_version.h.erb +17 -0
- data/templates/src/parser_options_defaults.c.erb +1 -1
- data/templates/template.rb +17 -2
- data/templates/wasm/nodes.cpp.erb +8 -18
- data/templates/wasm/parser_options_helpers.cpp.erb +24 -0
- data/vendor/prism/Rakefile +76 -7
- data/vendor/prism/config.yml +174 -161
- data/vendor/prism/include/prism/arena.h +45 -0
- data/vendor/prism/include/prism/arena.hpp +42 -0
- data/vendor/prism/include/prism/ast.h +2738 -611
- data/vendor/prism/include/prism/ast.hpp +641 -0
- data/vendor/prism/include/prism/buffer.h +60 -0
- data/vendor/prism/include/prism/buffer.hpp +55 -0
- data/vendor/prism/include/prism/comments.h +72 -0
- data/vendor/prism/include/prism/compiler/accel.h +26 -0
- data/vendor/prism/include/prism/compiler/align.h +36 -0
- data/vendor/prism/include/prism/compiler/assume.h +25 -0
- data/vendor/prism/include/prism/compiler/branch.h +26 -0
- data/vendor/prism/include/prism/compiler/bswap.h +46 -0
- data/vendor/prism/include/prism/compiler/cplusplus.hpp +16 -0
- data/vendor/prism/include/prism/compiler/endianness.h +34 -0
- data/vendor/prism/include/prism/compiler/exceptions.hpp +17 -0
- data/vendor/prism/include/prism/compiler/exported.h +24 -0
- data/vendor/prism/include/prism/compiler/fallthrough.h +22 -0
- data/vendor/prism/include/prism/compiler/filesystem.h +32 -0
- data/vendor/prism/include/prism/compiler/flex_array.h +19 -0
- data/vendor/prism/include/prism/compiler/force_inline.h +21 -0
- data/vendor/prism/include/prism/compiler/format.h +27 -0
- data/vendor/prism/include/prism/compiler/inline.h +17 -0
- data/vendor/prism/include/prism/compiler/lifetimebound.hpp +25 -0
- data/vendor/prism/include/prism/compiler/nodiscard.h +22 -0
- data/vendor/prism/include/prism/compiler/nonnull.h +18 -0
- data/vendor/prism/include/prism/compiler/unused.h +18 -0
- data/vendor/prism/include/prism/constant_pool.h +106 -0
- data/vendor/prism/include/prism/diagnostic.h +55 -402
- data/vendor/prism/include/prism/errors_format.h +61 -0
- data/vendor/prism/include/prism/excludes.h +29 -0
- data/vendor/prism/include/prism/integer.h +41 -0
- data/vendor/prism/include/prism/internal/allocator.h +68 -0
- data/vendor/prism/include/prism/internal/allocator_debug.h +88 -0
- data/vendor/prism/include/prism/internal/arena.h +108 -0
- data/vendor/prism/include/prism/internal/bit.h +42 -0
- data/vendor/prism/include/prism/internal/buffer.h +94 -0
- data/vendor/prism/include/prism/internal/char.h +145 -0
- data/vendor/prism/include/prism/internal/comments.h +54 -0
- data/vendor/prism/include/prism/internal/constant_pool.h +152 -0
- data/vendor/prism/include/prism/internal/diagnostic.h +389 -0
- data/vendor/prism/include/prism/{encoding.h → internal/encoding.h} +27 -68
- data/vendor/prism/include/prism/internal/integer.h +68 -0
- data/vendor/prism/include/prism/internal/isinf.h +16 -0
- data/vendor/prism/include/prism/internal/line_offset_list.h +34 -0
- data/vendor/prism/include/prism/{util/pm_list.h → internal/list.h} +11 -52
- data/vendor/prism/include/prism/internal/magic_comments.h +23 -0
- data/vendor/prism/include/prism/internal/memchr.h +15 -0
- data/vendor/prism/include/prism/internal/node.h +42 -0
- data/vendor/prism/include/prism/internal/options.h +232 -0
- data/vendor/prism/include/prism/internal/parser.h +1015 -0
- data/vendor/prism/include/prism/internal/regexp.h +26 -0
- data/vendor/prism/include/prism/internal/serialize.h +39 -0
- data/vendor/prism/include/prism/internal/source.h +72 -0
- data/vendor/prism/include/prism/internal/static_literals.h +60 -0
- data/vendor/prism/include/prism/internal/stringy.h +30 -0
- data/vendor/prism/include/prism/{util/pm_strncasecmp.h → internal/strncasecmp.h} +3 -17
- data/vendor/prism/include/prism/{util/pm_strpbrk.h → internal/strpbrk.h} +7 -20
- data/vendor/prism/include/prism/internal/tokens.h +11 -0
- data/vendor/prism/include/prism/internal/xxh3.h +16 -0
- data/vendor/prism/include/prism/json.h +40 -0
- data/vendor/prism/include/prism/line_offset_list.h +69 -0
- data/vendor/prism/include/prism/magic_comments.h +53 -0
- data/vendor/prism/include/prism/node.h +59 -49
- data/vendor/prism/include/prism/node.hpp +272 -0
- data/vendor/prism/include/prism/node_type.hpp +38 -0
- data/vendor/prism/include/prism/options.h +154 -279
- data/vendor/prism/include/prism/options.hpp +43 -0
- data/vendor/prism/include/prism/parser.h +367 -870
- data/vendor/prism/include/prism/parser.hpp +274 -0
- data/vendor/prism/include/prism/prettyprint.h +14 -9
- data/vendor/prism/include/prism/serialize.h +123 -0
- data/vendor/prism/include/prism/source.h +163 -0
- data/vendor/prism/include/prism/stream.h +36 -0
- data/vendor/prism/include/prism/string_query.h +82 -0
- data/vendor/prism/include/prism/stringy.h +61 -0
- data/vendor/prism/include/prism/stringy.hpp +31 -0
- data/vendor/prism/include/prism/version.h +20 -3
- data/vendor/prism/include/prism.h +35 -320
- data/vendor/prism/include/prism.hpp +24 -0
- data/vendor/prism/src/arena.c +122 -0
- data/vendor/prism/src/{util/pm_buffer.c → buffer.c} +53 -21
- data/vendor/prism/src/{util/pm_char.c → char.c} +28 -57
- data/vendor/prism/src/comments.c +455 -0
- data/vendor/prism/src/constant_pool.c +406 -0
- data/vendor/prism/src/diagnostic.c +120 -68
- data/vendor/prism/src/encoding.c +8 -3
- data/vendor/prism/src/errors_format.c +519 -0
- data/vendor/prism/src/{util/pm_integer.c → integer.c} +38 -22
- data/vendor/prism/src/json.c +5733 -0
- data/vendor/prism/src/line_offset_list.c +100 -0
- data/vendor/prism/src/list.c +24 -0
- data/vendor/prism/src/{util/pm_memchr.c → memchr.c} +8 -6
- data/vendor/prism/src/node.c +3465 -7787
- data/vendor/prism/src/options.c +161 -54
- data/vendor/prism/src/parser.c +371 -0
- data/vendor/prism/src/prettyprint.c +421 -354
- data/vendor/prism/src/prism.c +8522 -7280
- data/vendor/prism/src/regexp.c +960 -45
- data/vendor/prism/src/serialize.c +2434 -2048
- data/vendor/prism/src/source.c +524 -0
- data/vendor/prism/src/static_literals.c +303 -360
- data/vendor/prism/src/string_query.c +180 -0
- data/vendor/prism/src/stringy.c +61 -0
- data/vendor/prism/src/{util/pm_strncasecmp.c → strncasecmp.c} +5 -4
- data/vendor/prism/src/strpbrk.c +447 -0
- data/vendor/prism/src/{token_type.c → tokens.c} +39 -18
- data/vendor/prism/src/xxh3.c +292 -0
- data/vendor/prism/templates/ext/prism/api_node.c.erb +58 -44
- data/vendor/prism/templates/include/prism/ast.h.erb +67 -17
- data/vendor/prism/templates/include/prism/ast.hpp.erb +31 -0
- data/vendor/prism/templates/include/prism/internal/diagnostic.h.erb +60 -0
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/AbstractNodeVisitor.java.erb +1 -1
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/Loader.java.erb +232 -133
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/Nodes.java.erb +62 -23
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +153 -146
- data/vendor/prism/templates/javascript/src/nodes.js.erb +4 -9
- data/vendor/prism/templates/lib/prism/compiler.rb.erb +14 -5
- data/vendor/prism/templates/lib/prism/dispatcher.rb.erb +20 -12
- data/vendor/prism/templates/lib/prism/dot_visitor.rb.erb +37 -11
- data/vendor/prism/templates/lib/prism/dsl.rb.erb +43 -4
- data/vendor/prism/templates/lib/prism/inspect_visitor.rb.erb +26 -10
- data/vendor/prism/templates/lib/prism/mutation_compiler.rb.erb +5 -2
- data/vendor/prism/templates/lib/prism/node.rb.erb +283 -105
- data/vendor/prism/templates/lib/prism/reflection.rb.erb +11 -2
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +291 -134
- data/vendor/prism/templates/lib/prism/visitor.rb.erb +18 -0
- data/vendor/prism/templates/src/diagnostic.c.erb +114 -63
- data/vendor/prism/templates/src/json.c.erb +130 -0
- data/vendor/prism/templates/src/node.c.erb +79 -236
- data/vendor/prism/templates/src/prettyprint.c.erb +24 -13
- data/vendor/prism/templates/src/serialize.c.erb +369 -183
- data/vendor/prism/templates/src/{token_type.c.erb → tokens.c.erb} +22 -11
- data/vendor/prism/templates/template.rb +193 -91
- metadata +100 -42
- data/vendor/prism/include/prism/defines.h +0 -260
- data/vendor/prism/include/prism/pack.h +0 -163
- data/vendor/prism/include/prism/regexp.h +0 -43
- data/vendor/prism/include/prism/static_literals.h +0 -121
- data/vendor/prism/include/prism/util/pm_buffer.h +0 -236
- data/vendor/prism/include/prism/util/pm_char.h +0 -204
- data/vendor/prism/include/prism/util/pm_constant_pool.h +0 -218
- data/vendor/prism/include/prism/util/pm_integer.h +0 -130
- data/vendor/prism/include/prism/util/pm_memchr.h +0 -29
- data/vendor/prism/include/prism/util/pm_newline_list.h +0 -113
- data/vendor/prism/include/prism/util/pm_string.h +0 -200
- data/vendor/prism/src/pack.c +0 -509
- data/vendor/prism/src/util/pm_constant_pool.c +0 -342
- data/vendor/prism/src/util/pm_list.c +0 -49
- data/vendor/prism/src/util/pm_newline_list.c +0 -125
- data/vendor/prism/src/util/pm_string.c +0 -381
- data/vendor/prism/src/util/pm_strpbrk.c +0 -206
- data/vendor/prism/templates/include/prism/diagnostic.h.erb +0 -130
- data/vendor/prism/templates/rbi/prism/dsl.rbi.erb +0 -68
- data/vendor/prism/templates/rbi/prism/node.rbi.erb +0 -167
- data/vendor/prism/templates/rbi/prism/visitor.rbi.erb +0 -18
- data/vendor/prism/templates/sig/prism/_private/dot_visitor.rbs.erb +0 -45
- data/vendor/prism/templates/sig/prism/dsl.rbs.erb +0 -31
- data/vendor/prism/templates/sig/prism/mutation_compiler.rbs.erb +0 -7
- data/vendor/prism/templates/sig/prism/node.rbs.erb +0 -136
- data/vendor/prism/templates/sig/prism/visitor.rbs.erb +0 -17
- data/vendor/prism/templates/sig/prism.rbs.erb +0 -92
|
@@ -65,7 +65,8 @@ module Herb
|
|
|
65
65
|
# An item is keyed by the key its template declares, through `herb-key` or `id` or a
|
|
66
66
|
# `<%# herb:key %>` directive, which is what makes it survive being reordered. `Visitor`
|
|
67
67
|
# decides what that key is and this evaluates it, so an item arrives under the same key the
|
|
68
|
-
# marker around it carries. A collection that declares none falls back to position
|
|
68
|
+
# marker around it carries. A collection that declares none falls back to position, counting
|
|
69
|
+
# from the first iteration, so a change re-renders every row from the first one that differs.
|
|
69
70
|
#
|
|
70
71
|
# ## A partial keeps its own values
|
|
71
72
|
#
|
|
@@ -88,7 +89,7 @@ module Herb
|
|
|
88
89
|
#
|
|
89
90
|
# ## Blocks
|
|
90
91
|
#
|
|
91
|
-
# A tag that takes a block, such as `<%= form_with do |f| %>`, owns an entry holding
|
|
92
|
+
# A tag that takes a block, such as `<%= form_with do |f| %>`, owns an entry holding the markup
|
|
92
93
|
# the block rendered, because the helper wraps that output in markup of its own that only the
|
|
93
94
|
# helper can produce. What the template wrote inside the block keeps its own indices alongside:
|
|
94
95
|
#
|
|
@@ -99,6 +100,20 @@ module Herb
|
|
|
99
100
|
# and the whole block. Slot 1 is inside slot 0, which the client already has to reason about
|
|
100
101
|
# for conditionals and collections.
|
|
101
102
|
#
|
|
103
|
+
# A partial inside a block is the exception to that fallback. It keeps its own values on its slot,
|
|
104
|
+
# and the block's entry is a String that cannot hold them, so the entry leaves the partial's
|
|
105
|
+
# markup out:
|
|
106
|
+
#
|
|
107
|
+
# <%= form_with(model: @user) do |f| %><%= render "card" %><% end %>
|
|
108
|
+
# #=> { 0 => "<form></form>", 1 => { template: "app/views/_card.html.erb", ... } }
|
|
109
|
+
#
|
|
110
|
+
# That entry cannot stand in for the block, so it must not be written over a block holding a
|
|
111
|
+
# partial. The client never writes a block's entry while the page marks slots inside that block.
|
|
112
|
+
# It reports the block as deferred instead, even when nothing in the block changed.
|
|
113
|
+
#
|
|
114
|
+
# A render that comes back as markup, because its template is not compiled for slots, is written
|
|
115
|
+
# into the entry as usual, and the entry stays whole.
|
|
116
|
+
#
|
|
102
117
|
# A block yielding more than once is the exception, since one index cannot stand for the several
|
|
103
118
|
# values its interior took. `each` and the other iterations are compiled as collections for that
|
|
104
119
|
# reason, and a helper that yields repeatedly reports the last value its interior took.
|
|
@@ -117,6 +132,8 @@ module Herb
|
|
|
117
132
|
|
|
118
133
|
OCCURRENCE_BUFFER: String
|
|
119
134
|
|
|
135
|
+
RENDERED_BUFFER: String
|
|
136
|
+
|
|
120
137
|
BRANCHING_NODES: Array[String]
|
|
121
138
|
|
|
122
139
|
class Compiler < Herb::Engine::Compiler
|
|
@@ -132,6 +149,9 @@ module Herb
|
|
|
132
149
|
# : (untyped) -> void
|
|
133
150
|
def visit_erb_content_node: (untyped) -> void
|
|
134
151
|
|
|
152
|
+
# : (untyped) -> void
|
|
153
|
+
def visit_ruby_literal_node: (untyped) -> void
|
|
154
|
+
|
|
135
155
|
# : (untyped) -> void
|
|
136
156
|
def visit_erb_yield_node: (untyped) -> void
|
|
137
157
|
|
|
@@ -246,8 +266,8 @@ module Herb
|
|
|
246
266
|
# : (Integer) -> bool
|
|
247
267
|
def boolean_presence?: (Integer) -> bool
|
|
248
268
|
|
|
249
|
-
# : (String, Integer?, bool) -> void
|
|
250
|
-
def add_dynamic_block: (String, Integer?, bool) -> void
|
|
269
|
+
# : (String, Integer?, bool, ?rendering: bool) -> void
|
|
270
|
+
def add_dynamic_block: (String, Integer?, bool, ?rendering: bool) -> void
|
|
251
271
|
|
|
252
272
|
# : (String, ?escaped: bool) -> void
|
|
253
273
|
def add_expression_block_end: (String, ?escaped: bool) -> void
|
|
@@ -302,9 +322,6 @@ module Herb
|
|
|
302
322
|
# : (Integer) -> void
|
|
303
323
|
def scope_item_end: (Integer) -> void
|
|
304
324
|
|
|
305
|
-
# : (Integer) -> bool
|
|
306
|
-
def keyed?: (Integer) -> bool
|
|
307
|
-
|
|
308
325
|
# : (Integer) -> String
|
|
309
326
|
def item_seeds: (Integer) -> String
|
|
310
327
|
|
|
@@ -329,6 +346,9 @@ module Herb
|
|
|
329
346
|
# : (Integer) -> bool
|
|
330
347
|
def interpolated?: (Integer) -> bool
|
|
331
348
|
|
|
349
|
+
# : (String) -> void
|
|
350
|
+
def add_block_render: (String) -> void
|
|
351
|
+
|
|
332
352
|
# : (String) -> void
|
|
333
353
|
def add_block_dynamic: (String) -> void
|
|
334
354
|
|
|
@@ -14,15 +14,29 @@ module Herb
|
|
|
14
14
|
|
|
15
15
|
COMMENT: Regexp
|
|
16
16
|
|
|
17
|
+
FOREIGN_ATTRIBUTE: String
|
|
18
|
+
|
|
19
|
+
FOREIGN_ROOTS: Hash[Symbol, String]
|
|
20
|
+
|
|
21
|
+
SVG_INTEGRATION_POINTS: Array[String]
|
|
22
|
+
|
|
23
|
+
MATH_INTEGRATION_POINTS: Array[String]
|
|
24
|
+
|
|
17
25
|
# : (String) -> bool
|
|
18
26
|
def self.marker?: (String) -> bool
|
|
19
27
|
|
|
20
28
|
# : (String) -> String
|
|
21
29
|
def self.seeds_expression: (String) -> String
|
|
22
30
|
|
|
31
|
+
# : (Symbol, String) -> Symbol
|
|
32
|
+
def self.namespace_within: (Symbol, String) -> Symbol
|
|
33
|
+
|
|
23
34
|
# : (Integer, Symbol) -> String
|
|
24
35
|
def slot_open: (Integer, Symbol) -> String
|
|
25
36
|
|
|
37
|
+
# : (String, Symbol) -> String
|
|
38
|
+
def foreign: (String, Symbol) -> String
|
|
39
|
+
|
|
26
40
|
# : (Array[[Integer, Symbol, String?]]) -> String
|
|
27
41
|
def element_anchors: (Array[[ Integer, Symbol, String? ]]) -> String
|
|
28
42
|
|
|
@@ -57,6 +57,8 @@ module Herb
|
|
|
57
57
|
|
|
58
58
|
OCCURRENCE: String
|
|
59
59
|
|
|
60
|
+
POSITION: String
|
|
61
|
+
|
|
60
62
|
NAME_ATTRIBUTE: String
|
|
61
63
|
|
|
62
64
|
KEY_ATTRIBUTE: String
|
|
@@ -121,6 +123,15 @@ module Herb
|
|
|
121
123
|
|
|
122
124
|
# : () -> bool
|
|
123
125
|
def interpolated?: () -> bool
|
|
126
|
+
|
|
127
|
+
# : () -> bool
|
|
128
|
+
def positional?: () -> bool
|
|
129
|
+
|
|
130
|
+
# : () -> String
|
|
131
|
+
def position_variable: () -> String
|
|
132
|
+
|
|
133
|
+
# : () -> String?
|
|
134
|
+
def item_key: () -> String?
|
|
124
135
|
end
|
|
125
136
|
|
|
126
137
|
# : (String) -> bool
|
|
@@ -404,6 +415,9 @@ module Herb
|
|
|
404
415
|
|
|
405
416
|
def erb_output_node: (untyped code) -> untyped
|
|
406
417
|
|
|
418
|
+
# : (Array[untyped], Integer) -> String
|
|
419
|
+
def attribute_spacing: (Array[untyped], Integer) -> String
|
|
420
|
+
|
|
407
421
|
private
|
|
408
422
|
|
|
409
423
|
def visit_children_with_paths: (untyped children) -> untyped
|
|
@@ -526,16 +540,17 @@ module Herb
|
|
|
526
540
|
# : (untyped) -> String?
|
|
527
541
|
def attribute_expression_for: (untyped) -> String?
|
|
528
542
|
|
|
529
|
-
|
|
543
|
+
# : (untyped, ?Symbol) -> untyped
|
|
544
|
+
def insert_markers: (untyped, ?Symbol) -> untyped
|
|
530
545
|
|
|
531
546
|
# : (untyped) -> Integer?
|
|
532
547
|
def content_anchor_index: (untyped) -> Integer?
|
|
533
548
|
|
|
534
|
-
# : (untyped, Integer?) -> void
|
|
535
|
-
def mark_branches: (untyped, Integer?) -> void
|
|
549
|
+
# : (untyped, Integer?, ?Symbol) -> void
|
|
550
|
+
def mark_branches: (untyped, Integer?, ?Symbol) -> void
|
|
536
551
|
|
|
537
|
-
# : (String, Array[untyped]) -> void
|
|
538
|
-
def park_branch: (String, Array[untyped]) -> void
|
|
552
|
+
# : (String, String, Array[untyped], Symbol) -> void
|
|
553
|
+
def park_branch: (String, String, Array[untyped], Symbol) -> void
|
|
539
554
|
|
|
540
555
|
# : (Herb::AST::DocumentNode) -> void
|
|
541
556
|
def append_statics: (Herb::AST::DocumentNode) -> void
|
|
@@ -558,25 +573,28 @@ module Herb
|
|
|
558
573
|
# : (untyped) -> Array[Array[Herb::AST::Node]]
|
|
559
574
|
def branch_bodies: (untyped) -> Array[Array[Herb::AST::Node]]
|
|
560
575
|
|
|
561
|
-
# : (
|
|
562
|
-
def
|
|
576
|
+
# : (Array[untyped], Integer, Integer?) -> Integer
|
|
577
|
+
def insert_position_counter: (Array[untyped], Integer, Integer?) -> Integer
|
|
578
|
+
|
|
579
|
+
# : (Herb::AST::Node, Integer?, ?Symbol) -> void
|
|
580
|
+
def wrap_items: (Herb::AST::Node, Integer?, ?Symbol) -> void
|
|
563
581
|
|
|
564
582
|
# : (untyped) -> Array[String]?
|
|
565
583
|
def attribute_segments: (untyped) -> Array[String]?
|
|
566
584
|
|
|
567
|
-
# : (Integer, untyped) -> void
|
|
568
|
-
def park_keyed: (Integer, untyped) -> void
|
|
585
|
+
# : (Integer, untyped, Symbol) -> void
|
|
586
|
+
def park_keyed: (Integer, untyped, Symbol) -> void
|
|
569
587
|
|
|
570
|
-
# : (untyped, untyped) -> Array[untyped]?
|
|
571
|
-
def park_item: (untyped, untyped) -> Array[untyped]?
|
|
588
|
+
# : (untyped, untyped, Symbol) -> Array[untyped]?
|
|
589
|
+
def park_item: (untyped, untyped, Symbol) -> Array[untyped]?
|
|
572
590
|
|
|
573
591
|
def anchor_attributes: (untyped node, ?untyped content_index) -> untyped
|
|
574
592
|
|
|
575
593
|
# : (Slot) -> String?
|
|
576
594
|
def anchor_name_for: (Slot) -> String?
|
|
577
595
|
|
|
578
|
-
# : (Herb::AST::Node) { (Array[untyped]) -> void } -> void
|
|
579
|
-
def each_child_array: (Herb::AST::Node) { (Array[untyped]) -> void } -> void
|
|
596
|
+
# : (Herb::AST::Node, ?Symbol) { (Array[untyped]) -> void } -> void
|
|
597
|
+
def each_child_array: (Herb::AST::Node, ?Symbol) { (Array[untyped]) -> void } -> void
|
|
580
598
|
|
|
581
599
|
# : (Herb::AST::DocumentNode) -> void
|
|
582
600
|
def wrap_region: (Herb::AST::DocumentNode) -> void
|
|
@@ -72,6 +72,8 @@ module Herb
|
|
|
72
72
|
# : (Herb::AST::Node, Herb::AST::Node) -> Herb::AST::Node
|
|
73
73
|
def replacing: (Herb::AST::Node, Herb::AST::Node) -> Herb::AST::Node
|
|
74
74
|
|
|
75
|
+
def literal?: (untyped node) -> untyped
|
|
76
|
+
|
|
75
77
|
def framed?: (untyped node) -> untyped
|
|
76
78
|
|
|
77
79
|
def assignment?: (untyped node) -> untyped
|
|
@@ -105,7 +107,9 @@ module Herb
|
|
|
105
107
|
|
|
106
108
|
def code: (untyped node) -> untyped
|
|
107
109
|
|
|
108
|
-
def
|
|
110
|
+
def rewrapped: (untyped node, untyped code) -> untyped
|
|
111
|
+
|
|
112
|
+
def erb_node: (untyped node, untyped opening, untyped code, ?closing: untyped) -> untyped
|
|
109
113
|
end
|
|
110
114
|
end
|
|
111
115
|
end
|
data/sig/herb/parser_options.rbs
CHANGED
|
@@ -28,6 +28,8 @@ module Herb
|
|
|
28
28
|
|
|
29
29
|
attr_reader render_nodes: bool
|
|
30
30
|
|
|
31
|
+
attr_reader ruby_version: String?
|
|
32
|
+
|
|
31
33
|
attr_reader strict: bool
|
|
32
34
|
|
|
33
35
|
attr_reader strict_locals: bool
|
|
@@ -76,11 +78,11 @@ module Herb
|
|
|
76
78
|
|
|
77
79
|
DEFAULT_TRANSFORM_CONDITIONALS: bool
|
|
78
80
|
|
|
79
|
-
# : (?action_view_helpers: bool, ?analyze: bool, ?arena_stats: bool, ?dot_notation_tags: bool, ?erb_openers: Array[String], ?herb_directives: bool, ?html: bool, ?iteration_nodes: bool, ?max_errors: Integer?, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?render_nodes: bool, ?strict: bool, ?strict_locals: bool, ?timeout: Numeric, ?track_locations: bool, ?track_whitespace: bool, ?transform_conditionals: bool) -> void
|
|
80
|
-
def initialize: (?action_view_helpers: bool, ?analyze: bool, ?arena_stats: bool, ?dot_notation_tags: bool, ?erb_openers: Array[String], ?herb_directives: bool, ?html: bool, ?iteration_nodes: bool, ?max_errors: Integer?, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?render_nodes: bool, ?strict: bool, ?strict_locals: bool, ?timeout: Numeric, ?track_locations: bool, ?track_whitespace: bool, ?transform_conditionals: bool) -> void
|
|
81
|
+
# : (?action_view_helpers: bool, ?analyze: bool, ?arena_stats: bool, ?dot_notation_tags: bool, ?erb_openers: Array[String], ?herb_directives: bool, ?html: bool, ?iteration_nodes: bool, ?max_errors: Integer?, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?render_nodes: bool, ?ruby_version: String?, ?strict: bool, ?strict_locals: bool, ?timeout: Numeric, ?track_locations: bool, ?track_whitespace: bool, ?transform_conditionals: bool) -> void
|
|
82
|
+
def initialize: (?action_view_helpers: bool, ?analyze: bool, ?arena_stats: bool, ?dot_notation_tags: bool, ?erb_openers: Array[String], ?herb_directives: bool, ?html: bool, ?iteration_nodes: bool, ?max_errors: Integer?, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?render_nodes: bool, ?ruby_version: String?, ?strict: bool, ?strict_locals: bool, ?timeout: Numeric, ?track_locations: bool, ?track_whitespace: bool, ?transform_conditionals: bool) -> void
|
|
81
83
|
|
|
82
|
-
# : () -> Hash[Symbol, (bool | Numeric | Array[String] | nil)]
|
|
83
|
-
def to_h: () -> Hash[Symbol, bool | Numeric | Array[String] | nil]
|
|
84
|
+
# : () -> Hash[Symbol, (bool | Numeric | String | Array[String] | nil)]
|
|
85
|
+
def to_h: () -> Hash[Symbol, bool | Numeric | String | Array[String] | nil]
|
|
84
86
|
|
|
85
87
|
# : () -> String
|
|
86
88
|
def inspect: () -> String
|
data/sig/herb.rbs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Generated from lib/herb.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
module Herb
|
|
4
|
-
# : (String input, ?track_whitespace: bool, ?track_locations: bool, ?analyze: bool, ?strict: bool, ?action_view_helpers: bool, ?transform_conditionals: bool, ?dot_notation_tags: bool, ?render_nodes: bool, ?strict_locals: bool, ?herb_directives: bool, ?iteration_nodes: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?html: bool, ?erb_openers: Array[String], ?arena_stats: bool) -> ParseResult
|
|
5
|
-
def self.parse: (String input, ?track_whitespace: bool, ?track_locations: bool, ?analyze: bool, ?strict: bool, ?action_view_helpers: bool, ?transform_conditionals: bool, ?dot_notation_tags: bool, ?render_nodes: bool, ?strict_locals: bool, ?herb_directives: bool, ?iteration_nodes: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?html: bool, ?erb_openers: Array[String], ?arena_stats: bool) -> ParseResult
|
|
4
|
+
# : (String input, ?track_whitespace: bool, ?track_locations: bool, ?analyze: bool, ?strict: bool, ?action_view_helpers: bool, ?transform_conditionals: bool, ?dot_notation_tags: bool, ?render_nodes: bool, ?strict_locals: bool, ?herb_directives: bool, ?iteration_nodes: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?html: bool, ?erb_openers: Array[String], ?ruby_version: String?, ?arena_stats: bool) -> ParseResult
|
|
5
|
+
def self.parse: (String input, ?track_whitespace: bool, ?track_locations: bool, ?analyze: bool, ?strict: bool, ?action_view_helpers: bool, ?transform_conditionals: bool, ?dot_notation_tags: bool, ?render_nodes: bool, ?strict_locals: bool, ?herb_directives: bool, ?iteration_nodes: bool, ?prism_nodes: bool, ?prism_nodes_deep: bool, ?prism_program: bool, ?html: bool, ?erb_openers: Array[String], ?ruby_version: String?, ?arena_stats: bool) -> ParseResult
|
|
6
6
|
|
|
7
7
|
# : (String input, ?erb_openers: Array[String], ?arena_stats: bool) -> LexResult
|
|
8
8
|
def self.lex: (String input, ?erb_openers: Array[String], ?arena_stats: bool) -> LexResult
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
#include "../../include/lib/hb_array.h"
|
|
5
5
|
#include "../../include/lib/hb_buffer.h"
|
|
6
6
|
#include "../../include/lib/hb_string.h"
|
|
7
|
+
#include "../../include/prism/prism_helpers.h"
|
|
7
8
|
#include "../../include/util/html_util.h"
|
|
8
9
|
#include "../../include/util/util.h"
|
|
9
10
|
|
|
10
11
|
#include <prism.h>
|
|
12
|
+
#include <stdio.h>
|
|
11
13
|
#include <stdlib.h>
|
|
12
14
|
#include <string.h>
|
|
13
15
|
|
|
@@ -39,14 +41,14 @@ static void compute_position_pair(
|
|
|
39
41
|
position_T* out_end
|
|
40
42
|
) {
|
|
41
43
|
*out_start = prism_location_to_position_with_offset(location, original_source, erb_content_offset, source);
|
|
42
|
-
pm_location_t end_location = { .start = location
|
|
44
|
+
pm_location_t end_location = { .start = herb_prism_location_end(*location), .length = 0 };
|
|
43
45
|
*out_end = prism_location_to_position_with_offset(&end_location, original_source, erb_content_offset, source);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
static void extract_key_name_location(pm_node_t* key, pm_location_t* out_name_loc) {
|
|
47
49
|
if (key->type == PM_SYMBOL_NODE) {
|
|
48
50
|
pm_symbol_node_t* symbol = (pm_symbol_node_t*) key;
|
|
49
|
-
*out_name_loc = symbol->
|
|
51
|
+
*out_name_loc = symbol->content_loc;
|
|
50
52
|
} else if (key->type == PM_STRING_NODE) {
|
|
51
53
|
pm_string_node_t* string_node = (pm_string_node_t*) key;
|
|
52
54
|
*out_name_loc = string_node->content_loc;
|
|
@@ -69,7 +71,7 @@ static void compute_separator_info(
|
|
|
69
71
|
*out_separator_end =
|
|
70
72
|
prism_location_to_position_with_offset(&assoc->value->location, original_source, erb_content_offset, source);
|
|
71
73
|
|
|
72
|
-
if (assoc->operator_loc
|
|
74
|
+
if (herb_prism_location_assigned(assoc->operator_loc)) {
|
|
73
75
|
*out_separator_string = " => ";
|
|
74
76
|
*out_separator_type = TOKEN_EQUALS;
|
|
75
77
|
*out_separator_start = key_end;
|
|
@@ -78,8 +80,8 @@ static void compute_separator_info(
|
|
|
78
80
|
*out_separator_type = TOKEN_COLON;
|
|
79
81
|
|
|
80
82
|
pm_location_t colon_loc = {
|
|
81
|
-
.start = assoc->key->location
|
|
82
|
-
.
|
|
83
|
+
.start = herb_prism_location_end(assoc->key->location) - 1,
|
|
84
|
+
.length = 0,
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
*out_separator_start =
|
|
@@ -102,7 +104,7 @@ static void extract_delimited_locations(
|
|
|
102
104
|
pm_symbol_node_t* symbol_node = (pm_symbol_node_t*) node;
|
|
103
105
|
*out_opening = &symbol_node->opening_loc;
|
|
104
106
|
*out_closing = &symbol_node->closing_loc;
|
|
105
|
-
*out_content = &symbol_node->
|
|
107
|
+
*out_content = &symbol_node->content_loc;
|
|
106
108
|
} else {
|
|
107
109
|
*out_opening = NULL;
|
|
108
110
|
*out_closing = NULL;
|
|
@@ -127,7 +129,8 @@ static void compute_value_positions(
|
|
|
127
129
|
|
|
128
130
|
extract_delimited_locations(value_node, &opening_loc, &closing_loc, &content_loc);
|
|
129
131
|
|
|
130
|
-
if (opening_loc && opening_loc
|
|
132
|
+
if (opening_loc && herb_prism_location_assigned(*opening_loc) && closing_loc
|
|
133
|
+
&& herb_prism_location_assigned(*closing_loc)) {
|
|
131
134
|
compute_position_pair(
|
|
132
135
|
&*opening_loc,
|
|
133
136
|
source,
|
|
@@ -167,7 +170,7 @@ static void fill_attribute_positions(
|
|
|
167
170
|
);
|
|
168
171
|
|
|
169
172
|
position_T key_end;
|
|
170
|
-
pm_location_t key_end_loc = { .start = assoc->key->location
|
|
173
|
+
pm_location_t key_end_loc = { .start = herb_prism_location_end(assoc->key->location), .length = 0 };
|
|
171
174
|
key_end = prism_location_to_position_with_offset(&key_end_loc, original_source, erb_content_offset, source);
|
|
172
175
|
|
|
173
176
|
compute_separator_info(
|
|
@@ -246,6 +249,7 @@ static char* join_static_string_array(pm_array_node_t* array, hb_allocator_T* al
|
|
|
246
249
|
static AST_NODE_T* create_attribute_from_value(
|
|
247
250
|
const char* name_string,
|
|
248
251
|
pm_node_t* value_node,
|
|
252
|
+
const uint8_t* source,
|
|
249
253
|
attribute_positions_T* positions,
|
|
250
254
|
hb_allocator_T* allocator,
|
|
251
255
|
bool is_nested
|
|
@@ -281,8 +285,8 @@ static AST_NODE_T* create_attribute_from_value(
|
|
|
281
285
|
|
|
282
286
|
return (AST_NODE_T*) create_html_attribute_node_precise(name_string, "false", positions, allocator);
|
|
283
287
|
} else if (value_node->type == PM_INTEGER_NODE) {
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
char* value_string =
|
|
289
|
+
hb_allocator_strndup(allocator, (const char*) (source + value_node->location.start), value_node->location.length);
|
|
286
290
|
if (!value_string) { return NULL; }
|
|
287
291
|
|
|
288
292
|
AST_HTML_ATTRIBUTE_NODE_T* attribute =
|
|
@@ -294,15 +298,17 @@ static AST_NODE_T* create_attribute_from_value(
|
|
|
294
298
|
return (AST_NODE_T*) create_html_attribute_with_interpolated_value(
|
|
295
299
|
name_string,
|
|
296
300
|
(pm_interpolated_string_node_t*) value_node,
|
|
301
|
+
source,
|
|
297
302
|
positions->name_start,
|
|
298
303
|
positions->value_end,
|
|
299
304
|
allocator
|
|
300
305
|
);
|
|
301
306
|
} else {
|
|
302
|
-
size_t value_length = value_node->location.
|
|
303
|
-
char* raw_content =
|
|
307
|
+
size_t value_length = value_node->location.length;
|
|
308
|
+
char* raw_content =
|
|
309
|
+
hb_allocator_strndup(allocator, (const char*) (source + value_node->location.start), value_length);
|
|
304
310
|
|
|
305
|
-
if (raw_content && value_node->location
|
|
311
|
+
if (raw_content && herb_prism_location_assigned(value_node->location)) {
|
|
306
312
|
char* ruby_content = raw_content;
|
|
307
313
|
hb_buffer_T wrapper;
|
|
308
314
|
bool wrapped = false;
|
|
@@ -488,8 +494,14 @@ AST_NODE_T* extract_html_attribute_from_assoc(
|
|
|
488
494
|
fill_attribute_positions(assoc, source, original_source, erb_content_offset, &positions);
|
|
489
495
|
|
|
490
496
|
char* dashed_name = convert_underscores_to_dashes(name_string);
|
|
491
|
-
AST_NODE_T* attribute_node =
|
|
492
|
-
|
|
497
|
+
AST_NODE_T* attribute_node = create_attribute_from_value(
|
|
498
|
+
dashed_name ? dashed_name : name_string,
|
|
499
|
+
assoc->value,
|
|
500
|
+
source,
|
|
501
|
+
&positions,
|
|
502
|
+
allocator,
|
|
503
|
+
false
|
|
504
|
+
);
|
|
493
505
|
|
|
494
506
|
if (dashed_name) { free(dashed_name); }
|
|
495
507
|
hb_allocator_dealloc(allocator, name_string);
|
|
@@ -516,8 +528,9 @@ hb_array_T* extract_html_attributes_from_keyword_hash(
|
|
|
516
528
|
pm_assoc_splat_node_t* splat = (pm_assoc_splat_node_t*) element;
|
|
517
529
|
|
|
518
530
|
if (splat->value) {
|
|
519
|
-
size_t value_length = splat->value->location.
|
|
520
|
-
char* value_source =
|
|
531
|
+
size_t value_length = splat->value->location.length;
|
|
532
|
+
char* value_source =
|
|
533
|
+
hb_allocator_strndup(allocator, (const char*) (source + splat->value->location.start), value_length);
|
|
521
534
|
|
|
522
535
|
if (value_source) {
|
|
523
536
|
hb_buffer_T wrapped;
|
|
@@ -560,9 +573,9 @@ hb_array_T* extract_html_attributes_from_keyword_hash(
|
|
|
560
573
|
pm_assoc_splat_node_t* splat = (pm_assoc_splat_node_t*) hash_element;
|
|
561
574
|
|
|
562
575
|
if (splat->value) {
|
|
563
|
-
size_t value_length = splat->value->location.
|
|
576
|
+
size_t value_length = splat->value->location.length;
|
|
564
577
|
char* value_source =
|
|
565
|
-
hb_allocator_strndup(allocator, (const char*) splat->value->location.start, value_length);
|
|
578
|
+
hb_allocator_strndup(allocator, (const char*) (source + splat->value->location.start), value_length);
|
|
566
579
|
|
|
567
580
|
if (value_source) {
|
|
568
581
|
hb_buffer_T wrapped;
|
|
@@ -612,8 +625,14 @@ hb_array_T* extract_html_attributes_from_keyword_hash(
|
|
|
612
625
|
attribute_positions_T hash_positions;
|
|
613
626
|
fill_attribute_positions(hash_assoc, source, original_source, erb_content_offset, &hash_positions);
|
|
614
627
|
|
|
615
|
-
AST_NODE_T* attribute =
|
|
616
|
-
|
|
628
|
+
AST_NODE_T* attribute = create_attribute_from_value(
|
|
629
|
+
attribute_key_string,
|
|
630
|
+
hash_assoc->value,
|
|
631
|
+
source,
|
|
632
|
+
&hash_positions,
|
|
633
|
+
allocator,
|
|
634
|
+
true
|
|
635
|
+
);
|
|
617
636
|
|
|
618
637
|
if (attribute) { hb_array_append(attributes, attribute); }
|
|
619
638
|
hb_allocator_dealloc(allocator, attribute_key_string);
|
|
@@ -16,41 +16,41 @@
|
|
|
16
16
|
bool detect_image_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
17
17
|
if (!call_node || !call_node->name) { return false; }
|
|
18
18
|
|
|
19
|
-
pm_constant_t* constant =
|
|
19
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
20
20
|
|
|
21
|
-
return constant && constant
|
|
21
|
+
return constant && pm_constant_length(constant) == 9 && strncmp((const char*) pm_constant_start(constant), "image_tag", 9) == 0;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
bool detect_javascript_include_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
25
25
|
if (!call_node || !call_node->name) { return false; }
|
|
26
26
|
|
|
27
|
-
pm_constant_t* constant =
|
|
27
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
28
28
|
|
|
29
|
-
return constant && constant
|
|
29
|
+
return constant && pm_constant_length(constant) == 22 && strncmp((const char*) pm_constant_start(constant), "javascript_include_tag", 22) == 0;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
bool detect_stylesheet_link_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
33
33
|
if (!call_node || !call_node->name) { return false; }
|
|
34
34
|
|
|
35
|
-
pm_constant_t* constant =
|
|
35
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
36
36
|
|
|
37
|
-
return constant && constant
|
|
37
|
+
return constant && pm_constant_length(constant) == 19 && strncmp((const char*) pm_constant_start(constant), "stylesheet_link_tag", 19) == 0;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
bool detect_javascript_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
41
41
|
if (!call_node || !call_node->name) { return false; }
|
|
42
42
|
|
|
43
|
-
pm_constant_t* constant =
|
|
43
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
44
44
|
|
|
45
|
-
return constant && constant
|
|
45
|
+
return constant && pm_constant_length(constant) == 14 && strncmp((const char*) pm_constant_start(constant), "javascript_tag", 14) == 0;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
bool detect_content_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
49
49
|
if (!call_node || !call_node->name) { return false; }
|
|
50
50
|
|
|
51
|
-
pm_constant_t* constant =
|
|
51
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
52
52
|
|
|
53
|
-
return constant && constant
|
|
53
|
+
return constant && pm_constant_length(constant) == 11 && strncmp((const char*) pm_constant_start(constant), "content_tag", 11) == 0;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
bool detect_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
@@ -60,17 +60,17 @@ bool detect_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
|
60
60
|
pm_call_node_t* receiver_node = (pm_call_node_t*) call_node->receiver;
|
|
61
61
|
if (!receiver_node->name) { return false; }
|
|
62
62
|
|
|
63
|
-
pm_constant_t* constant =
|
|
63
|
+
const pm_constant_t* constant = pm_parser_constant(parser, receiver_node->name);
|
|
64
64
|
|
|
65
|
-
return constant && constant
|
|
65
|
+
return constant && pm_constant_length(constant) == 3 && strncmp((const char*) pm_constant_start(constant), "tag", 3) == 0;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
bool detect_turbo_frame_tag(pm_call_node_t* call_node, pm_parser_t* parser) {
|
|
69
69
|
if (!call_node || !call_node->name) { return false; }
|
|
70
70
|
|
|
71
|
-
pm_constant_t* constant =
|
|
71
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
72
72
|
|
|
73
|
-
return constant && constant
|
|
73
|
+
return constant && pm_constant_length(constant) == 15 && strncmp((const char*) pm_constant_start(constant), "turbo_frame_tag", 15) == 0;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// ==========================================================================
|
|
@@ -133,14 +133,17 @@ extern bool is_ruby_introspection_method(hb_string_T method_name);
|
|
|
133
133
|
static char* extract_tag_tag_name(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) {
|
|
134
134
|
if (!call_node || !call_node->name) { return NULL; }
|
|
135
135
|
|
|
136
|
-
pm_constant_t* constant =
|
|
136
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
137
137
|
if (!constant) { return NULL; }
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
const char* constant_start = (const char*) pm_constant_start(constant);
|
|
140
|
+
size_t constant_length = pm_constant_length(constant);
|
|
140
141
|
|
|
141
|
-
|
|
142
|
+
if (is_ruby_introspection_method(hb_string_from_data(constant_start, constant_length))) { return NULL; }
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
char* name = hb_allocator_strndup(allocator, constant_start, constant_length);
|
|
145
|
+
|
|
146
|
+
for (size_t i = 0; i < constant_length && name[i] != '\0'; i++) {
|
|
144
147
|
if (name[i] == '_') { name[i] = '-'; }
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -182,9 +185,7 @@ static char* extract_stylesheet_link_tag_content(pm_call_node_t* _call_node, pm_
|
|
|
182
185
|
return NULL;
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
static char* extract_javascript_tag_content(pm_call_node_t* call_node, pm_parser_t*
|
|
186
|
-
(void) _parser;
|
|
187
|
-
|
|
188
|
+
static char* extract_javascript_tag_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) {
|
|
188
189
|
if (!call_node || !call_node->arguments) { return NULL; }
|
|
189
190
|
|
|
190
191
|
pm_arguments_node_t* arguments = call_node->arguments;
|
|
@@ -200,17 +201,16 @@ static char* extract_javascript_tag_content(pm_call_node_t* call_node, pm_parser
|
|
|
200
201
|
return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
const uint8_t* source = pm_parser_start(parser);
|
|
205
|
+
size_t source_length = first_argument->location.length;
|
|
206
|
+
return hb_allocator_strndup(allocator, (const char*) (source + first_argument->location.start), source_length);
|
|
205
207
|
}
|
|
206
208
|
|
|
207
|
-
static char* extract_content_tag_content(pm_call_node_t* call_node, pm_parser_t*
|
|
208
|
-
(void) _parser;
|
|
209
|
-
|
|
209
|
+
static char* extract_content_tag_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) {
|
|
210
210
|
if (!call_node) { return NULL; }
|
|
211
211
|
|
|
212
212
|
|
|
213
|
-
char* block_content = extract_inline_block_content(call_node, allocator);
|
|
213
|
+
char* block_content = extract_inline_block_content(call_node, parser, allocator);
|
|
214
214
|
if (block_content) { return block_content; }
|
|
215
215
|
|
|
216
216
|
|
|
@@ -228,10 +228,11 @@ static char* extract_content_tag_content(pm_call_node_t* call_node, pm_parser_t*
|
|
|
228
228
|
return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
const uint8_t* source = pm_parser_start(parser);
|
|
232
|
+
size_t source_length = argument->location.length;
|
|
232
233
|
|
|
233
234
|
|
|
234
|
-
return hb_allocator_strndup(allocator, (const char*) argument->location.start, source_length);
|
|
235
|
+
return hb_allocator_strndup(allocator, (const char*) (source + argument->location.start), source_length);
|
|
235
236
|
|
|
236
237
|
}
|
|
237
238
|
}
|
|
@@ -241,19 +242,17 @@ static char* extract_content_tag_content(pm_call_node_t* call_node, pm_parser_t*
|
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
static char* extract_tag_content(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) {
|
|
244
|
-
(void) parser;
|
|
245
|
-
|
|
246
245
|
if (!call_node) { return NULL; }
|
|
247
246
|
|
|
248
247
|
if (call_node->name) {
|
|
249
|
-
pm_constant_t* constant =
|
|
248
|
+
const pm_constant_t* constant = pm_parser_constant(parser, call_node->name);
|
|
250
249
|
|
|
251
|
-
if (constant && is_ruby_introspection_method(hb_string_from_data((const char*) constant
|
|
250
|
+
if (constant && is_ruby_introspection_method(hb_string_from_data((const char*) pm_constant_start(constant), pm_constant_length(constant)))) {
|
|
252
251
|
return NULL;
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
|
|
256
|
-
char* block_content = extract_inline_block_content(call_node, allocator);
|
|
255
|
+
char* block_content = extract_inline_block_content(call_node, parser, allocator);
|
|
257
256
|
if (block_content) { return block_content; }
|
|
258
257
|
|
|
259
258
|
|
|
@@ -271,10 +270,11 @@ static char* extract_tag_content(pm_call_node_t* call_node, pm_parser_t* parser,
|
|
|
271
270
|
return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length);
|
|
272
271
|
}
|
|
273
272
|
|
|
274
|
-
|
|
273
|
+
const uint8_t* source = pm_parser_start(parser);
|
|
274
|
+
size_t source_length = argument->location.length;
|
|
275
275
|
|
|
276
276
|
|
|
277
|
-
return hb_allocator_strndup(allocator, (const char*) argument->location.start, source_length);
|
|
277
|
+
return hb_allocator_strndup(allocator, (const char*) (source + argument->location.start), source_length);
|
|
278
278
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <stdbool.h>
|
|
6
6
|
#include <string.h>
|
|
7
7
|
|
|
8
|
-
char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t*
|
|
8
|
+
char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t* parser, hb_allocator_T* allocator) {
|
|
9
9
|
if (!call_node || !call_node->arguments) { return NULL; }
|
|
10
10
|
|
|
11
11
|
pm_arguments_node_t* arguments = call_node->arguments;
|
|
@@ -20,9 +20,13 @@ char* extract_image_tag_src(pm_call_node_t* call_node, pm_parser_t* _parser, hb_
|
|
|
20
20
|
return hb_allocator_strndup(allocator, (const char*) pm_string_source(&string_node->unescaped), length);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const uint8_t* source = pm_parser_start(parser);
|
|
24
24
|
|
|
25
|
-
return hb_allocator_strndup(
|
|
25
|
+
return hb_allocator_strndup(
|
|
26
|
+
allocator,
|
|
27
|
+
(const char*) (source + first_argument->location.start),
|
|
28
|
+
first_argument->location.length
|
|
29
|
+
);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
bool image_tag_source_is_url(const char* source, size_t length) {
|