herb 0.8.3-x86_64-linux-musl → 0.8.4-x86_64-linux-musl
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/ext/herb/error_helpers.c +1 -1
- data/ext/herb/extension_helpers.c +1 -1
- data/ext/herb/nodes.c +2 -2
- 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/engine/debug_visitor.rb +24 -1
- data/lib/herb/version.rb +1 -1
- data/sig/herb/engine/debug_visitor.rbs +5 -0
- data/src/analyze.c +27 -27
- data/src/ast_node.c +1 -1
- data/src/ast_nodes.c +157 -53
- data/src/errors.c +5 -5
- data/src/extract.c +2 -2
- data/src/herb.c +2 -2
- data/src/include/version.h +1 -1
- data/src/parser.c +6 -6
- data/src/parser_helpers.c +4 -4
- data/src/pretty_print.c +6 -6
- data/src/visitor.c +26 -26
- data/templates/ext/herb/error_helpers.c.erb +1 -1
- data/templates/ext/herb/nodes.c.erb +1 -1
- data/templates/java/error_helpers.c.erb +1 -1
- data/templates/java/nodes.c.erb +2 -2
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +1 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +1 -1
- data/templates/rust/src/ast/nodes.rs.erb +2 -2
- data/templates/src/ast_nodes.c.erb +7 -3
- data/templates/src/errors.c.erb +5 -5
- data/templates/src/visitor.c.erb +1 -1
- data/templates/wasm/error_helpers.cpp.erb +1 -1
- data/templates/wasm/nodes.cpp.erb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 894a1b1eb2fa62a37d7d04354611dad5075b6abadd173dfa363dd3f32661a35a
|
|
4
|
+
data.tar.gz: '082ffba5c4d3a007ae0fad9c17a6ea70df576b6fddee4277333d6eea345e0d70'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 624d138af5d7da7393aeee55146fc76446193ebd0fcb48407042bce9bf700ba28a81ca7cf512df09d6501837df77e455f6cc5d39adf0759ff628a7baf3255225
|
|
7
|
+
data.tar.gz: c01d35421dce99d3fedfb49eecad2f1f51af3d3be7869fdfa34ada43ff95bec32e41d27cd0b130a3bedd8e83b57dafc74754dad4541c596389a3c49585eb67f7
|
data/ext/herb/error_helpers.c
CHANGED
|
@@ -342,7 +342,7 @@ VALUE rb_errors_array_from_c_array(hb_array_T* array) {
|
|
|
342
342
|
VALUE rb_array = rb_ary_new();
|
|
343
343
|
|
|
344
344
|
if (array) {
|
|
345
|
-
for (size_t i = 0; i <
|
|
345
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
346
346
|
ERROR_T* child_node = (ERROR_T*) hb_array_get(array, i);
|
|
347
347
|
|
|
348
348
|
if (child_node) {
|
|
@@ -63,7 +63,7 @@ VALUE create_lex_result(hb_array_T* tokens, VALUE source) {
|
|
|
63
63
|
VALUE warnings = rb_ary_new();
|
|
64
64
|
VALUE errors = rb_ary_new();
|
|
65
65
|
|
|
66
|
-
for (size_t i = 0; i <
|
|
66
|
+
for (size_t i = 0; i < tokens->size; i++) {
|
|
67
67
|
token_T* token = hb_array_get(tokens, i);
|
|
68
68
|
if (token != NULL) { rb_ary_push(value, rb_token_from_c_struct(token)); }
|
|
69
69
|
}
|
data/ext/herb/nodes.c
CHANGED
|
@@ -464,7 +464,7 @@ static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_conte
|
|
|
464
464
|
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
|
465
465
|
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
|
466
466
|
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
|
467
|
-
/* #<Herb::Template::AnalyzedRubyField:
|
|
467
|
+
/* #<Herb::Template::AnalyzedRubyField:0x00007f4bf6394088 @name="analyzed_ruby", @options={kind: nil}> */
|
|
468
468
|
VALUE erb_content_node_analyzed_ruby = Qnil;
|
|
469
469
|
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
|
470
470
|
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
|
@@ -1091,7 +1091,7 @@ static VALUE rb_nodes_array_from_c_array(hb_array_T* array) {
|
|
|
1091
1091
|
VALUE rb_array = rb_ary_new();
|
|
1092
1092
|
|
|
1093
1093
|
if (array) {
|
|
1094
|
-
for (size_t i = 0; i <
|
|
1094
|
+
for (size_t i = 0; i < array->size; i++) {
|
|
1095
1095
|
AST_NODE_T* child_node = (AST_NODE_T*) hb_array_get(array, i);
|
|
1096
1096
|
|
|
1097
1097
|
if (child_node) {
|
data/lib/herb/3.0/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.1/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.2/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.3/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.4/herb.so
CHANGED
|
Binary file
|
|
@@ -25,6 +25,7 @@ module Herb
|
|
|
25
25
|
@relative_file_path = calculate_relative_path
|
|
26
26
|
@top_level_elements = [] #: Array[Herb::AST::HTMLElementNode]
|
|
27
27
|
@element_stack = [] #: Array[String]
|
|
28
|
+
@erb_block_stack = [] #: Array[Herb::AST::ERBBlockNode]
|
|
28
29
|
@debug_attributes_applied = false
|
|
29
30
|
@in_attribute = false
|
|
30
31
|
@in_html_comment = false
|
|
@@ -83,6 +84,12 @@ module Herb
|
|
|
83
84
|
nil
|
|
84
85
|
end
|
|
85
86
|
|
|
87
|
+
def visit_erb_block_node(node)
|
|
88
|
+
@erb_block_stack.push(node)
|
|
89
|
+
super
|
|
90
|
+
@erb_block_stack.pop
|
|
91
|
+
end
|
|
92
|
+
|
|
86
93
|
private
|
|
87
94
|
|
|
88
95
|
def calculate_relative_path
|
|
@@ -295,7 +302,11 @@ module Herb
|
|
|
295
302
|
|
|
296
303
|
def in_excluded_context?
|
|
297
304
|
excluded_tags = ["script", "style", "head", "textarea", "pre"]
|
|
298
|
-
excluded_tags.any? { |tag| @element_stack.include?(tag) }
|
|
305
|
+
return true if excluded_tags.any? { |tag| @element_stack.include?(tag) }
|
|
306
|
+
|
|
307
|
+
return true if @erb_block_stack.any? { |node| javascript_tag?(node.content.value.strip) }
|
|
308
|
+
|
|
309
|
+
false
|
|
299
310
|
end
|
|
300
311
|
|
|
301
312
|
def erb_output?(opening)
|
|
@@ -332,6 +343,18 @@ module Herb
|
|
|
332
343
|
|
|
333
344
|
false
|
|
334
345
|
end
|
|
346
|
+
|
|
347
|
+
# TODO: Rewrite using Prism Nodes once available
|
|
348
|
+
def javascript_tag?(code)
|
|
349
|
+
cleaned_code = code.strip.gsub(/\s+/, " ")
|
|
350
|
+
|
|
351
|
+
return true if cleaned_code.match?(/\bjavascript_tag\s.*do\s*$/) ||
|
|
352
|
+
cleaned_code.match?(/\bjavascript_tag\s.*\{\s*$/) ||
|
|
353
|
+
cleaned_code.match?(/\bjavascript_tag\(.*do\s*$/) ||
|
|
354
|
+
cleaned_code.match?(/\bjavascript_tag\(.*\{\s*$/)
|
|
355
|
+
|
|
356
|
+
false
|
|
357
|
+
end
|
|
335
358
|
end
|
|
336
359
|
end
|
|
337
360
|
end
|
data/lib/herb/version.rb
CHANGED
|
@@ -19,6 +19,8 @@ module Herb
|
|
|
19
19
|
|
|
20
20
|
def visit_erb_yield_node: (untyped _node) -> untyped
|
|
21
21
|
|
|
22
|
+
def visit_erb_block_node: (untyped node) -> untyped
|
|
23
|
+
|
|
22
24
|
private
|
|
23
25
|
|
|
24
26
|
def calculate_relative_path: () -> untyped
|
|
@@ -65,6 +67,9 @@ module Herb
|
|
|
65
67
|
|
|
66
68
|
# TODO: Rewrite using Prism Nodes once available
|
|
67
69
|
def complex_rails_helper?: (untyped code) -> untyped
|
|
70
|
+
|
|
71
|
+
# TODO: Rewrite using Prism Nodes once available
|
|
72
|
+
def javascript_tag?: (untyped code) -> untyped
|
|
68
73
|
end
|
|
69
74
|
end
|
|
70
75
|
end
|
data/src/analyze.c
CHANGED
|
@@ -287,7 +287,7 @@ static AST_NODE_T* create_control_node(
|
|
|
287
287
|
|
|
288
288
|
if (end_node) {
|
|
289
289
|
end_position = end_node->base.location.end;
|
|
290
|
-
} else if (children &&
|
|
290
|
+
} else if (children && children->size > 0) {
|
|
291
291
|
AST_NODE_T* last_child = hb_array_last(children);
|
|
292
292
|
end_position = last_child->location.end;
|
|
293
293
|
} else if (subsequent) {
|
|
@@ -329,7 +329,7 @@ static AST_NODE_T* create_control_node(
|
|
|
329
329
|
hb_array_T* in_conditions = hb_array_init(8);
|
|
330
330
|
hb_array_T* non_when_non_in_children = hb_array_init(8);
|
|
331
331
|
|
|
332
|
-
for (size_t i = 0; i <
|
|
332
|
+
for (size_t i = 0; i < children->size; i++) {
|
|
333
333
|
AST_NODE_T* child = hb_array_get(children, i);
|
|
334
334
|
|
|
335
335
|
if (child && child->type == AST_ERB_WHEN_NODE) {
|
|
@@ -343,7 +343,7 @@ static AST_NODE_T* create_control_node(
|
|
|
343
343
|
|
|
344
344
|
hb_array_free(&children);
|
|
345
345
|
|
|
346
|
-
if (
|
|
346
|
+
if (in_conditions->size > 0) {
|
|
347
347
|
hb_array_free(&when_conditions);
|
|
348
348
|
|
|
349
349
|
return (AST_NODE_T*) ast_erb_case_match_node_init(
|
|
@@ -539,7 +539,7 @@ static size_t process_control_structure(
|
|
|
539
539
|
hb_array_T* in_conditions = hb_array_init(8);
|
|
540
540
|
hb_array_T* non_when_non_in_children = hb_array_init(8);
|
|
541
541
|
|
|
542
|
-
while (index <
|
|
542
|
+
while (index < array->size) {
|
|
543
543
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
544
544
|
|
|
545
545
|
if (!next_node) { break; }
|
|
@@ -555,7 +555,7 @@ static size_t process_control_structure(
|
|
|
555
555
|
index++;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
while (index <
|
|
558
|
+
while (index < array->size) {
|
|
559
559
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
560
560
|
|
|
561
561
|
if (!next_node) { break; }
|
|
@@ -627,7 +627,7 @@ static size_t process_control_structure(
|
|
|
627
627
|
|
|
628
628
|
AST_ERB_ELSE_NODE_T* else_clause = NULL;
|
|
629
629
|
|
|
630
|
-
if (index <
|
|
630
|
+
if (index < array->size) {
|
|
631
631
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
632
632
|
|
|
633
633
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -661,7 +661,7 @@ static size_t process_control_structure(
|
|
|
661
661
|
|
|
662
662
|
AST_ERB_END_NODE_T* end_node = NULL;
|
|
663
663
|
|
|
664
|
-
if (index <
|
|
664
|
+
if (index < array->size) {
|
|
665
665
|
AST_NODE_T* potential_end = hb_array_get(array, index);
|
|
666
666
|
|
|
667
667
|
if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -694,15 +694,15 @@ static size_t process_control_structure(
|
|
|
694
694
|
end_position = end_node->base.location.end;
|
|
695
695
|
} else if (else_clause) {
|
|
696
696
|
end_position = else_clause->base.location.end;
|
|
697
|
-
} else if (
|
|
697
|
+
} else if (when_conditions->size > 0) {
|
|
698
698
|
AST_NODE_T* last_when = hb_array_last(when_conditions);
|
|
699
699
|
end_position = last_when->location.end;
|
|
700
|
-
} else if (
|
|
700
|
+
} else if (in_conditions->size > 0) {
|
|
701
701
|
AST_NODE_T* last_in = hb_array_last(in_conditions);
|
|
702
702
|
end_position = last_in->location.end;
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
-
if (
|
|
705
|
+
if (in_conditions->size > 0) {
|
|
706
706
|
hb_array_T* case_match_errors = erb_node->base.errors;
|
|
707
707
|
erb_node->base.errors = NULL;
|
|
708
708
|
|
|
@@ -760,7 +760,7 @@ static size_t process_control_structure(
|
|
|
760
760
|
AST_ERB_ELSE_NODE_T* else_clause = NULL;
|
|
761
761
|
AST_ERB_ENSURE_NODE_T* ensure_clause = NULL;
|
|
762
762
|
|
|
763
|
-
if (index <
|
|
763
|
+
if (index < array->size) {
|
|
764
764
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
765
765
|
|
|
766
766
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -775,7 +775,7 @@ static size_t process_control_structure(
|
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
|
|
778
|
-
if (index <
|
|
778
|
+
if (index < array->size) {
|
|
779
779
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
780
780
|
|
|
781
781
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -807,7 +807,7 @@ static size_t process_control_structure(
|
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
|
|
810
|
-
if (index <
|
|
810
|
+
if (index < array->size) {
|
|
811
811
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
812
812
|
|
|
813
813
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -819,7 +819,7 @@ static size_t process_control_structure(
|
|
|
819
819
|
|
|
820
820
|
index++;
|
|
821
821
|
|
|
822
|
-
while (index <
|
|
822
|
+
while (index < array->size) {
|
|
823
823
|
AST_NODE_T* child = hb_array_get(array, index);
|
|
824
824
|
|
|
825
825
|
if (!child) { break; }
|
|
@@ -855,7 +855,7 @@ static size_t process_control_structure(
|
|
|
855
855
|
|
|
856
856
|
AST_ERB_END_NODE_T* end_node = NULL;
|
|
857
857
|
|
|
858
|
-
if (index <
|
|
858
|
+
if (index < array->size) {
|
|
859
859
|
AST_NODE_T* potential_end = hb_array_get(array, index);
|
|
860
860
|
|
|
861
861
|
if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -922,7 +922,7 @@ static size_t process_control_structure(
|
|
|
922
922
|
|
|
923
923
|
AST_ERB_END_NODE_T* end_node = NULL;
|
|
924
924
|
|
|
925
|
-
if (index <
|
|
925
|
+
if (index < array->size) {
|
|
926
926
|
AST_NODE_T* potential_close = hb_array_get(array, index);
|
|
927
927
|
|
|
928
928
|
if (potential_close && potential_close->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -954,7 +954,7 @@ static size_t process_control_structure(
|
|
|
954
954
|
|
|
955
955
|
if (end_node) {
|
|
956
956
|
end_position = end_node->base.location.end;
|
|
957
|
-
} else if (children &&
|
|
957
|
+
} else if (children && children->size > 0) {
|
|
958
958
|
AST_NODE_T* last_child = hb_array_last(children);
|
|
959
959
|
end_position = last_child->location.end;
|
|
960
960
|
}
|
|
@@ -984,7 +984,7 @@ static size_t process_control_structure(
|
|
|
984
984
|
AST_NODE_T* subsequent = NULL;
|
|
985
985
|
AST_ERB_END_NODE_T* end_node = NULL;
|
|
986
986
|
|
|
987
|
-
if (index <
|
|
987
|
+
if (index < array->size) {
|
|
988
988
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
989
989
|
|
|
990
990
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -997,7 +997,7 @@ static size_t process_control_structure(
|
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
|
-
if (index <
|
|
1000
|
+
if (index < array->size) {
|
|
1001
1001
|
AST_NODE_T* potential_end = hb_array_get(array, index);
|
|
1002
1002
|
|
|
1003
1003
|
if (potential_end && potential_end->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -1059,7 +1059,7 @@ static size_t process_subsequent_block(
|
|
|
1059
1059
|
hb_array_free(&children);
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
|
-
if (index <
|
|
1062
|
+
if (index < array->size) {
|
|
1063
1063
|
AST_NODE_T* next_node = hb_array_get(array, index);
|
|
1064
1064
|
|
|
1065
1065
|
if (next_node && next_node->type == AST_ERB_CONTENT_NODE) {
|
|
@@ -1117,7 +1117,7 @@ static size_t process_block_children(
|
|
|
1117
1117
|
analyze_ruby_context_T* context,
|
|
1118
1118
|
control_type_t parent_type
|
|
1119
1119
|
) {
|
|
1120
|
-
while (index <
|
|
1120
|
+
while (index < array->size) {
|
|
1121
1121
|
AST_NODE_T* child = hb_array_get(array, index);
|
|
1122
1122
|
|
|
1123
1123
|
if (!child) { break; }
|
|
@@ -1139,7 +1139,7 @@ static size_t process_block_children(
|
|
|
1139
1139
|
hb_array_T* temp_array = hb_array_init(1);
|
|
1140
1140
|
size_t new_index = process_control_structure(node, array, index, temp_array, context, child_type);
|
|
1141
1141
|
|
|
1142
|
-
if (
|
|
1142
|
+
if (temp_array->size > 0) { hb_array_append(children_array, hb_array_first(temp_array)); }
|
|
1143
1143
|
|
|
1144
1144
|
hb_array_free(&temp_array);
|
|
1145
1145
|
|
|
@@ -1155,10 +1155,10 @@ static size_t process_block_children(
|
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
1157
|
hb_array_T* rewrite_node_array(AST_NODE_T* node, hb_array_T* array, analyze_ruby_context_T* context) {
|
|
1158
|
-
hb_array_T* new_array = hb_array_init(
|
|
1158
|
+
hb_array_T* new_array = hb_array_init(array->size);
|
|
1159
1159
|
size_t index = 0;
|
|
1160
1160
|
|
|
1161
|
-
while (index <
|
|
1161
|
+
while (index < array->size) {
|
|
1162
1162
|
AST_NODE_T* item = hb_array_get(array, index);
|
|
1163
1163
|
|
|
1164
1164
|
if (!item) { break; }
|
|
@@ -1293,7 +1293,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
|
|
|
1293
1293
|
if (if_node->end_node == NULL) { check_erb_node_for_missing_end(node); }
|
|
1294
1294
|
|
|
1295
1295
|
if (if_node->statements != NULL) {
|
|
1296
|
-
for (size_t i = 0; i <
|
|
1296
|
+
for (size_t i = 0; i < if_node->statements->size; i++) {
|
|
1297
1297
|
AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(if_node->statements, i);
|
|
1298
1298
|
|
|
1299
1299
|
if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
|
|
@@ -1325,7 +1325,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
|
|
|
1325
1325
|
const AST_ERB_IF_NODE_T* elsif_node = (const AST_ERB_IF_NODE_T*) subsequent;
|
|
1326
1326
|
|
|
1327
1327
|
if (elsif_node->statements != NULL) {
|
|
1328
|
-
for (size_t i = 0; i <
|
|
1328
|
+
for (size_t i = 0; i < elsif_node->statements->size; i++) {
|
|
1329
1329
|
AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(elsif_node->statements, i);
|
|
1330
1330
|
|
|
1331
1331
|
if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
|
|
@@ -1337,7 +1337,7 @@ static bool detect_invalid_erb_structures(const AST_NODE_T* node, void* data) {
|
|
|
1337
1337
|
const AST_ERB_ELSE_NODE_T* else_node = (const AST_ERB_ELSE_NODE_T*) subsequent;
|
|
1338
1338
|
|
|
1339
1339
|
if (else_node->statements != NULL) {
|
|
1340
|
-
for (size_t i = 0; i <
|
|
1340
|
+
for (size_t i = 0; i < else_node->statements->size; i++) {
|
|
1341
1341
|
AST_NODE_T* statement = (AST_NODE_T*) hb_array_get(else_node->statements, i);
|
|
1342
1342
|
|
|
1343
1343
|
if (statement != NULL) { herb_visit_node(statement, detect_invalid_erb_structures, context); }
|
data/src/ast_node.c
CHANGED