herb 0.9.0-arm-linux-gnu → 0.9.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/config.yml +156 -0
- data/ext/herb/error_helpers.c +168 -0
- data/ext/herb/extension.c +4 -0
- data/ext/herb/extension_helpers.c +1 -0
- data/ext/herb/nodes.c +110 -0
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -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/ast/nodes.rb +393 -17
- data/lib/herb/engine/compiler.rb +17 -41
- data/lib/herb/engine.rb +76 -26
- data/lib/herb/errors.rb +245 -0
- data/lib/herb/parser_options.rb +6 -1
- data/lib/herb/prism_inspect.rb +5 -1
- data/lib/herb/version.rb +1 -1
- data/lib/herb/visitor.rb +10 -0
- data/sig/herb/ast/nodes.rbs +132 -0
- data/sig/herb/engine/compiler.rbs +4 -2
- data/sig/herb/engine.rbs +8 -0
- data/sig/herb/errors.rbs +114 -0
- data/sig/herb/parser_options.rbs +4 -0
- data/sig/herb/visitor.rbs +6 -0
- data/sig/rubyvm.rbs +5 -0
- data/sig/serialized_ast_errors.rbs +28 -0
- data/sig/serialized_ast_nodes.rbs +31 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +23 -1
- data/src/analyze/action_view/content_tag.c +19 -11
- data/src/analyze/action_view/javascript_include_tag.c +92 -0
- data/src/analyze/action_view/javascript_tag.c +55 -0
- data/src/analyze/action_view/link_to.c +25 -1
- data/src/analyze/action_view/registry.c +29 -2
- data/src/analyze/action_view/tag.c +14 -8
- data/src/analyze/action_view/tag_helper_node_builders.c +16 -3
- data/src/analyze/action_view/tag_helpers.c +332 -12
- data/src/analyze/analyze.c +3 -0
- data/src/analyze/prism_annotate.c +4 -2
- data/src/analyze/render_nodes.c +761 -0
- data/src/analyze/transform.c +7 -0
- data/src/ast_nodes.c +97 -0
- data/src/ast_pretty_print.c +74 -0
- data/src/errors.c +379 -0
- data/src/html_util.c +50 -0
- data/src/include/analyze/action_view/tag_helper_handler.h +2 -0
- data/src/include/analyze/render_nodes.h +11 -0
- data/src/include/ast_nodes.h +37 -0
- data/src/include/errors.h +58 -0
- data/src/include/html_util.h +1 -0
- data/src/include/parser.h +1 -0
- data/src/include/version.h +1 -1
- data/src/parser.c +1 -0
- data/src/parser_match_tags.c +20 -0
- data/src/util/hb_arena.c +3 -7
- data/src/visitor.c +20 -0
- data/templates/lib/herb/ast/nodes.rb.erb +8 -2
- data/templates/rust/src/ast/nodes.rs.erb +1 -1
- data/templates/rust/src/nodes.rs.erb +1 -1
- metadata +6 -1
data/src/analyze/transform.c
CHANGED
|
@@ -197,6 +197,13 @@ bool transform_erb_nodes(const AST_NODE_T* node, void* data) {
|
|
|
197
197
|
hb_array_free(&old_array);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
if (node->type == AST_ERB_RENDER_NODE) {
|
|
201
|
+
AST_ERB_RENDER_NODE_T* erb_render_node = (AST_ERB_RENDER_NODE_T*) node;
|
|
202
|
+
hb_array_T* old_array = erb_render_node->locals;
|
|
203
|
+
erb_render_node->locals = rewrite_node_array((AST_NODE_T*) node, erb_render_node->locals, context);
|
|
204
|
+
hb_array_free(&old_array);
|
|
205
|
+
}
|
|
206
|
+
|
|
200
207
|
if (node->type == AST_ERB_IN_NODE) {
|
|
201
208
|
AST_ERB_IN_NODE_T* erb_in_node = (AST_ERB_IN_NODE_T*) node;
|
|
202
209
|
hb_array_T* old_array = erb_in_node->statements;
|
data/src/ast_nodes.c
CHANGED
|
@@ -568,6 +568,53 @@ AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* c
|
|
|
568
568
|
return erb_unless_node;
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
+
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) {
|
|
572
|
+
AST_RUBY_RENDER_LOCAL_NODE_T* ruby_render_local_node = hb_allocator_alloc(allocator, sizeof(AST_RUBY_RENDER_LOCAL_NODE_T));
|
|
573
|
+
|
|
574
|
+
if (!ruby_render_local_node) { return NULL; }
|
|
575
|
+
|
|
576
|
+
ast_node_init(&ruby_render_local_node->base, AST_RUBY_RENDER_LOCAL_NODE, start_position, end_position, errors, allocator);
|
|
577
|
+
|
|
578
|
+
ruby_render_local_node->name = token_copy(name, allocator);
|
|
579
|
+
ruby_render_local_node->value = value;
|
|
580
|
+
|
|
581
|
+
return ruby_render_local_node;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
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) {
|
|
585
|
+
AST_ERB_RENDER_NODE_T* erb_render_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_RENDER_NODE_T));
|
|
586
|
+
|
|
587
|
+
if (!erb_render_node) { return NULL; }
|
|
588
|
+
|
|
589
|
+
ast_node_init(&erb_render_node->base, AST_ERB_RENDER_NODE, start_position, end_position, errors, allocator);
|
|
590
|
+
|
|
591
|
+
erb_render_node->tag_opening = token_copy(tag_opening, allocator);
|
|
592
|
+
erb_render_node->content = token_copy(content, allocator);
|
|
593
|
+
erb_render_node->tag_closing = token_copy(tag_closing, allocator);
|
|
594
|
+
erb_render_node->analyzed_ruby = analyzed_ruby;
|
|
595
|
+
erb_render_node->prism_node = prism_node;
|
|
596
|
+
erb_render_node->partial = token_copy(partial, allocator);
|
|
597
|
+
erb_render_node->template_path = token_copy(template_path, allocator);
|
|
598
|
+
erb_render_node->layout = token_copy(layout, allocator);
|
|
599
|
+
erb_render_node->file = token_copy(file, allocator);
|
|
600
|
+
erb_render_node->inline_template = token_copy(inline_template, allocator);
|
|
601
|
+
erb_render_node->body = token_copy(body, allocator);
|
|
602
|
+
erb_render_node->plain = token_copy(plain, allocator);
|
|
603
|
+
erb_render_node->html = token_copy(html, allocator);
|
|
604
|
+
erb_render_node->renderable = token_copy(renderable, allocator);
|
|
605
|
+
erb_render_node->collection = token_copy(collection, allocator);
|
|
606
|
+
erb_render_node->object = token_copy(object, allocator);
|
|
607
|
+
erb_render_node->as_name = token_copy(as_name, allocator);
|
|
608
|
+
erb_render_node->spacer_template = token_copy(spacer_template, allocator);
|
|
609
|
+
erb_render_node->formats = token_copy(formats, allocator);
|
|
610
|
+
erb_render_node->variants = token_copy(variants, allocator);
|
|
611
|
+
erb_render_node->handlers = token_copy(handlers, allocator);
|
|
612
|
+
erb_render_node->content_type = token_copy(content_type, allocator);
|
|
613
|
+
erb_render_node->locals = locals;
|
|
614
|
+
|
|
615
|
+
return erb_render_node;
|
|
616
|
+
}
|
|
617
|
+
|
|
571
618
|
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) {
|
|
572
619
|
AST_ERB_YIELD_NODE_T* erb_yield_node = hb_allocator_alloc(allocator, sizeof(AST_ERB_YIELD_NODE_T));
|
|
573
620
|
|
|
@@ -636,6 +683,8 @@ hb_string_T ast_node_type_to_string(AST_NODE_T* node) {
|
|
|
636
683
|
case AST_ERB_ENSURE_NODE: return hb_string("AST_ERB_ENSURE_NODE");
|
|
637
684
|
case AST_ERB_BEGIN_NODE: return hb_string("AST_ERB_BEGIN_NODE");
|
|
638
685
|
case AST_ERB_UNLESS_NODE: return hb_string("AST_ERB_UNLESS_NODE");
|
|
686
|
+
case AST_RUBY_RENDER_LOCAL_NODE: return hb_string("AST_RUBY_RENDER_LOCAL_NODE");
|
|
687
|
+
case AST_ERB_RENDER_NODE: return hb_string("AST_ERB_RENDER_NODE");
|
|
639
688
|
case AST_ERB_YIELD_NODE: return hb_string("AST_ERB_YIELD_NODE");
|
|
640
689
|
case AST_ERB_IN_NODE: return hb_string("AST_ERB_IN_NODE");
|
|
641
690
|
}
|
|
@@ -681,6 +730,8 @@ hb_string_T ast_node_human_type(AST_NODE_T* node) {
|
|
|
681
730
|
case AST_ERB_ENSURE_NODE: return hb_string("ERBEnsureNode");
|
|
682
731
|
case AST_ERB_BEGIN_NODE: return hb_string("ERBBeginNode");
|
|
683
732
|
case AST_ERB_UNLESS_NODE: return hb_string("ERBUnlessNode");
|
|
733
|
+
case AST_RUBY_RENDER_LOCAL_NODE: return hb_string("RubyRenderLocalNode");
|
|
734
|
+
case AST_ERB_RENDER_NODE: return hb_string("ERBRenderNode");
|
|
684
735
|
case AST_ERB_YIELD_NODE: return hb_string("ERBYieldNode");
|
|
685
736
|
case AST_ERB_IN_NODE: return hb_string("ERBInNode");
|
|
686
737
|
}
|
|
@@ -1222,6 +1273,50 @@ static void ast_free_erb_unless_node(AST_ERB_UNLESS_NODE_T* erb_unless_node, hb_
|
|
|
1222
1273
|
ast_free_base_node(&erb_unless_node->base, allocator);
|
|
1223
1274
|
}
|
|
1224
1275
|
|
|
1276
|
+
static void ast_free_ruby_render_local_node(AST_RUBY_RENDER_LOCAL_NODE_T* ruby_render_local_node, hb_allocator_T* allocator) {
|
|
1277
|
+
if (ruby_render_local_node->name != NULL) { token_free(ruby_render_local_node->name, allocator); }
|
|
1278
|
+
ast_node_free((AST_NODE_T*) ruby_render_local_node->value, allocator);
|
|
1279
|
+
|
|
1280
|
+
ast_free_base_node(&ruby_render_local_node->base, allocator);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
static void ast_free_erb_render_node(AST_ERB_RENDER_NODE_T* erb_render_node, hb_allocator_T* allocator) {
|
|
1284
|
+
if (erb_render_node->tag_opening != NULL) { token_free(erb_render_node->tag_opening, allocator); }
|
|
1285
|
+
if (erb_render_node->content != NULL) { token_free(erb_render_node->content, allocator); }
|
|
1286
|
+
if (erb_render_node->tag_closing != NULL) { token_free(erb_render_node->tag_closing, allocator); }
|
|
1287
|
+
if (erb_render_node->analyzed_ruby != NULL) {
|
|
1288
|
+
free_analyzed_ruby(erb_render_node->analyzed_ruby);
|
|
1289
|
+
}
|
|
1290
|
+
/* prism_node is a borrowed reference into the prism context, not freed here */
|
|
1291
|
+
if (erb_render_node->partial != NULL) { token_free(erb_render_node->partial, allocator); }
|
|
1292
|
+
if (erb_render_node->template_path != NULL) { token_free(erb_render_node->template_path, allocator); }
|
|
1293
|
+
if (erb_render_node->layout != NULL) { token_free(erb_render_node->layout, allocator); }
|
|
1294
|
+
if (erb_render_node->file != NULL) { token_free(erb_render_node->file, allocator); }
|
|
1295
|
+
if (erb_render_node->inline_template != NULL) { token_free(erb_render_node->inline_template, allocator); }
|
|
1296
|
+
if (erb_render_node->body != NULL) { token_free(erb_render_node->body, allocator); }
|
|
1297
|
+
if (erb_render_node->plain != NULL) { token_free(erb_render_node->plain, allocator); }
|
|
1298
|
+
if (erb_render_node->html != NULL) { token_free(erb_render_node->html, allocator); }
|
|
1299
|
+
if (erb_render_node->renderable != NULL) { token_free(erb_render_node->renderable, allocator); }
|
|
1300
|
+
if (erb_render_node->collection != NULL) { token_free(erb_render_node->collection, allocator); }
|
|
1301
|
+
if (erb_render_node->object != NULL) { token_free(erb_render_node->object, allocator); }
|
|
1302
|
+
if (erb_render_node->as_name != NULL) { token_free(erb_render_node->as_name, allocator); }
|
|
1303
|
+
if (erb_render_node->spacer_template != NULL) { token_free(erb_render_node->spacer_template, allocator); }
|
|
1304
|
+
if (erb_render_node->formats != NULL) { token_free(erb_render_node->formats, allocator); }
|
|
1305
|
+
if (erb_render_node->variants != NULL) { token_free(erb_render_node->variants, allocator); }
|
|
1306
|
+
if (erb_render_node->handlers != NULL) { token_free(erb_render_node->handlers, allocator); }
|
|
1307
|
+
if (erb_render_node->content_type != NULL) { token_free(erb_render_node->content_type, allocator); }
|
|
1308
|
+
if (erb_render_node->locals != NULL) {
|
|
1309
|
+
for (size_t i = 0; i < hb_array_size(erb_render_node->locals); i++) {
|
|
1310
|
+
AST_NODE_T* child = hb_array_get(erb_render_node->locals, i);
|
|
1311
|
+
if (child) { ast_node_free(child, allocator); }
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
hb_array_free(&erb_render_node->locals);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
ast_free_base_node(&erb_render_node->base, allocator);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1225
1320
|
static void ast_free_erb_yield_node(AST_ERB_YIELD_NODE_T* erb_yield_node, hb_allocator_T* allocator) {
|
|
1226
1321
|
if (erb_yield_node->tag_opening != NULL) { token_free(erb_yield_node->tag_opening, allocator); }
|
|
1227
1322
|
if (erb_yield_node->content != NULL) { token_free(erb_yield_node->content, allocator); }
|
|
@@ -1287,6 +1382,8 @@ void ast_node_free(AST_NODE_T* node, hb_allocator_T* allocator) {
|
|
|
1287
1382
|
case AST_ERB_ENSURE_NODE: ast_free_erb_ensure_node((AST_ERB_ENSURE_NODE_T*) node, allocator); break;
|
|
1288
1383
|
case AST_ERB_BEGIN_NODE: ast_free_erb_begin_node((AST_ERB_BEGIN_NODE_T*) node, allocator); break;
|
|
1289
1384
|
case AST_ERB_UNLESS_NODE: ast_free_erb_unless_node((AST_ERB_UNLESS_NODE_T*) node, allocator); break;
|
|
1385
|
+
case AST_RUBY_RENDER_LOCAL_NODE: ast_free_ruby_render_local_node((AST_RUBY_RENDER_LOCAL_NODE_T*) node, allocator); break;
|
|
1386
|
+
case AST_ERB_RENDER_NODE: ast_free_erb_render_node((AST_ERB_RENDER_NODE_T*) node, allocator); break;
|
|
1290
1387
|
case AST_ERB_YIELD_NODE: ast_free_erb_yield_node((AST_ERB_YIELD_NODE_T*) node, allocator); break;
|
|
1291
1388
|
case AST_ERB_IN_NODE: ast_free_erb_in_node((AST_ERB_IN_NODE_T*) node, allocator); break;
|
|
1292
1389
|
}
|
data/src/ast_pretty_print.c
CHANGED
|
@@ -856,6 +856,80 @@ void ast_pretty_print_node(AST_NODE_T* node, const size_t indent, const size_t r
|
|
|
856
856
|
|
|
857
857
|
} break;
|
|
858
858
|
|
|
859
|
+
case AST_RUBY_RENDER_LOCAL_NODE: {
|
|
860
|
+
const AST_RUBY_RENDER_LOCAL_NODE_T* ruby_render_local_node = (AST_RUBY_RENDER_LOCAL_NODE_T*) node;
|
|
861
|
+
|
|
862
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
863
|
+
pretty_print_token_property(ruby_render_local_node->name, hb_string("name"), indent, relative_indent, false, buffer);
|
|
864
|
+
|
|
865
|
+
pretty_print_label(hb_string("value"), indent, relative_indent, true, buffer);
|
|
866
|
+
|
|
867
|
+
if (ruby_render_local_node->value) {
|
|
868
|
+
hb_buffer_append(buffer, "\n");
|
|
869
|
+
pretty_print_indent(buffer, indent);
|
|
870
|
+
pretty_print_indent(buffer, relative_indent + 1);
|
|
871
|
+
|
|
872
|
+
hb_buffer_append(buffer, "└── ");
|
|
873
|
+
ast_pretty_print_node((AST_NODE_T*) ruby_render_local_node->value, indent, relative_indent + 2, buffer);
|
|
874
|
+
} else {
|
|
875
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
876
|
+
}
|
|
877
|
+
hb_buffer_append(buffer, "\n");
|
|
878
|
+
|
|
879
|
+
} break;
|
|
880
|
+
|
|
881
|
+
case AST_ERB_RENDER_NODE: {
|
|
882
|
+
const AST_ERB_RENDER_NODE_T* erb_render_node = (AST_ERB_RENDER_NODE_T*) node;
|
|
883
|
+
|
|
884
|
+
pretty_print_errors(node, indent, relative_indent, false, buffer);
|
|
885
|
+
pretty_print_token_property(erb_render_node->tag_opening, hb_string("tag_opening"), indent, relative_indent, false, buffer);
|
|
886
|
+
pretty_print_token_property(erb_render_node->content, hb_string("content"), indent, relative_indent, false, buffer);
|
|
887
|
+
pretty_print_token_property(erb_render_node->tag_closing, hb_string("tag_closing"), indent, relative_indent, false, buffer);
|
|
888
|
+
if (erb_render_node->analyzed_ruby) {
|
|
889
|
+
pretty_print_boolean_property(hb_string("if_node"), has_if_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
890
|
+
pretty_print_boolean_property(hb_string("elsif_node"), has_elsif_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
891
|
+
pretty_print_boolean_property(hb_string("else_node"), has_else_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
892
|
+
pretty_print_boolean_property(hb_string("end"), has_end(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
893
|
+
pretty_print_boolean_property(hb_string("block_node"), has_block_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
894
|
+
pretty_print_boolean_property(hb_string("block_closing"), has_block_closing(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
895
|
+
pretty_print_boolean_property(hb_string("case_node"), has_case_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
896
|
+
pretty_print_boolean_property(hb_string("when_node"), has_when_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
897
|
+
pretty_print_boolean_property(hb_string("for_node"), has_for_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
898
|
+
pretty_print_boolean_property(hb_string("while_node"), has_while_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
899
|
+
pretty_print_boolean_property(hb_string("until_node"), has_until_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
900
|
+
pretty_print_boolean_property(hb_string("begin_node"), has_begin_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
901
|
+
pretty_print_boolean_property(hb_string("rescue_node"), has_rescue_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
902
|
+
pretty_print_boolean_property(hb_string("ensure_node"), has_ensure_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
903
|
+
pretty_print_boolean_property(hb_string("unless_node"), has_unless_node(erb_render_node->analyzed_ruby), indent, relative_indent, false, buffer);
|
|
904
|
+
} else {
|
|
905
|
+
pretty_print_label(hb_string("analyzed_ruby"), indent, relative_indent, false, buffer);
|
|
906
|
+
hb_buffer_append(buffer, " ∅\n");
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (erb_render_node->prism_node.node != NULL) {
|
|
910
|
+
pretty_print_label(hb_string("prism_node"), indent, relative_indent, false, buffer);
|
|
911
|
+
hb_buffer_append(buffer, " (pm_node_t*)\n");
|
|
912
|
+
}
|
|
913
|
+
pretty_print_token_property(erb_render_node->partial, hb_string("partial"), indent, relative_indent, false, buffer);
|
|
914
|
+
pretty_print_token_property(erb_render_node->template_path, hb_string("template_path"), indent, relative_indent, false, buffer);
|
|
915
|
+
pretty_print_token_property(erb_render_node->layout, hb_string("layout"), indent, relative_indent, false, buffer);
|
|
916
|
+
pretty_print_token_property(erb_render_node->file, hb_string("file"), indent, relative_indent, false, buffer);
|
|
917
|
+
pretty_print_token_property(erb_render_node->inline_template, hb_string("inline_template"), indent, relative_indent, false, buffer);
|
|
918
|
+
pretty_print_token_property(erb_render_node->body, hb_string("body"), indent, relative_indent, false, buffer);
|
|
919
|
+
pretty_print_token_property(erb_render_node->plain, hb_string("plain"), indent, relative_indent, false, buffer);
|
|
920
|
+
pretty_print_token_property(erb_render_node->html, hb_string("html"), indent, relative_indent, false, buffer);
|
|
921
|
+
pretty_print_token_property(erb_render_node->renderable, hb_string("renderable"), indent, relative_indent, false, buffer);
|
|
922
|
+
pretty_print_token_property(erb_render_node->collection, hb_string("collection"), indent, relative_indent, false, buffer);
|
|
923
|
+
pretty_print_token_property(erb_render_node->object, hb_string("object"), indent, relative_indent, false, buffer);
|
|
924
|
+
pretty_print_token_property(erb_render_node->as_name, hb_string("as_name"), indent, relative_indent, false, buffer);
|
|
925
|
+
pretty_print_token_property(erb_render_node->spacer_template, hb_string("spacer_template"), indent, relative_indent, false, buffer);
|
|
926
|
+
pretty_print_token_property(erb_render_node->formats, hb_string("formats"), indent, relative_indent, false, buffer);
|
|
927
|
+
pretty_print_token_property(erb_render_node->variants, hb_string("variants"), indent, relative_indent, false, buffer);
|
|
928
|
+
pretty_print_token_property(erb_render_node->handlers, hb_string("handlers"), indent, relative_indent, false, buffer);
|
|
929
|
+
pretty_print_token_property(erb_render_node->content_type, hb_string("content_type"), indent, relative_indent, false, buffer);
|
|
930
|
+
pretty_print_array(hb_string("locals"), erb_render_node->locals, indent, relative_indent, true, buffer);
|
|
931
|
+
} break;
|
|
932
|
+
|
|
859
933
|
case AST_ERB_YIELD_NODE: {
|
|
860
934
|
const AST_ERB_YIELD_NODE_T* erb_yield_node = (AST_ERB_YIELD_NODE_T*) node;
|
|
861
935
|
|
data/src/errors.c
CHANGED
|
@@ -820,6 +820,215 @@ void append_nested_erb_tag_error(token_T* opening_tag, size_t nested_tag_line, s
|
|
|
820
820
|
hb_array_append(errors, nested_erb_tag_error_init(opening_tag, nested_tag_line, nested_tag_column, start, end, allocator));
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
+
RENDER_AMBIGUOUS_LOCALS_ERROR_T* render_ambiguous_locals_error_init(hb_string_T partial, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
824
|
+
RENDER_AMBIGUOUS_LOCALS_ERROR_T* render_ambiguous_locals_error = hb_allocator_alloc(allocator, sizeof(RENDER_AMBIGUOUS_LOCALS_ERROR_T));
|
|
825
|
+
|
|
826
|
+
if (!render_ambiguous_locals_error) { return NULL; }
|
|
827
|
+
|
|
828
|
+
error_init(&render_ambiguous_locals_error->base, RENDER_AMBIGUOUS_LOCALS_ERROR, start, end);
|
|
829
|
+
|
|
830
|
+
const char* message_template = "Did you mean `render partial: '%s', locals: { ... }`? Using `render '%s', locals: { ... }` passes a local variable named `locals` to the partial instead of setting the `locals:` option.";
|
|
831
|
+
|
|
832
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(partial, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
833
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
834
|
+
|
|
835
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(partial, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
836
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
837
|
+
|
|
838
|
+
char message[442];
|
|
839
|
+
snprintf(
|
|
840
|
+
message,
|
|
841
|
+
sizeof(message),
|
|
842
|
+
message_template,
|
|
843
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
844
|
+
truncated_c_string_1 ? truncated_c_string_1 : ""
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
848
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
849
|
+
render_ambiguous_locals_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
850
|
+
|
|
851
|
+
render_ambiguous_locals_error->partial = hb_string_copy(partial, allocator);
|
|
852
|
+
return render_ambiguous_locals_error;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
void append_render_ambiguous_locals_error(hb_string_T partial, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
856
|
+
hb_array_append(errors, render_ambiguous_locals_error_init(partial, start, end, allocator));
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
RENDER_MISSING_LOCALS_ERROR_T* render_missing_locals_error_init(hb_string_T partial, hb_string_T keywords, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
860
|
+
RENDER_MISSING_LOCALS_ERROR_T* render_missing_locals_error = hb_allocator_alloc(allocator, sizeof(RENDER_MISSING_LOCALS_ERROR_T));
|
|
861
|
+
|
|
862
|
+
if (!render_missing_locals_error) { return NULL; }
|
|
863
|
+
|
|
864
|
+
error_init(&render_missing_locals_error->base, RENDER_MISSING_LOCALS_ERROR, start, end);
|
|
865
|
+
|
|
866
|
+
const char* message_template = "Wrap `%s` in `locals: { ... }` when using `partial:`. Use `render partial: '%s', locals: { %s }` instead. Without `locals:`, these keyword arguments are ignored.";
|
|
867
|
+
|
|
868
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(keywords, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
869
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
870
|
+
|
|
871
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(partial, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
872
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
873
|
+
|
|
874
|
+
hb_string_T truncated_argument_2 = hb_string_truncate(keywords, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
875
|
+
char* truncated_c_string_2 = hb_string_to_c_string_using_malloc(truncated_argument_2);
|
|
876
|
+
|
|
877
|
+
char message[546];
|
|
878
|
+
snprintf(
|
|
879
|
+
message,
|
|
880
|
+
sizeof(message),
|
|
881
|
+
message_template,
|
|
882
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
883
|
+
truncated_c_string_1 ? truncated_c_string_1 : "",
|
|
884
|
+
truncated_c_string_2 ? truncated_c_string_2 : ""
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
888
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
889
|
+
if (truncated_c_string_2) { free(truncated_c_string_2); }
|
|
890
|
+
render_missing_locals_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
891
|
+
|
|
892
|
+
render_missing_locals_error->partial = hb_string_copy(partial, allocator);
|
|
893
|
+
render_missing_locals_error->keywords = hb_string_copy(keywords, allocator);
|
|
894
|
+
return render_missing_locals_error;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
void append_render_missing_locals_error(hb_string_T partial, hb_string_T keywords, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
898
|
+
hb_array_append(errors, render_missing_locals_error_init(partial, keywords, start, end, allocator));
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
RENDER_NO_ARGUMENTS_ERROR_T* render_no_arguments_error_init(position_T start, position_T end, hb_allocator_T* allocator) {
|
|
902
|
+
RENDER_NO_ARGUMENTS_ERROR_T* render_no_arguments_error = hb_allocator_alloc(allocator, sizeof(RENDER_NO_ARGUMENTS_ERROR_T));
|
|
903
|
+
|
|
904
|
+
if (!render_no_arguments_error) { return NULL; }
|
|
905
|
+
|
|
906
|
+
error_init(&render_no_arguments_error->base, RENDER_NO_ARGUMENTS_ERROR, start, end);
|
|
907
|
+
|
|
908
|
+
render_no_arguments_error->base.message = hb_string_copy(hb_string("No arguments passed to `render`. It needs a partial name, a keyword argument like `partial:`, `template:`, or `layout:`, or a renderable object."), allocator);
|
|
909
|
+
|
|
910
|
+
return render_no_arguments_error;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
void append_render_no_arguments_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
914
|
+
hb_array_append(errors, render_no_arguments_error_init(start, end, allocator));
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
RENDER_CONFLICTING_PARTIAL_ERROR_T* render_conflicting_partial_error_init(hb_string_T positional_partial, hb_string_T keyword_partial, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
918
|
+
RENDER_CONFLICTING_PARTIAL_ERROR_T* render_conflicting_partial_error = hb_allocator_alloc(allocator, sizeof(RENDER_CONFLICTING_PARTIAL_ERROR_T));
|
|
919
|
+
|
|
920
|
+
if (!render_conflicting_partial_error) { return NULL; }
|
|
921
|
+
|
|
922
|
+
error_init(&render_conflicting_partial_error->base, RENDER_CONFLICTING_PARTIAL_ERROR, start, end);
|
|
923
|
+
|
|
924
|
+
const char* message_template = "Both a positional partial `'%s'` and a keyword `partial: '%s'` were passed to `render`. Use one form or the other, not both.";
|
|
925
|
+
|
|
926
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(positional_partial, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
927
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
928
|
+
|
|
929
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(keyword_partial, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
930
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
931
|
+
|
|
932
|
+
char message[381];
|
|
933
|
+
snprintf(
|
|
934
|
+
message,
|
|
935
|
+
sizeof(message),
|
|
936
|
+
message_template,
|
|
937
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
938
|
+
truncated_c_string_1 ? truncated_c_string_1 : ""
|
|
939
|
+
);
|
|
940
|
+
|
|
941
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
942
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
943
|
+
render_conflicting_partial_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
944
|
+
|
|
945
|
+
render_conflicting_partial_error->positional_partial = hb_string_copy(positional_partial, allocator);
|
|
946
|
+
render_conflicting_partial_error->keyword_partial = hb_string_copy(keyword_partial, allocator);
|
|
947
|
+
return render_conflicting_partial_error;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
void append_render_conflicting_partial_error(hb_string_T positional_partial, hb_string_T keyword_partial, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
951
|
+
hb_array_append(errors, render_conflicting_partial_error_init(positional_partial, keyword_partial, start, end, allocator));
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
RENDER_INVALID_AS_OPTION_ERROR_T* render_invalid_as_option_error_init(hb_string_T as_value, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
955
|
+
RENDER_INVALID_AS_OPTION_ERROR_T* render_invalid_as_option_error = hb_allocator_alloc(allocator, sizeof(RENDER_INVALID_AS_OPTION_ERROR_T));
|
|
956
|
+
|
|
957
|
+
if (!render_invalid_as_option_error) { return NULL; }
|
|
958
|
+
|
|
959
|
+
error_init(&render_invalid_as_option_error->base, RENDER_INVALID_AS_OPTION_ERROR, start, end);
|
|
960
|
+
|
|
961
|
+
const char* message_template = "The `as:` value `'%s'` is not a valid Ruby identifier. Use a name that starts with a lowercase letter or underscore, like `as: :item`.";
|
|
962
|
+
|
|
963
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(as_value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
964
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
965
|
+
|
|
966
|
+
char message[263];
|
|
967
|
+
snprintf(
|
|
968
|
+
message,
|
|
969
|
+
sizeof(message),
|
|
970
|
+
message_template,
|
|
971
|
+
truncated_c_string_0 ? truncated_c_string_0 : ""
|
|
972
|
+
);
|
|
973
|
+
|
|
974
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
975
|
+
render_invalid_as_option_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
976
|
+
|
|
977
|
+
render_invalid_as_option_error->as_value = hb_string_copy(as_value, allocator);
|
|
978
|
+
return render_invalid_as_option_error;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
void append_render_invalid_as_option_error(hb_string_T as_value, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
982
|
+
hb_array_append(errors, render_invalid_as_option_error_init(as_value, start, end, allocator));
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
RENDER_OBJECT_AND_COLLECTION_ERROR_T* render_object_and_collection_error_init(position_T start, position_T end, hb_allocator_T* allocator) {
|
|
986
|
+
RENDER_OBJECT_AND_COLLECTION_ERROR_T* render_object_and_collection_error = hb_allocator_alloc(allocator, sizeof(RENDER_OBJECT_AND_COLLECTION_ERROR_T));
|
|
987
|
+
|
|
988
|
+
if (!render_object_and_collection_error) { return NULL; }
|
|
989
|
+
|
|
990
|
+
error_init(&render_object_and_collection_error->base, RENDER_OBJECT_AND_COLLECTION_ERROR, start, end);
|
|
991
|
+
|
|
992
|
+
render_object_and_collection_error->base.message = hb_string_copy(hb_string("The `object:` and `collection:` options are mutually exclusive. Use one or the other in your `render` call."), allocator);
|
|
993
|
+
|
|
994
|
+
return render_object_and_collection_error;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
void append_render_object_and_collection_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
998
|
+
hb_array_append(errors, render_object_and_collection_error_init(start, end, allocator));
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* render_layout_without_block_error_init(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
1002
|
+
RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* render_layout_without_block_error = hb_allocator_alloc(allocator, sizeof(RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T));
|
|
1003
|
+
|
|
1004
|
+
if (!render_layout_without_block_error) { return NULL; }
|
|
1005
|
+
|
|
1006
|
+
error_init(&render_layout_without_block_error->base, RENDER_LAYOUT_WITHOUT_BLOCK_ERROR, start, end);
|
|
1007
|
+
|
|
1008
|
+
const char* message_template = "Layout rendering needs a block. Use `render layout: '%s' do ... end` so the layout has content to wrap.";
|
|
1009
|
+
|
|
1010
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(layout, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
1011
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
1012
|
+
|
|
1013
|
+
char message[232];
|
|
1014
|
+
snprintf(
|
|
1015
|
+
message,
|
|
1016
|
+
sizeof(message),
|
|
1017
|
+
message_template,
|
|
1018
|
+
truncated_c_string_0 ? truncated_c_string_0 : ""
|
|
1019
|
+
);
|
|
1020
|
+
|
|
1021
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
1022
|
+
render_layout_without_block_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
1023
|
+
|
|
1024
|
+
render_layout_without_block_error->layout = hb_string_copy(layout, allocator);
|
|
1025
|
+
return render_layout_without_block_error;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
void append_render_layout_without_block_error(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
1029
|
+
hb_array_append(errors, render_layout_without_block_error_init(layout, start, end, allocator));
|
|
1030
|
+
}
|
|
1031
|
+
|
|
823
1032
|
hb_string_T error_type_to_string(ERROR_T* error) {
|
|
824
1033
|
switch (error->type) {
|
|
825
1034
|
case UNEXPECTED_ERROR: return hb_string("UNEXPECTED_ERROR");
|
|
@@ -845,6 +1054,13 @@ hb_string_T error_type_to_string(ERROR_T* error) {
|
|
|
845
1054
|
case UNCLOSED_ERB_TAG_ERROR: return hb_string("UNCLOSED_ERB_TAG_ERROR");
|
|
846
1055
|
case STRAY_ERB_CLOSING_TAG_ERROR: return hb_string("STRAY_ERB_CLOSING_TAG_ERROR");
|
|
847
1056
|
case NESTED_ERB_TAG_ERROR: return hb_string("NESTED_ERB_TAG_ERROR");
|
|
1057
|
+
case RENDER_AMBIGUOUS_LOCALS_ERROR: return hb_string("RENDER_AMBIGUOUS_LOCALS_ERROR");
|
|
1058
|
+
case RENDER_MISSING_LOCALS_ERROR: return hb_string("RENDER_MISSING_LOCALS_ERROR");
|
|
1059
|
+
case RENDER_NO_ARGUMENTS_ERROR: return hb_string("RENDER_NO_ARGUMENTS_ERROR");
|
|
1060
|
+
case RENDER_CONFLICTING_PARTIAL_ERROR: return hb_string("RENDER_CONFLICTING_PARTIAL_ERROR");
|
|
1061
|
+
case RENDER_INVALID_AS_OPTION_ERROR: return hb_string("RENDER_INVALID_AS_OPTION_ERROR");
|
|
1062
|
+
case RENDER_OBJECT_AND_COLLECTION_ERROR: return hb_string("RENDER_OBJECT_AND_COLLECTION_ERROR");
|
|
1063
|
+
case RENDER_LAYOUT_WITHOUT_BLOCK_ERROR: return hb_string("RENDER_LAYOUT_WITHOUT_BLOCK_ERROR");
|
|
848
1064
|
}
|
|
849
1065
|
|
|
850
1066
|
return hb_string("Unknown error_type_T");
|
|
@@ -875,6 +1091,13 @@ hb_string_T error_human_type(ERROR_T* error) {
|
|
|
875
1091
|
case UNCLOSED_ERB_TAG_ERROR: return hb_string("UnclosedERBTagError");
|
|
876
1092
|
case STRAY_ERB_CLOSING_TAG_ERROR: return hb_string("StrayERBClosingTagError");
|
|
877
1093
|
case NESTED_ERB_TAG_ERROR: return hb_string("NestedERBTagError");
|
|
1094
|
+
case RENDER_AMBIGUOUS_LOCALS_ERROR: return hb_string("RenderAmbiguousLocalsError");
|
|
1095
|
+
case RENDER_MISSING_LOCALS_ERROR: return hb_string("RenderMissingLocalsError");
|
|
1096
|
+
case RENDER_NO_ARGUMENTS_ERROR: return hb_string("RenderNoArgumentsError");
|
|
1097
|
+
case RENDER_CONFLICTING_PARTIAL_ERROR: return hb_string("RenderConflictingPartialError");
|
|
1098
|
+
case RENDER_INVALID_AS_OPTION_ERROR: return hb_string("RenderInvalidAsOptionError");
|
|
1099
|
+
case RENDER_OBJECT_AND_COLLECTION_ERROR: return hb_string("RenderObjectAndCollectionError");
|
|
1100
|
+
case RENDER_LAYOUT_WITHOUT_BLOCK_ERROR: return hb_string("RenderLayoutWithoutBlockError");
|
|
878
1101
|
}
|
|
879
1102
|
|
|
880
1103
|
return hb_string("Unknown error_type_T");
|
|
@@ -1044,6 +1267,50 @@ static void error_free_nested_erb_tag_error(NESTED_ERB_TAG_ERROR_T* nested_erb_t
|
|
|
1044
1267
|
error_free_base_error(&nested_erb_tag_error->base, allocator);
|
|
1045
1268
|
}
|
|
1046
1269
|
|
|
1270
|
+
static void error_free_render_ambiguous_locals_error(RENDER_AMBIGUOUS_LOCALS_ERROR_T* render_ambiguous_locals_error, hb_allocator_T* allocator) {
|
|
1271
|
+
if (render_ambiguous_locals_error->partial.data != NULL) { hb_allocator_dealloc(allocator, render_ambiguous_locals_error->partial.data); }
|
|
1272
|
+
|
|
1273
|
+
error_free_base_error(&render_ambiguous_locals_error->base, allocator);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
static void error_free_render_missing_locals_error(RENDER_MISSING_LOCALS_ERROR_T* render_missing_locals_error, hb_allocator_T* allocator) {
|
|
1277
|
+
if (render_missing_locals_error->partial.data != NULL) { hb_allocator_dealloc(allocator, render_missing_locals_error->partial.data); }
|
|
1278
|
+
if (render_missing_locals_error->keywords.data != NULL) { hb_allocator_dealloc(allocator, render_missing_locals_error->keywords.data); }
|
|
1279
|
+
|
|
1280
|
+
error_free_base_error(&render_missing_locals_error->base, allocator);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
static void error_free_render_no_arguments_error(RENDER_NO_ARGUMENTS_ERROR_T* render_no_arguments_error, hb_allocator_T* allocator) {
|
|
1284
|
+
/* no RENDER_NO_ARGUMENTS_ERROR_T specific fields to free up */
|
|
1285
|
+
|
|
1286
|
+
error_free_base_error(&render_no_arguments_error->base, allocator);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
static void error_free_render_conflicting_partial_error(RENDER_CONFLICTING_PARTIAL_ERROR_T* render_conflicting_partial_error, hb_allocator_T* allocator) {
|
|
1290
|
+
if (render_conflicting_partial_error->positional_partial.data != NULL) { hb_allocator_dealloc(allocator, render_conflicting_partial_error->positional_partial.data); }
|
|
1291
|
+
if (render_conflicting_partial_error->keyword_partial.data != NULL) { hb_allocator_dealloc(allocator, render_conflicting_partial_error->keyword_partial.data); }
|
|
1292
|
+
|
|
1293
|
+
error_free_base_error(&render_conflicting_partial_error->base, allocator);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
static void error_free_render_invalid_as_option_error(RENDER_INVALID_AS_OPTION_ERROR_T* render_invalid_as_option_error, hb_allocator_T* allocator) {
|
|
1297
|
+
if (render_invalid_as_option_error->as_value.data != NULL) { hb_allocator_dealloc(allocator, render_invalid_as_option_error->as_value.data); }
|
|
1298
|
+
|
|
1299
|
+
error_free_base_error(&render_invalid_as_option_error->base, allocator);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
static void error_free_render_object_and_collection_error(RENDER_OBJECT_AND_COLLECTION_ERROR_T* render_object_and_collection_error, hb_allocator_T* allocator) {
|
|
1303
|
+
/* no RENDER_OBJECT_AND_COLLECTION_ERROR_T specific fields to free up */
|
|
1304
|
+
|
|
1305
|
+
error_free_base_error(&render_object_and_collection_error->base, allocator);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
static void error_free_render_layout_without_block_error(RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* render_layout_without_block_error, hb_allocator_T* allocator) {
|
|
1309
|
+
if (render_layout_without_block_error->layout.data != NULL) { hb_allocator_dealloc(allocator, render_layout_without_block_error->layout.data); }
|
|
1310
|
+
|
|
1311
|
+
error_free_base_error(&render_layout_without_block_error->base, allocator);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1047
1314
|
void error_free(ERROR_T* error, hb_allocator_T* allocator) {
|
|
1048
1315
|
if (!error) { return; }
|
|
1049
1316
|
|
|
@@ -1071,6 +1338,13 @@ void error_free(ERROR_T* error, hb_allocator_T* allocator) {
|
|
|
1071
1338
|
case UNCLOSED_ERB_TAG_ERROR: error_free_unclosed_erb_tag_error((UNCLOSED_ERB_TAG_ERROR_T*) error, allocator); break;
|
|
1072
1339
|
case STRAY_ERB_CLOSING_TAG_ERROR: error_free_stray_erb_closing_tag_error((STRAY_ERB_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
1073
1340
|
case NESTED_ERB_TAG_ERROR: error_free_nested_erb_tag_error((NESTED_ERB_TAG_ERROR_T*) error, allocator); break;
|
|
1341
|
+
case RENDER_AMBIGUOUS_LOCALS_ERROR: error_free_render_ambiguous_locals_error((RENDER_AMBIGUOUS_LOCALS_ERROR_T*) error, allocator); break;
|
|
1342
|
+
case RENDER_MISSING_LOCALS_ERROR: error_free_render_missing_locals_error((RENDER_MISSING_LOCALS_ERROR_T*) error, allocator); break;
|
|
1343
|
+
case RENDER_NO_ARGUMENTS_ERROR: error_free_render_no_arguments_error((RENDER_NO_ARGUMENTS_ERROR_T*) error, allocator); break;
|
|
1344
|
+
case RENDER_CONFLICTING_PARTIAL_ERROR: error_free_render_conflicting_partial_error((RENDER_CONFLICTING_PARTIAL_ERROR_T*) error, allocator); break;
|
|
1345
|
+
case RENDER_INVALID_AS_OPTION_ERROR: error_free_render_invalid_as_option_error((RENDER_INVALID_AS_OPTION_ERROR_T*) error, allocator); break;
|
|
1346
|
+
case RENDER_OBJECT_AND_COLLECTION_ERROR: error_free_render_object_and_collection_error((RENDER_OBJECT_AND_COLLECTION_ERROR_T*) error, allocator); break;
|
|
1347
|
+
case RENDER_LAYOUT_WITHOUT_BLOCK_ERROR: error_free_render_layout_without_block_error((RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T*) error, allocator); break;
|
|
1074
1348
|
}
|
|
1075
1349
|
}
|
|
1076
1350
|
|
|
@@ -1457,6 +1731,104 @@ static void error_pretty_print_nested_erb_tag_error(NESTED_ERB_TAG_ERROR_T* erro
|
|
|
1457
1731
|
pretty_print_size_t_property(error->nested_tag_column, hb_string("nested_tag_column"), indent, relative_indent, true, buffer);
|
|
1458
1732
|
}
|
|
1459
1733
|
|
|
1734
|
+
static void error_pretty_print_render_ambiguous_locals_error(RENDER_AMBIGUOUS_LOCALS_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1735
|
+
if (!error) { return; }
|
|
1736
|
+
|
|
1737
|
+
hb_buffer_append(buffer, "@ ");
|
|
1738
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1739
|
+
hb_buffer_append(buffer, " ");
|
|
1740
|
+
|
|
1741
|
+
pretty_print_location(error->base.location, buffer);
|
|
1742
|
+
hb_buffer_append(buffer, "\n");
|
|
1743
|
+
|
|
1744
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1745
|
+
pretty_print_quoted_property(hb_string("partial"), error->partial, indent, relative_indent, true, buffer);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
static void error_pretty_print_render_missing_locals_error(RENDER_MISSING_LOCALS_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1749
|
+
if (!error) { return; }
|
|
1750
|
+
|
|
1751
|
+
hb_buffer_append(buffer, "@ ");
|
|
1752
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1753
|
+
hb_buffer_append(buffer, " ");
|
|
1754
|
+
|
|
1755
|
+
pretty_print_location(error->base.location, buffer);
|
|
1756
|
+
hb_buffer_append(buffer, "\n");
|
|
1757
|
+
|
|
1758
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1759
|
+
pretty_print_quoted_property(hb_string("partial"), error->partial, indent, relative_indent, false, buffer);
|
|
1760
|
+
pretty_print_quoted_property(hb_string("keywords"), error->keywords, indent, relative_indent, true, buffer);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
static void error_pretty_print_render_no_arguments_error(RENDER_NO_ARGUMENTS_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1764
|
+
if (!error) { return; }
|
|
1765
|
+
|
|
1766
|
+
hb_buffer_append(buffer, "@ ");
|
|
1767
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1768
|
+
hb_buffer_append(buffer, " ");
|
|
1769
|
+
|
|
1770
|
+
pretty_print_location(error->base.location, buffer);
|
|
1771
|
+
hb_buffer_append(buffer, "\n");
|
|
1772
|
+
|
|
1773
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, true, buffer);
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
static void error_pretty_print_render_conflicting_partial_error(RENDER_CONFLICTING_PARTIAL_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1777
|
+
if (!error) { return; }
|
|
1778
|
+
|
|
1779
|
+
hb_buffer_append(buffer, "@ ");
|
|
1780
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1781
|
+
hb_buffer_append(buffer, " ");
|
|
1782
|
+
|
|
1783
|
+
pretty_print_location(error->base.location, buffer);
|
|
1784
|
+
hb_buffer_append(buffer, "\n");
|
|
1785
|
+
|
|
1786
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1787
|
+
pretty_print_quoted_property(hb_string("positional_partial"), error->positional_partial, indent, relative_indent, false, buffer);
|
|
1788
|
+
pretty_print_quoted_property(hb_string("keyword_partial"), error->keyword_partial, indent, relative_indent, true, buffer);
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
static void error_pretty_print_render_invalid_as_option_error(RENDER_INVALID_AS_OPTION_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1792
|
+
if (!error) { return; }
|
|
1793
|
+
|
|
1794
|
+
hb_buffer_append(buffer, "@ ");
|
|
1795
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1796
|
+
hb_buffer_append(buffer, " ");
|
|
1797
|
+
|
|
1798
|
+
pretty_print_location(error->base.location, buffer);
|
|
1799
|
+
hb_buffer_append(buffer, "\n");
|
|
1800
|
+
|
|
1801
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1802
|
+
pretty_print_quoted_property(hb_string("as_value"), error->as_value, indent, relative_indent, true, buffer);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
static void error_pretty_print_render_object_and_collection_error(RENDER_OBJECT_AND_COLLECTION_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1806
|
+
if (!error) { return; }
|
|
1807
|
+
|
|
1808
|
+
hb_buffer_append(buffer, "@ ");
|
|
1809
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1810
|
+
hb_buffer_append(buffer, " ");
|
|
1811
|
+
|
|
1812
|
+
pretty_print_location(error->base.location, buffer);
|
|
1813
|
+
hb_buffer_append(buffer, "\n");
|
|
1814
|
+
|
|
1815
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, true, buffer);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
static void error_pretty_print_render_layout_without_block_error(RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1819
|
+
if (!error) { return; }
|
|
1820
|
+
|
|
1821
|
+
hb_buffer_append(buffer, "@ ");
|
|
1822
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1823
|
+
hb_buffer_append(buffer, " ");
|
|
1824
|
+
|
|
1825
|
+
pretty_print_location(error->base.location, buffer);
|
|
1826
|
+
hb_buffer_append(buffer, "\n");
|
|
1827
|
+
|
|
1828
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1829
|
+
pretty_print_quoted_property(hb_string("layout"), error->layout, indent, relative_indent, true, buffer);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1460
1832
|
void error_pretty_print(ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1461
1833
|
if (!error) { return; }
|
|
1462
1834
|
|
|
@@ -1484,6 +1856,13 @@ void error_pretty_print(ERROR_T* error, const size_t indent, const size_t relati
|
|
|
1484
1856
|
case UNCLOSED_ERB_TAG_ERROR: error_pretty_print_unclosed_erb_tag_error((UNCLOSED_ERB_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1485
1857
|
case STRAY_ERB_CLOSING_TAG_ERROR: error_pretty_print_stray_erb_closing_tag_error((STRAY_ERB_CLOSING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1486
1858
|
case NESTED_ERB_TAG_ERROR: error_pretty_print_nested_erb_tag_error((NESTED_ERB_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1859
|
+
case RENDER_AMBIGUOUS_LOCALS_ERROR: error_pretty_print_render_ambiguous_locals_error((RENDER_AMBIGUOUS_LOCALS_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1860
|
+
case RENDER_MISSING_LOCALS_ERROR: error_pretty_print_render_missing_locals_error((RENDER_MISSING_LOCALS_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1861
|
+
case RENDER_NO_ARGUMENTS_ERROR: error_pretty_print_render_no_arguments_error((RENDER_NO_ARGUMENTS_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1862
|
+
case RENDER_CONFLICTING_PARTIAL_ERROR: error_pretty_print_render_conflicting_partial_error((RENDER_CONFLICTING_PARTIAL_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1863
|
+
case RENDER_INVALID_AS_OPTION_ERROR: error_pretty_print_render_invalid_as_option_error((RENDER_INVALID_AS_OPTION_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1864
|
+
case RENDER_OBJECT_AND_COLLECTION_ERROR: error_pretty_print_render_object_and_collection_error((RENDER_OBJECT_AND_COLLECTION_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1865
|
+
case RENDER_LAYOUT_WITHOUT_BLOCK_ERROR: error_pretty_print_render_layout_without_block_error((RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1487
1866
|
}
|
|
1488
1867
|
}
|
|
1489
1868
|
|