herb 0.9.4-arm-linux-gnu → 0.9.6-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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/config.yml +57 -21
  3. data/ext/herb/extension.c +8 -0
  4. data/ext/herb/extension_helpers.c +1 -0
  5. data/ext/herb/nodes.c +93 -55
  6. data/lib/herb/3.0/herb.so +0 -0
  7. data/lib/herb/3.1/herb.so +0 -0
  8. data/lib/herb/3.2/herb.so +0 -0
  9. data/lib/herb/3.3/herb.so +0 -0
  10. data/lib/herb/3.4/herb.so +0 -0
  11. data/lib/herb/4.0/herb.so +0 -0
  12. data/lib/herb/action_view/helper_registry.rb +8107 -0
  13. data/lib/herb/ast/nodes.rb +212 -78
  14. data/lib/herb/engine/compiler.rb +4 -6
  15. data/lib/herb/parser_options.rb +7 -2
  16. data/lib/herb/project.rb +2 -5
  17. data/lib/herb/version.rb +1 -1
  18. data/lib/herb/visitor.rb +8 -2
  19. data/sig/herb/action_view/helper_registry.rbs +1144 -0
  20. data/sig/herb/ast/nodes.rbs +85 -34
  21. data/sig/herb/parser_options.rbs +6 -2
  22. data/sig/herb/visitor.rbs +5 -2
  23. data/sig/serialized_ast_nodes.rbs +20 -9
  24. data/src/analyze/action_view/generated_handlers.c +355 -0
  25. data/src/analyze/action_view/generated_handlers.h +16 -0
  26. data/src/analyze/action_view/helper_registry.c +7244 -0
  27. data/src/analyze/action_view/image_tag.c +4 -31
  28. data/src/analyze/action_view/javascript_include_tag.c +1 -42
  29. data/src/analyze/action_view/javascript_tag.c +26 -40
  30. data/src/analyze/action_view/registry.c +2 -2
  31. data/src/analyze/action_view/tag_helper_node_builders.c +23 -2
  32. data/src/analyze/action_view/tag_helpers.c +61 -134
  33. data/src/analyze/action_view/turbo_frame_tag.c +1 -36
  34. data/src/analyze/analyze.c +28 -0
  35. data/src/analyze/analyze_helpers.c +406 -0
  36. data/src/analyze/builders.c +1 -0
  37. data/src/analyze/missing_end.c +16 -0
  38. data/src/analyze/parse_errors.c +3 -2
  39. data/src/analyze/postfix_conditionals.c +326 -0
  40. data/src/analyze/render_nodes.c +231 -35
  41. data/src/analyze/strict_locals.c +22 -338
  42. data/src/analyze/ternary_conditionals.c +265 -0
  43. data/src/analyze/transform.c +23 -2
  44. data/src/ast/ast_nodes.c +114 -57
  45. data/src/ast/ast_pretty_print.c +109 -25
  46. data/src/include/analyze/action_view/helper_registry.h +325 -0
  47. data/src/include/analyze/action_view/tag_helper_handler.h +3 -0
  48. data/src/include/analyze/action_view/tag_helper_node_builders.h +7 -0
  49. data/src/include/analyze/action_view/tag_helpers.h +0 -1
  50. data/src/include/analyze/helpers.h +18 -0
  51. data/src/include/analyze/postfix_conditionals.h +9 -0
  52. data/src/include/analyze/ternary_conditionals.h +15 -0
  53. data/src/include/ast/ast_nodes.h +27 -13
  54. data/src/include/parser/parser.h +1 -0
  55. data/src/include/version.h +1 -1
  56. data/src/parser/match_tags.c +37 -6
  57. data/src/parser.c +9 -0
  58. data/src/visitor.c +50 -7
  59. data/templates/java/org/herb/ast/HelperRegistry.java.erb +258 -0
  60. data/templates/javascript/packages/core/src/action-view-helpers.ts.erb +171 -0
  61. data/templates/javascript/packages/core/src/nodes.ts.erb +5 -1
  62. data/templates/lib/herb/action_view/helper_registry.rb.erb +288 -0
  63. data/templates/rust/src/action_view_helpers.rs.erb +154 -0
  64. data/templates/src/analyze/action_view/generated_handlers.c.erb +230 -0
  65. data/templates/src/analyze/action_view/generated_handlers.h.erb +12 -0
  66. data/templates/src/analyze/action_view/helper_registry.c.erb +114 -0
  67. data/templates/src/include/analyze/action_view/helper_registry.h.erb +82 -0
  68. data/templates/template.rb +338 -1
  69. metadata +19 -3
  70. data/src/analyze/action_view/content_tag.c +0 -78
  71. data/src/analyze/action_view/tag.c +0 -87
@@ -0,0 +1,325 @@
1
+ // NOTE: This file is generated by the templates/template.rb script and should not
2
+ // be modified manually. See /home/runner/work/herb/herb/templates/src/include/analyze/action_view/helper_registry.h.erb
3
+
4
+ #ifndef HELPER_REGISTRY_H
5
+ #define HELPER_REGISTRY_H
6
+
7
+ #include "../../lib/hb_string.h"
8
+
9
+ #include <stdbool.h>
10
+ #include <stddef.h>
11
+
12
+ typedef enum {
13
+ HELPER_ACTION_CABLE_META_TAG,
14
+ HELPER_CONTENT_SECURITY_POLICY_P,
15
+ HELPER_CONTENT_SECURITY_POLICY_NONCE,
16
+ HELPER_POLYMORPHIC_PATH,
17
+ HELPER_POLYMORPHIC_URL,
18
+ HELPER_FORM_AUTHENTICITY_TOKEN,
19
+ HELPER_PROTECT_AGAINST_FORGERY_P,
20
+ HELPER_RENDER_ACTION_TEXT_CONTENT,
21
+ HELPER_SANITIZE_ACTION_TEXT_CONTENT,
22
+ HELPER_RICH_TEXTAREA_TAG,
23
+ HELPER_ERROR_MESSAGE,
24
+ HELPER_ERROR_WRAPPING,
25
+ HELPER_OBJECT,
26
+ HELPER_APPLY_STYLESHEET_MEDIA_DEFAULT,
27
+ HELPER_AUDIO_TAG,
28
+ HELPER_AUTO_DISCOVERY_LINK_TAG,
29
+ HELPER_AUTO_INCLUDE_NONCE,
30
+ HELPER_AUTO_INCLUDE_NONCE_FOR_SCRIPTS,
31
+ HELPER_AUTO_INCLUDE_NONCE_FOR_STYLES,
32
+ HELPER_FAVICON_LINK_TAG,
33
+ HELPER_IMAGE_DECODING,
34
+ HELPER_IMAGE_LOADING,
35
+ HELPER_IMAGE_TAG,
36
+ HELPER_JAVASCRIPT_INCLUDE_TAG,
37
+ HELPER_PICTURE_TAG,
38
+ HELPER_PRELOAD_LINK_TAG,
39
+ HELPER_PRELOAD_LINKS_HEADER,
40
+ HELPER_STYLESHEET_LINK_TAG,
41
+ HELPER_VIDEO_TAG,
42
+ HELPER_ASSET_PATH,
43
+ HELPER_ASSET_URL,
44
+ HELPER_AUDIO_PATH,
45
+ HELPER_AUDIO_URL,
46
+ HELPER_COMPUTE_ASSET_EXTNAME,
47
+ HELPER_COMPUTE_ASSET_HOST,
48
+ HELPER_COMPUTE_ASSET_PATH,
49
+ HELPER_FONT_PATH,
50
+ HELPER_FONT_URL,
51
+ HELPER_IMAGE_PATH,
52
+ HELPER_IMAGE_URL,
53
+ HELPER_JAVASCRIPT_PATH,
54
+ HELPER_JAVASCRIPT_URL,
55
+ HELPER_PUBLIC_COMPUTE_ASSET_PATH,
56
+ HELPER_STYLESHEET_PATH,
57
+ HELPER_STYLESHEET_URL,
58
+ HELPER_VIDEO_PATH,
59
+ HELPER_VIDEO_URL,
60
+ HELPER_ATOM_FEED,
61
+ HELPER_CACHE,
62
+ HELPER_CACHE_FRAGMENT_NAME,
63
+ HELPER_CACHE_IF,
64
+ HELPER_CACHE_UNLESS,
65
+ HELPER_CACHING_P,
66
+ HELPER_DIGEST_PATH_FROM_TEMPLATE,
67
+ HELPER_FRAGMENT_FOR,
68
+ HELPER_FRAGMENT_NAME_WITH_DIGEST,
69
+ HELPER_READ_FRAGMENT_FOR,
70
+ HELPER_UNCACHEABLE_BANG,
71
+ HELPER_WRITE_FRAGMENT_FOR,
72
+ HELPER_CAPTURE,
73
+ HELPER_CONTENT_FOR,
74
+ HELPER_CONTENT_FOR_P,
75
+ HELPER_PROVIDE,
76
+ HELPER_WITH_OUTPUT_BUFFER,
77
+ HELPER_PREPEND_CONTENT_EXFILTRATION_PREVENTION,
78
+ HELPER_PREVENT_CONTENT_EXFILTRATION,
79
+ HELPER_ACTION_NAME,
80
+ HELPER_ASSIGN_CONTROLLER,
81
+ HELPER_CONTROLLER,
82
+ HELPER_CONTROLLER_NAME,
83
+ HELPER_CONTROLLER_PATH,
84
+ HELPER_COOKIES,
85
+ HELPER_FLASH,
86
+ HELPER_HEADERS,
87
+ HELPER_LOGGER,
88
+ HELPER_PARAMS,
89
+ HELPER_REQUEST,
90
+ HELPER_REQUEST_FORGERY_PROTECTION_TOKEN,
91
+ HELPER_RESPONSE,
92
+ HELPER_SESSION,
93
+ HELPER_CSP_META_TAG,
94
+ HELPER_CSRF_META_TAGS,
95
+ HELPER_DATE_SELECT,
96
+ HELPER_DATETIME_SELECT,
97
+ HELPER_DISTANCE_OF_TIME_IN_WORDS,
98
+ HELPER_RELATIVE_TIME_IN_WORDS,
99
+ HELPER_SELECT_DATE,
100
+ HELPER_SELECT_DATETIME,
101
+ HELPER_SELECT_DAY,
102
+ HELPER_SELECT_HOUR,
103
+ HELPER_SELECT_MINUTE,
104
+ HELPER_SELECT_MONTH,
105
+ HELPER_SELECT_SECOND,
106
+ HELPER_SELECT_TIME,
107
+ HELPER_SELECT_YEAR,
108
+ HELPER_TIME_AGO_IN_WORDS,
109
+ HELPER_TIME_SELECT,
110
+ HELPER_TIME_TAG,
111
+ HELPER_DEBUG,
112
+ HELPER_APPLY_FORM_FOR_OPTIONS_BANG,
113
+ HELPER_BUTTON,
114
+ HELPER_CHECKBOX,
115
+ HELPER_COLOR_FIELD,
116
+ HELPER_DATE_FIELD,
117
+ HELPER_DATETIME_FIELD,
118
+ HELPER_EMAIL_FIELD,
119
+ HELPER_EMITTED_HIDDEN_ID_P,
120
+ HELPER_FIELDS,
121
+ HELPER_FIELDS_FOR,
122
+ HELPER_FILE_FIELD,
123
+ HELPER_FORM_FOR,
124
+ HELPER_FORM_WITH,
125
+ HELPER_FORM_WITH_GENERATES_IDS,
126
+ HELPER_FORM_WITH_GENERATES_REMOTE_FORMS,
127
+ HELPER_HIDDEN_FIELD,
128
+ HELPER_LABEL,
129
+ HELPER_MONTH_FIELD,
130
+ HELPER_MULTIPART,
131
+ HELPER_MULTIPLE_FILE_FIELD_INCLUDE_HIDDEN,
132
+ HELPER_NUMBER_FIELD,
133
+ HELPER_PASSWORD_FIELD,
134
+ HELPER_RADIO_BUTTON,
135
+ HELPER_RANGE_FIELD,
136
+ HELPER_SEARCH_FIELD,
137
+ HELPER_SUBMIT,
138
+ HELPER_TELEPHONE_FIELD,
139
+ HELPER_TEXT_FIELD,
140
+ HELPER_TEXTAREA,
141
+ HELPER_TIME_FIELD,
142
+ HELPER_URL_FIELD,
143
+ HELPER_WEEK_FIELD,
144
+ HELPER_COLLECTION_CHECKBOXES,
145
+ HELPER_COLLECTION_RADIO_BUTTONS,
146
+ HELPER_COLLECTION_SELECT,
147
+ HELPER_GROUPED_COLLECTION_SELECT,
148
+ HELPER_GROUPED_OPTIONS_FOR_SELECT,
149
+ HELPER_OPTION_GROUPS_FROM_COLLECTION_FOR_SELECT,
150
+ HELPER_OPTIONS_FOR_SELECT,
151
+ HELPER_OPTIONS_FROM_COLLECTION_FOR_SELECT,
152
+ HELPER_SELECT,
153
+ HELPER_TIME_ZONE_OPTIONS_FOR_SELECT,
154
+ HELPER_TIME_ZONE_SELECT,
155
+ HELPER_WEEKDAY_OPTIONS_FOR_SELECT,
156
+ HELPER_WEEKDAY_SELECT,
157
+ HELPER_BUTTON_TAG,
158
+ HELPER_CHECKBOX_TAG,
159
+ HELPER_COLOR_FIELD_TAG,
160
+ HELPER_DATE_FIELD_TAG,
161
+ HELPER_DATETIME_FIELD_TAG,
162
+ HELPER_DEFAULT_ENFORCE_UTF8,
163
+ HELPER_EMAIL_FIELD_TAG,
164
+ HELPER_EMBED_AUTHENTICITY_TOKEN_IN_REMOTE_FORMS,
165
+ HELPER_FIELD_ID,
166
+ HELPER_FIELD_NAME,
167
+ HELPER_FIELD_SET_TAG,
168
+ HELPER_FILE_FIELD_TAG,
169
+ HELPER_FORM_TAG,
170
+ HELPER_HIDDEN_FIELD_TAG,
171
+ HELPER_IMAGE_SUBMIT_TAG,
172
+ HELPER_LABEL_TAG,
173
+ HELPER_MONTH_FIELD_TAG,
174
+ HELPER_NUMBER_FIELD_TAG,
175
+ HELPER_PASSWORD_FIELD_TAG,
176
+ HELPER_RADIO_BUTTON_TAG,
177
+ HELPER_RANGE_FIELD_TAG,
178
+ HELPER_SEARCH_FIELD_TAG,
179
+ HELPER_SELECT_TAG,
180
+ HELPER_SUBMIT_TAG,
181
+ HELPER_TELEPHONE_FIELD_TAG,
182
+ HELPER_TEXT_FIELD_TAG,
183
+ HELPER_TEXTAREA_TAG,
184
+ HELPER_TIME_FIELD_TAG,
185
+ HELPER_URL_FIELD_TAG,
186
+ HELPER_UTF8_ENFORCER_TAG,
187
+ HELPER_WEEK_FIELD_TAG,
188
+ HELPER_ESCAPE_JAVASCRIPT,
189
+ HELPER_JAVASCRIPT_CDATA_SECTION,
190
+ HELPER_JAVASCRIPT_TAG,
191
+ HELPER_NUMBER_TO_CURRENCY,
192
+ HELPER_NUMBER_TO_HUMAN,
193
+ HELPER_NUMBER_TO_HUMAN_SIZE,
194
+ HELPER_NUMBER_TO_PERCENTAGE,
195
+ HELPER_NUMBER_TO_PHONE,
196
+ HELPER_NUMBER_WITH_DELIMITER,
197
+ HELPER_NUMBER_WITH_PRECISION,
198
+ HELPER_RAW,
199
+ HELPER_SAFE_JOIN,
200
+ HELPER_TO_SENTENCE,
201
+ HELPER_DOM_CLASS,
202
+ HELPER_DOM_ID,
203
+ HELPER_DOM_TARGET,
204
+ HELPER_MODEL_NAME_FROM_RECORD_OR_CLASS,
205
+ HELPER_RENDER,
206
+ HELPER_SANITIZE,
207
+ HELPER_SANITIZE_CSS,
208
+ HELPER_SANITIZER_VENDOR,
209
+ HELPER_STRIP_LINKS,
210
+ HELPER_STRIP_TAGS,
211
+ HELPER_CDATA_SECTION,
212
+ HELPER_CONTENT_TAG,
213
+ HELPER_ESCAPE_ONCE,
214
+ HELPER_TAG,
215
+ HELPER_TOKEN_LIST,
216
+ HELPER_CONCAT,
217
+ HELPER_CURRENT_CYCLE,
218
+ HELPER_CYCLE,
219
+ HELPER_EXCERPT,
220
+ HELPER_HIGHLIGHT,
221
+ HELPER_PLURALIZE,
222
+ HELPER_RESET_CYCLE,
223
+ HELPER_SAFE_CONCAT,
224
+ HELPER_SIMPLE_FORMAT,
225
+ HELPER_TRUNCATE,
226
+ HELPER_WORD_WRAP,
227
+ HELPER_DEBUG_MISSING_TRANSLATION,
228
+ HELPER_LOCALIZE,
229
+ HELPER_TRANSLATE,
230
+ HELPER_BUTTON_TO,
231
+ HELPER_BUTTON_TO_GENERATES_BUTTON_TAG,
232
+ HELPER_CURRENT_PAGE_P,
233
+ HELPER_LINK_TO,
234
+ HELPER_LINK_TO_IF,
235
+ HELPER_LINK_TO_UNLESS,
236
+ HELPER_LINK_TO_UNLESS_CURRENT,
237
+ HELPER_MAIL_TO,
238
+ HELPER_PHONE_TO,
239
+ HELPER_SMS_TO,
240
+ HELPER_URL_FOR,
241
+ HELPER_TURBO_EXEMPTS_PAGE_FROM_CACHE,
242
+ HELPER_TURBO_EXEMPTS_PAGE_FROM_CACHE_TAG,
243
+ HELPER_TURBO_EXEMPTS_PAGE_FROM_PREVIEW,
244
+ HELPER_TURBO_EXEMPTS_PAGE_FROM_PREVIEW_TAG,
245
+ HELPER_TURBO_PAGE_REQUIRES_RELOAD,
246
+ HELPER_TURBO_PAGE_REQUIRES_RELOAD_TAG,
247
+ HELPER_TURBO_REFRESH_METHOD_TAG,
248
+ HELPER_TURBO_REFRESH_SCROLL_TAG,
249
+ HELPER_TURBO_REFRESHES_WITH,
250
+ HELPER_TURBO_FRAME_TAG,
251
+ HELPER_TURBO_INCLUDE_TAGS,
252
+ HELPER_TURBO_STREAM_ACTION_TAG,
253
+ HELPER_TURBO_STREAM_REFRESH_TAG,
254
+ HELPER_TURBO_STREAM,
255
+ HELPER_TURBO_STREAM_FROM,
256
+ } helper_type_T;
257
+
258
+ #define HELPER_COUNT 243
259
+
260
+ typedef enum {
261
+ HELPER_DETECT_CALL_NAME,
262
+ HELPER_DETECT_RECEIVER_CALL,
263
+ } helper_detect_style_T;
264
+
265
+ typedef struct {
266
+ const char* name;
267
+ const char* type;
268
+ const char* description;
269
+ } helper_argument_T;
270
+
271
+ typedef struct {
272
+ const char* name;
273
+ const char* type;
274
+ const char* maps_to;
275
+ const char* description;
276
+ } helper_option_T;
277
+
278
+ typedef struct {
279
+ const char* name;
280
+ const char* source;
281
+ const char* source_with_block;
282
+ const char* wrapper;
283
+ } helper_implicit_attribute_T;
284
+
285
+ typedef enum {
286
+ HELPER_OUTPUT_HTML,
287
+ HELPER_OUTPUT_TEXT,
288
+ HELPER_OUTPUT_URL,
289
+ HELPER_OUTPUT_BOOLEAN,
290
+ HELPER_OUTPUT_VOID,
291
+ HELPER_OUTPUT_OBJECT,
292
+ } helper_output_T;
293
+
294
+ typedef struct {
295
+ helper_type_T type;
296
+ const char* name;
297
+ size_t name_length;
298
+ hb_string_T source;
299
+ const char* gem;
300
+ helper_output_T output;
301
+ const char* visibility;
302
+ const char* tag_name;
303
+ bool is_void;
304
+ bool supports_block;
305
+ bool preferred_for_tag;
306
+ bool supported;
307
+ helper_detect_style_T detect_style;
308
+ const char* description;
309
+ const char* signature;
310
+ const char* documentation_url;
311
+ const helper_implicit_attribute_T* implicit_attribute;
312
+ const helper_argument_T* arguments;
313
+ size_t arguments_count;
314
+ const helper_option_T* options;
315
+ size_t options_count;
316
+ } helper_registry_entry_T;
317
+
318
+ const helper_registry_entry_T* helper_registry_get(helper_type_T type);
319
+ const helper_registry_entry_T* helper_registry_find_by_name(const char* name, size_t length);
320
+ const helper_registry_entry_T* helper_registry_find_by_source(const char* source);
321
+ const helper_registry_entry_T* helper_registry_find_preferred_for_tag(const char* tag_name);
322
+ const helper_registry_entry_T* helper_registry_entries(void);
323
+ size_t helper_registry_count(void);
324
+
325
+ #endif
@@ -40,4 +40,7 @@ size_t get_tag_helper_handlers_count(void);
40
40
 
41
41
  char* extract_inline_block_content(pm_call_node_t* call_node, hb_allocator_T* allocator);
42
42
 
43
+ struct AST_NODE_STRUCT;
44
+ bool wrap_javascript_tag_body_visitor(const struct AST_NODE_STRUCT* node, void* data);
45
+
43
46
  #endif
@@ -87,6 +87,13 @@ AST_HTML_ATTRIBUTE_NODE_T* create_href_attribute(
87
87
  hb_allocator_T* allocator
88
88
  );
89
89
 
90
+ AST_CDATA_NODE_T* create_javascript_cdata_node(
91
+ hb_array_T* children,
92
+ position_T start,
93
+ position_T end,
94
+ hb_allocator_T* allocator
95
+ );
96
+
90
97
  void append_body_content_node(
91
98
  hb_array_T* body,
92
99
  const char* content,
@@ -17,7 +17,6 @@ typedef struct {
17
17
  tag_helper_info_T* info;
18
18
  const tag_helper_handler_T* matched_handler;
19
19
  bool found;
20
- const pm_node_t* postfix_conditional_node;
21
20
  } tag_helper_search_data_T;
22
21
 
23
22
  bool search_tag_helper_node(const pm_node_t* node, void* data);
@@ -5,7 +5,9 @@
5
5
  #include <stdbool.h>
6
6
 
7
7
  #include "../ast/ast_node.h"
8
+ #include "../ast/ast_nodes.h"
8
9
  #include "../lib/hb_allocator.h"
10
+ #include "../lib/hb_array.h"
9
11
  #include "analyzed_ruby.h"
10
12
 
11
13
  bool has_if_node(analyzed_ruby_T* analyzed);
@@ -62,4 +64,20 @@ bool search_unexpected_when_nodes(analyzed_ruby_T* analyzed);
62
64
 
63
65
  void check_erb_node_for_missing_end(const AST_NODE_T* node, hb_allocator_T* allocator);
64
66
 
67
+ hb_array_T* extract_parameters_from_prism(
68
+ pm_parameters_node_t* parameters,
69
+ pm_parser_t* parser,
70
+ const char* source,
71
+ size_t source_base_offset,
72
+ const uint8_t* prism_source_start,
73
+ hb_allocator_T* allocator
74
+ );
75
+
76
+ hb_array_T* extract_block_arguments_from_erb_node(
77
+ const AST_ERB_CONTENT_NODE_T* erb_node,
78
+ const char* source,
79
+ hb_array_T* errors,
80
+ hb_allocator_T* allocator
81
+ );
82
+
65
83
  #endif
@@ -0,0 +1,9 @@
1
+ #ifndef HERB_ANALYZE_POSTFIX_CONDITIONALS_H
2
+ #define HERB_ANALYZE_POSTFIX_CONDITIONALS_H
3
+
4
+ #include "../ast/ast_nodes.h"
5
+ #include "analyze.h"
6
+
7
+ bool transform_conditional_nodes(const AST_NODE_T* node, void* data);
8
+
9
+ #endif
@@ -0,0 +1,15 @@
1
+ #ifndef HERB_ANALYZE_TERNARY_CONDITIONALS_H
2
+ #define HERB_ANALYZE_TERNARY_CONDITIONALS_H
3
+
4
+ #include "../ast/ast_nodes.h"
5
+ #include "analyze.h"
6
+
7
+ AST_NODE_T* transform_ternary_expression(
8
+ AST_ERB_CONTENT_NODE_T* erb_node,
9
+ pm_if_node_t* if_node,
10
+ hb_allocator_T* allocator
11
+ );
12
+
13
+ bool transform_ternary_conditional_nodes(const AST_NODE_T* node, void* data);
14
+
15
+ #endif
@@ -57,8 +57,9 @@ typedef enum {
57
57
  AST_ERB_BEGIN_NODE,
58
58
  AST_ERB_UNLESS_NODE,
59
59
  AST_RUBY_RENDER_LOCAL_NODE,
60
+ AST_RUBY_RENDER_KEYWORDS_NODE,
60
61
  AST_ERB_RENDER_NODE,
61
- AST_RUBY_STRICT_LOCAL_NODE,
62
+ AST_RUBY_PARAMETER_NODE,
62
63
  AST_ERB_STRICT_LOCALS_NODE,
63
64
  AST_ERB_YIELD_NODE,
64
65
  AST_ERB_IN_NODE,
@@ -263,6 +264,7 @@ typedef struct AST_ERB_BLOCK_NODE_STRUCT {
263
264
  token_T* tag_closing;
264
265
  herb_prism_node_T prism_node;
265
266
  hb_array_T* body;
267
+ hb_array_T* block_arguments;
266
268
  struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
267
269
  struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
268
270
  struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause;
@@ -380,13 +382,8 @@ typedef struct AST_RUBY_RENDER_LOCAL_NODE_STRUCT {
380
382
  struct AST_RUBY_LITERAL_NODE_STRUCT* value;
381
383
  } AST_RUBY_RENDER_LOCAL_NODE_T;
382
384
 
383
- typedef struct AST_ERB_RENDER_NODE_STRUCT {
385
+ typedef struct AST_RUBY_RENDER_KEYWORDS_NODE_STRUCT {
384
386
  AST_NODE_T base;
385
- token_T* tag_opening;
386
- token_T* content;
387
- token_T* tag_closing;
388
- analyzed_ruby_T* analyzed_ruby;
389
- herb_prism_node_T prism_node;
390
387
  token_T* partial;
391
388
  token_T* template_path;
392
389
  token_T* layout;
@@ -405,15 +402,31 @@ typedef struct AST_ERB_RENDER_NODE_STRUCT {
405
402
  token_T* handlers;
406
403
  token_T* content_type;
407
404
  hb_array_T* locals;
405
+ } AST_RUBY_RENDER_KEYWORDS_NODE_T;
406
+
407
+ typedef struct AST_ERB_RENDER_NODE_STRUCT {
408
+ AST_NODE_T base;
409
+ token_T* tag_opening;
410
+ token_T* content;
411
+ token_T* tag_closing;
412
+ analyzed_ruby_T* analyzed_ruby;
413
+ herb_prism_node_T prism_node;
414
+ struct AST_RUBY_RENDER_KEYWORDS_NODE_STRUCT* keywords;
415
+ hb_array_T* body;
416
+ hb_array_T* block_arguments;
417
+ struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
418
+ struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
419
+ struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause;
420
+ struct AST_ERB_END_NODE_STRUCT* end_node;
408
421
  } AST_ERB_RENDER_NODE_T;
409
422
 
410
- typedef struct AST_RUBY_STRICT_LOCAL_NODE_STRUCT {
423
+ typedef struct AST_RUBY_PARAMETER_NODE_STRUCT {
411
424
  AST_NODE_T base;
412
425
  token_T* name;
413
426
  struct AST_RUBY_LITERAL_NODE_STRUCT* default_value;
427
+ hb_string_T kind;
414
428
  bool required;
415
- bool double_splat;
416
- } AST_RUBY_STRICT_LOCAL_NODE_T;
429
+ } AST_RUBY_PARAMETER_NODE_T;
417
430
 
418
431
  typedef struct AST_ERB_STRICT_LOCALS_NODE_STRUCT {
419
432
  AST_NODE_T base;
@@ -466,7 +479,7 @@ AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T*
466
479
  AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
467
480
  AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
468
481
  AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, AST_NODE_T* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
469
- AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
482
+ AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* body, hb_array_T* block_arguments, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
470
483
  AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
471
484
  AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
472
485
  AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, herb_prism_node_T prism_node, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
@@ -478,8 +491,9 @@ AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* c
478
491
  AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
479
492
  AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
480
493
  AST_RUBY_RENDER_LOCAL_NODE_T* ast_ruby_render_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
481
- AST_ERB_RENDER_NODE_T* ast_erb_render_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, token_T* partial, token_T* template_path, token_T* layout, token_T* file, token_T* inline_template, token_T* body, token_T* plain, token_T* html, token_T* renderable, token_T* collection, token_T* object, token_T* as_name, token_T* spacer_template, token_T* formats, token_T* variants, token_T* handlers, token_T* content_type, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
482
- AST_RUBY_STRICT_LOCAL_NODE_T* ast_ruby_strict_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* default_value, bool required, bool double_splat, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
494
+ AST_RUBY_RENDER_KEYWORDS_NODE_T* ast_ruby_render_keywords_node_init(token_T* partial, token_T* template_path, token_T* layout, token_T* file, token_T* inline_template, token_T* body, token_T* plain, token_T* html, token_T* renderable, token_T* collection, token_T* object, token_T* as_name, token_T* spacer_template, token_T* formats, token_T* variants, token_T* handlers, token_T* content_type, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
495
+ AST_ERB_RENDER_NODE_T* ast_erb_render_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, struct AST_RUBY_RENDER_KEYWORDS_NODE_STRUCT* keywords, hb_array_T* body, hb_array_T* block_arguments, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
496
+ AST_RUBY_PARAMETER_NODE_T* ast_ruby_parameter_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* default_value, hb_string_T kind, bool required, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
483
497
  AST_ERB_STRICT_LOCALS_NODE_T* ast_erb_strict_locals_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
484
498
  AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
485
499
  AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
@@ -23,6 +23,7 @@ typedef struct PARSER_OPTIONS_STRUCT {
23
23
  bool analyze;
24
24
  bool strict;
25
25
  bool action_view_helpers;
26
+ bool transform_conditionals;
26
27
  bool render_nodes;
27
28
  bool strict_locals;
28
29
  bool prism_program;
@@ -1,6 +1,6 @@
1
1
  #ifndef HERB_VERSION_H
2
2
  #define HERB_VERSION_H
3
3
 
4
- #define HERB_VERSION "0.9.4"
4
+ #define HERB_VERSION "0.9.6"
5
5
 
6
6
  #endif
@@ -205,6 +205,9 @@ bool match_tags_visitor(const AST_NODE_T* node, void* data) {
205
205
  if (erb_block_node->body != NULL) {
206
206
  match_tags_in_node_array(erb_block_node->body, context->errors, context->options, context->allocator);
207
207
  }
208
+ if (erb_block_node->block_arguments != NULL) {
209
+ match_tags_in_node_array(erb_block_node->block_arguments, context->errors, context->options, context->allocator);
210
+ }
208
211
  if (erb_block_node->rescue_clause != NULL) {
209
212
  herb_visit_node((AST_NODE_T*) erb_block_node->rescue_clause, match_tags_visitor, context);
210
213
  }
@@ -379,21 +382,49 @@ bool match_tags_visitor(const AST_NODE_T* node, void* data) {
379
382
 
380
383
 
381
384
 
385
+ case AST_RUBY_RENDER_KEYWORDS_NODE: {
386
+ const AST_RUBY_RENDER_KEYWORDS_NODE_T* ruby_render_keywords_node = (const AST_RUBY_RENDER_KEYWORDS_NODE_T*) node;
387
+
388
+ if (ruby_render_keywords_node->locals != NULL) {
389
+ match_tags_in_node_array(ruby_render_keywords_node->locals, context->errors, context->options, context->allocator);
390
+ }
391
+ } break;
392
+
393
+
394
+
382
395
  case AST_ERB_RENDER_NODE: {
383
396
  const AST_ERB_RENDER_NODE_T* erb_render_node = (const AST_ERB_RENDER_NODE_T*) node;
384
397
 
385
- if (erb_render_node->locals != NULL) {
386
- match_tags_in_node_array(erb_render_node->locals, context->errors, context->options, context->allocator);
398
+ if (erb_render_node->body != NULL) {
399
+ match_tags_in_node_array(erb_render_node->body, context->errors, context->options, context->allocator);
400
+ }
401
+ if (erb_render_node->block_arguments != NULL) {
402
+ match_tags_in_node_array(erb_render_node->block_arguments, context->errors, context->options, context->allocator);
403
+ }
404
+ if (erb_render_node->keywords != NULL) {
405
+ herb_visit_node((AST_NODE_T*) erb_render_node->keywords, match_tags_visitor, context);
406
+ }
407
+ if (erb_render_node->rescue_clause != NULL) {
408
+ herb_visit_node((AST_NODE_T*) erb_render_node->rescue_clause, match_tags_visitor, context);
409
+ }
410
+ if (erb_render_node->else_clause != NULL) {
411
+ herb_visit_node((AST_NODE_T*) erb_render_node->else_clause, match_tags_visitor, context);
412
+ }
413
+ if (erb_render_node->ensure_clause != NULL) {
414
+ herb_visit_node((AST_NODE_T*) erb_render_node->ensure_clause, match_tags_visitor, context);
415
+ }
416
+ if (erb_render_node->end_node != NULL) {
417
+ herb_visit_node((AST_NODE_T*) erb_render_node->end_node, match_tags_visitor, context);
387
418
  }
388
419
  } break;
389
420
 
390
421
 
391
422
 
392
- case AST_RUBY_STRICT_LOCAL_NODE: {
393
- const AST_RUBY_STRICT_LOCAL_NODE_T* ruby_strict_local_node = (const AST_RUBY_STRICT_LOCAL_NODE_T*) node;
423
+ case AST_RUBY_PARAMETER_NODE: {
424
+ const AST_RUBY_PARAMETER_NODE_T* ruby_parameter_node = (const AST_RUBY_PARAMETER_NODE_T*) node;
394
425
 
395
- if (ruby_strict_local_node->default_value != NULL) {
396
- herb_visit_node((AST_NODE_T*) ruby_strict_local_node->default_value, match_tags_visitor, context);
426
+ if (ruby_parameter_node->default_value != NULL) {
427
+ herb_visit_node((AST_NODE_T*) ruby_parameter_node->default_value, match_tags_visitor, context);
397
428
  }
398
429
  } break;
399
430
 
data/src/parser.c CHANGED
@@ -1,4 +1,5 @@
1
1
  #include "include/parser/parser.h"
2
+ #include "include/analyze/action_view/tag_helper_handler.h"
2
3
  #include "include/ast/ast_node.h"
3
4
  #include "include/ast/ast_nodes.h"
4
5
  #include "include/errors.h"
@@ -38,6 +39,7 @@ const parser_options_T HERB_DEFAULT_PARSER_OPTIONS = { .track_whitespace = false
38
39
  .analyze = true,
39
40
  .strict = true,
40
41
  .action_view_helpers = false,
42
+ .transform_conditionals = false,
41
43
  .render_nodes = false,
42
44
  .strict_locals = false,
43
45
  .prism_nodes_deep = false,
@@ -1897,4 +1899,11 @@ void herb_parser_match_html_tags_post_analyze(
1897
1899
  if (document == NULL) { return; }
1898
1900
 
1899
1901
  match_tags_in_node_array(document->children, document->base.errors, options, allocator);
1902
+
1903
+ if (options && options->action_view_helpers) {
1904
+ for (size_t i = 0; i < hb_array_size(document->children); i++) {
1905
+ AST_NODE_T* node = (AST_NODE_T*) hb_array_get(document->children, i);
1906
+ herb_visit_node(node, wrap_javascript_tag_body_visitor, allocator);
1907
+ }
1908
+ }
1900
1909
  }