@herb-tools/node 0.8.10 → 0.9.1
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.
- package/binding.gyp +27 -8
- package/dist/herb-node.cjs +41 -12
- package/dist/herb-node.cjs.map +1 -1
- package/dist/herb-node.esm.js +8 -1
- package/dist/herb-node.esm.js.map +1 -1
- package/dist/types/node-backend.d.ts +3 -1
- package/extension/error_helpers.cpp +598 -73
- package/extension/error_helpers.h +20 -3
- package/extension/extension_helpers.cpp +40 -35
- package/extension/extension_helpers.h +2 -2
- package/extension/herb.cpp +194 -64
- package/extension/libherb/analyze/action_view/attribute_extraction_helpers.c +303 -0
- package/extension/libherb/analyze/action_view/attribute_extraction_helpers.h +36 -0
- package/extension/libherb/analyze/action_view/content_tag.c +78 -0
- package/extension/libherb/analyze/action_view/link_to.c +167 -0
- package/extension/libherb/analyze/action_view/registry.c +83 -0
- package/extension/libherb/analyze/action_view/tag.c +70 -0
- package/extension/libherb/analyze/action_view/tag_helper_handler.h +43 -0
- package/extension/libherb/analyze/action_view/tag_helper_node_builders.c +305 -0
- package/extension/libherb/analyze/action_view/tag_helper_node_builders.h +70 -0
- package/extension/libherb/analyze/action_view/tag_helpers.c +815 -0
- package/extension/libherb/analyze/action_view/tag_helpers.h +38 -0
- package/extension/libherb/analyze/action_view/turbo_frame_tag.c +88 -0
- package/extension/libherb/analyze/analyze.c +885 -0
- package/extension/libherb/{include → analyze}/analyze.h +14 -4
- package/extension/libherb/{analyzed_ruby.c → analyze/analyzed_ruby.c} +13 -11
- package/extension/libherb/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
- package/extension/libherb/analyze/builders.c +343 -0
- package/extension/libherb/analyze/builders.h +27 -0
- package/extension/libherb/analyze/conditional_elements.c +594 -0
- package/extension/libherb/analyze/conditional_elements.h +9 -0
- package/extension/libherb/analyze/conditional_open_tags.c +640 -0
- package/extension/libherb/analyze/conditional_open_tags.h +9 -0
- package/extension/libherb/analyze/control_type.c +250 -0
- package/extension/libherb/analyze/control_type.h +14 -0
- package/extension/libherb/{analyze_helpers.c → analyze/helpers.c} +48 -23
- package/extension/libherb/{analyze_helpers.h → analyze/helpers.h} +4 -2
- package/extension/libherb/analyze/invalid_structures.c +193 -0
- package/extension/libherb/analyze/invalid_structures.h +11 -0
- package/extension/libherb/{analyze_missing_end.c → analyze/missing_end.c} +33 -22
- package/extension/libherb/analyze/parse_errors.c +84 -0
- package/extension/libherb/analyze/prism_annotate.c +399 -0
- package/extension/libherb/analyze/prism_annotate.h +16 -0
- package/extension/libherb/analyze/render_nodes.c +761 -0
- package/extension/libherb/analyze/render_nodes.h +11 -0
- package/extension/libherb/{analyze_transform.c → analyze/transform.c} +24 -3
- package/extension/libherb/ast_node.c +17 -7
- package/extension/libherb/ast_node.h +11 -5
- package/extension/libherb/ast_nodes.c +760 -388
- package/extension/libherb/ast_nodes.h +155 -39
- package/extension/libherb/ast_pretty_print.c +265 -7
- package/extension/libherb/ast_pretty_print.h +6 -1
- package/extension/libherb/element_source.h +3 -8
- package/extension/libherb/errors.c +1455 -520
- package/extension/libherb/errors.h +207 -56
- package/extension/libherb/extract.c +145 -49
- package/extension/libherb/extract.h +21 -5
- package/extension/libherb/herb.c +52 -34
- package/extension/libherb/herb.h +18 -6
- package/extension/libherb/herb_prism_node.h +13 -0
- package/extension/libherb/html_util.c +241 -12
- package/extension/libherb/html_util.h +7 -2
- package/extension/libherb/include/analyze/action_view/attribute_extraction_helpers.h +36 -0
- package/extension/libherb/include/analyze/action_view/tag_helper_handler.h +43 -0
- package/extension/libherb/include/analyze/action_view/tag_helper_node_builders.h +70 -0
- package/extension/libherb/include/analyze/action_view/tag_helpers.h +38 -0
- package/extension/libherb/{analyze.h → include/analyze/analyze.h} +14 -4
- package/extension/libherb/include/{analyzed_ruby.h → analyze/analyzed_ruby.h} +3 -3
- package/extension/libherb/include/analyze/builders.h +27 -0
- package/extension/libherb/include/analyze/conditional_elements.h +9 -0
- package/extension/libherb/include/analyze/conditional_open_tags.h +9 -0
- package/extension/libherb/include/analyze/control_type.h +14 -0
- package/extension/libherb/include/{analyze_helpers.h → analyze/helpers.h} +4 -2
- package/extension/libherb/include/analyze/invalid_structures.h +11 -0
- package/extension/libherb/include/analyze/prism_annotate.h +16 -0
- package/extension/libherb/include/analyze/render_nodes.h +11 -0
- package/extension/libherb/include/ast_node.h +11 -5
- package/extension/libherb/include/ast_nodes.h +155 -39
- package/extension/libherb/include/ast_pretty_print.h +6 -1
- package/extension/libherb/include/element_source.h +3 -8
- package/extension/libherb/include/errors.h +207 -56
- package/extension/libherb/include/extract.h +21 -5
- package/extension/libherb/include/herb.h +18 -6
- package/extension/libherb/include/herb_prism_node.h +13 -0
- package/extension/libherb/include/html_util.h +7 -2
- package/extension/libherb/include/io.h +3 -1
- package/extension/libherb/include/lex_helpers.h +29 -0
- package/extension/libherb/include/lexer.h +1 -1
- package/extension/libherb/include/lexer_peek_helpers.h +87 -13
- package/extension/libherb/include/lexer_struct.h +2 -0
- package/extension/libherb/include/location.h +2 -1
- package/extension/libherb/include/parser.h +28 -2
- package/extension/libherb/include/parser_helpers.h +19 -3
- package/extension/libherb/include/pretty_print.h +10 -5
- package/extension/libherb/include/prism_context.h +45 -0
- package/extension/libherb/include/prism_helpers.h +10 -7
- package/extension/libherb/include/prism_serialized.h +12 -0
- package/extension/libherb/include/token.h +16 -4
- package/extension/libherb/include/token_struct.h +10 -3
- package/extension/libherb/include/utf8.h +2 -1
- package/extension/libherb/include/util/hb_allocator.h +78 -0
- package/extension/libherb/include/util/hb_arena.h +6 -1
- package/extension/libherb/include/util/hb_arena_debug.h +12 -1
- package/extension/libherb/include/util/hb_array.h +7 -3
- package/extension/libherb/include/util/hb_buffer.h +6 -4
- package/extension/libherb/include/util/hb_foreach.h +79 -0
- package/extension/libherb/include/util/hb_narray.h +8 -4
- package/extension/libherb/include/util/hb_string.h +56 -9
- package/extension/libherb/include/util.h +6 -3
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/io.c +3 -2
- package/extension/libherb/io.h +3 -1
- package/extension/libherb/lex_helpers.h +29 -0
- package/extension/libherb/lexer.c +42 -30
- package/extension/libherb/lexer.h +1 -1
- package/extension/libherb/lexer_peek_helpers.c +12 -74
- package/extension/libherb/lexer_peek_helpers.h +87 -13
- package/extension/libherb/lexer_struct.h +2 -0
- package/extension/libherb/location.c +2 -2
- package/extension/libherb/location.h +2 -1
- package/extension/libherb/main.c +53 -28
- package/extension/libherb/parser.c +784 -247
- package/extension/libherb/parser.h +28 -2
- package/extension/libherb/parser_helpers.c +110 -23
- package/extension/libherb/parser_helpers.h +19 -3
- package/extension/libherb/parser_match_tags.c +130 -49
- package/extension/libherb/pretty_print.c +29 -24
- package/extension/libherb/pretty_print.h +10 -5
- package/extension/libherb/prism_context.h +45 -0
- package/extension/libherb/prism_helpers.c +30 -27
- package/extension/libherb/prism_helpers.h +10 -7
- package/extension/libherb/prism_serialized.h +12 -0
- package/extension/libherb/ruby_parser.c +2 -0
- package/extension/libherb/token.c +151 -66
- package/extension/libherb/token.h +16 -4
- package/extension/libherb/token_matchers.c +0 -1
- package/extension/libherb/token_struct.h +10 -3
- package/extension/libherb/utf8.c +7 -6
- package/extension/libherb/utf8.h +2 -1
- package/extension/libherb/util/hb_allocator.c +341 -0
- package/extension/libherb/util/hb_allocator.h +78 -0
- package/extension/libherb/util/hb_arena.c +81 -56
- package/extension/libherb/util/hb_arena.h +6 -1
- package/extension/libherb/util/hb_arena_debug.c +32 -17
- package/extension/libherb/util/hb_arena_debug.h +12 -1
- package/extension/libherb/util/hb_array.c +30 -15
- package/extension/libherb/util/hb_array.h +7 -3
- package/extension/libherb/util/hb_buffer.c +17 -21
- package/extension/libherb/util/hb_buffer.h +6 -4
- package/extension/libherb/util/hb_foreach.h +79 -0
- package/extension/libherb/util/hb_narray.c +22 -7
- package/extension/libherb/util/hb_narray.h +8 -4
- package/extension/libherb/util/hb_string.c +49 -35
- package/extension/libherb/util/hb_string.h +56 -9
- package/extension/libherb/util.c +21 -11
- package/extension/libherb/util.h +6 -3
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +68 -1
- package/extension/nodes.cpp +593 -6
- package/extension/nodes.h +10 -1
- package/package.json +12 -8
- package/src/node-backend.ts +11 -1
- package/dist/types/index-cjs.d.cts +0 -1
- package/extension/libherb/analyze.c +0 -1608
- package/extension/libherb/element_source.c +0 -12
- package/extension/libherb/include/util/hb_system.h +0 -9
- package/extension/libherb/util/hb_system.c +0 -30
- package/extension/libherb/util/hb_system.h +0 -9
- package/src/index-cjs.cts +0 -22
- /package/dist/types/{index-esm.d.mts → index.d.ts} +0 -0
- /package/src/{index-esm.mts → index.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/src/errors.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/errors.h"
|
|
5
5
|
#include "include/location.h"
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
#include "include/pretty_print.h"
|
|
8
8
|
#include "include/token.h"
|
|
9
9
|
#include "include/util.h"
|
|
10
|
+
#include "include/util/hb_allocator.h"
|
|
10
11
|
#include "include/util/hb_array.h"
|
|
12
|
+
#include "include/util/hb_string.h"
|
|
11
13
|
|
|
12
14
|
#include <stdio.h>
|
|
13
15
|
#include <stdbool.h>
|
|
@@ -28,658 +30,1326 @@ void error_init(ERROR_T* error, const error_type_T type, position_T start, posit
|
|
|
28
30
|
error->location.end = end;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
UNEXPECTED_ERROR_T* unexpected_error_init(
|
|
32
|
-
UNEXPECTED_ERROR_T* unexpected_error =
|
|
33
|
+
UNEXPECTED_ERROR_T* unexpected_error_init(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
34
|
+
UNEXPECTED_ERROR_T* unexpected_error = hb_allocator_alloc(allocator, sizeof(UNEXPECTED_ERROR_T));
|
|
35
|
+
|
|
36
|
+
if (!unexpected_error) { return NULL; }
|
|
33
37
|
|
|
34
38
|
error_init(&unexpected_error->base, UNEXPECTED_ERROR, start, end);
|
|
35
39
|
|
|
36
|
-
const char* message_template = "%s. Expected:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
char*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
strncpy(truncated_argument_0, description, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
44
|
-
truncated_argument_0[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
45
|
-
|
|
46
|
-
char truncated_argument_1[ERROR_MESSAGES_TRUNCATED_LENGTH + 1];
|
|
47
|
-
strncpy(truncated_argument_1, expected, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
48
|
-
truncated_argument_1[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
49
|
-
|
|
50
|
-
char truncated_argument_2[ERROR_MESSAGES_TRUNCATED_LENGTH + 1];
|
|
51
|
-
strncpy(truncated_argument_2, found, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
52
|
-
truncated_argument_2[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
53
|
-
|
|
54
|
-
snprintf(
|
|
55
|
-
message,
|
|
56
|
-
message_size,
|
|
57
|
-
message_template,
|
|
58
|
-
truncated_argument_0,
|
|
59
|
-
truncated_argument_1,
|
|
60
|
-
truncated_argument_2
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
unexpected_error->base.message = herb_strdup(message);
|
|
64
|
-
free(message);
|
|
65
|
-
} else {
|
|
66
|
-
unexpected_error->base.message = herb_strdup("%s. Expected: `%s`, found: `%s`.");
|
|
67
|
-
}
|
|
40
|
+
const char* message_template = "%s. Expected: %s, found: %s.";
|
|
41
|
+
|
|
42
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(description, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
43
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
44
|
+
|
|
45
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(expected, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
46
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
68
47
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
hb_string_T truncated_argument_2 = hb_string_truncate(found, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
49
|
+
char* truncated_c_string_2 = hb_string_to_c_string_using_malloc(truncated_argument_2);
|
|
50
|
+
|
|
51
|
+
char message[413];
|
|
52
|
+
snprintf(
|
|
53
|
+
message,
|
|
54
|
+
sizeof(message),
|
|
55
|
+
message_template,
|
|
56
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
57
|
+
truncated_c_string_1 ? truncated_c_string_1 : "",
|
|
58
|
+
truncated_c_string_2 ? truncated_c_string_2 : ""
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
62
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
63
|
+
if (truncated_c_string_2) { free(truncated_c_string_2); }
|
|
64
|
+
unexpected_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
65
|
+
|
|
66
|
+
unexpected_error->description = hb_string_copy(description, allocator);
|
|
67
|
+
unexpected_error->expected = hb_string_copy(expected, allocator);
|
|
68
|
+
unexpected_error->found = hb_string_copy(found, allocator);
|
|
72
69
|
return unexpected_error;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
void append_unexpected_error(
|
|
76
|
-
hb_array_append(errors, unexpected_error_init(description, expected, found, start, end));
|
|
72
|
+
void append_unexpected_error(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
73
|
+
hb_array_append(errors, unexpected_error_init(description, expected, found, start, end, allocator));
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end) {
|
|
80
|
-
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error =
|
|
76
|
+
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
77
|
+
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error = hb_allocator_alloc(allocator, sizeof(UNEXPECTED_TOKEN_ERROR_T));
|
|
78
|
+
|
|
79
|
+
if (!unexpected_token_error) { return NULL; }
|
|
81
80
|
|
|
82
81
|
error_init(&unexpected_token_error->base, UNEXPECTED_TOKEN_ERROR, start, end);
|
|
83
82
|
|
|
84
|
-
const char* message_template = "Found
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
char*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
unexpected_token_error->base.message = herb_strdup(message);
|
|
109
|
-
free(message);
|
|
110
|
-
} else {
|
|
111
|
-
unexpected_token_error->base.message = herb_strdup("Found `%s` when expecting `%s` at (%u:%u).");
|
|
112
|
-
}
|
|
83
|
+
const char* message_template = "Found %s when expecting %s at (%u:%u).";
|
|
84
|
+
|
|
85
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(token_type_to_friendly_string(found->type), ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
86
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
87
|
+
|
|
88
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(token_type_to_friendly_string(expected_type), ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
89
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
90
|
+
|
|
91
|
+
char message[315];
|
|
92
|
+
snprintf(
|
|
93
|
+
message,
|
|
94
|
+
sizeof(message),
|
|
95
|
+
message_template,
|
|
96
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
97
|
+
truncated_c_string_1 ? truncated_c_string_1 : "",
|
|
98
|
+
found->location.start.line,
|
|
99
|
+
found->location.start.column
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
103
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
104
|
+
unexpected_token_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
113
105
|
|
|
114
106
|
unexpected_token_error->expected_type = expected_type;
|
|
115
|
-
unexpected_token_error->found = token_copy(found);
|
|
107
|
+
unexpected_token_error->found = token_copy(found, allocator);
|
|
116
108
|
return unexpected_token_error;
|
|
117
109
|
}
|
|
118
110
|
|
|
119
|
-
void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_array_T* errors) {
|
|
120
|
-
hb_array_append(errors, unexpected_token_error_init(expected_type, found, start, end));
|
|
111
|
+
void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
112
|
+
hb_array_append(errors, unexpected_token_error_init(expected_type, found, start, end, allocator));
|
|
121
113
|
}
|
|
122
114
|
|
|
123
|
-
MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end) {
|
|
124
|
-
MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error =
|
|
115
|
+
MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
116
|
+
MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error = hb_allocator_alloc(allocator, sizeof(MISSING_OPENING_TAG_ERROR_T));
|
|
117
|
+
|
|
118
|
+
if (!missing_opening_tag_error) { return NULL; }
|
|
125
119
|
|
|
126
120
|
error_init(&missing_opening_tag_error->base, MISSING_OPENING_TAG_ERROR, start, end);
|
|
127
121
|
|
|
128
122
|
const char* message_template = "Found closing tag `</%s>` at (%u:%u) without a matching opening tag in the same scope.";
|
|
129
123
|
|
|
130
|
-
|
|
131
|
-
char*
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
truncated_argument_0,
|
|
143
|
-
closing_tag->location.start.line,
|
|
144
|
-
closing_tag->location.start.column
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
missing_opening_tag_error->base.message = herb_strdup(message);
|
|
148
|
-
free(message);
|
|
149
|
-
} else {
|
|
150
|
-
missing_opening_tag_error->base.message = herb_strdup("Found closing tag `</%s>` at (%u:%u) without a matching opening tag in the same scope.");
|
|
151
|
-
}
|
|
124
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(closing_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
125
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
126
|
+
|
|
127
|
+
char message[235];
|
|
128
|
+
snprintf(
|
|
129
|
+
message,
|
|
130
|
+
sizeof(message),
|
|
131
|
+
message_template,
|
|
132
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
133
|
+
closing_tag->location.start.line,
|
|
134
|
+
closing_tag->location.start.column
|
|
135
|
+
);
|
|
152
136
|
|
|
153
|
-
|
|
137
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
138
|
+
missing_opening_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
139
|
+
|
|
140
|
+
missing_opening_tag_error->closing_tag = token_copy(closing_tag, allocator);
|
|
154
141
|
return missing_opening_tag_error;
|
|
155
142
|
}
|
|
156
143
|
|
|
157
|
-
void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_array_T* errors) {
|
|
158
|
-
hb_array_append(errors, missing_opening_tag_error_init(closing_tag, start, end));
|
|
144
|
+
void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
145
|
+
hb_array_append(errors, missing_opening_tag_error_init(closing_tag, start, end, allocator));
|
|
159
146
|
}
|
|
160
147
|
|
|
161
|
-
MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end) {
|
|
162
|
-
MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error =
|
|
148
|
+
MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
149
|
+
MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error = hb_allocator_alloc(allocator, sizeof(MISSING_CLOSING_TAG_ERROR_T));
|
|
150
|
+
|
|
151
|
+
if (!missing_closing_tag_error) { return NULL; }
|
|
163
152
|
|
|
164
153
|
error_init(&missing_closing_tag_error->base, MISSING_CLOSING_TAG_ERROR, start, end);
|
|
165
154
|
|
|
166
155
|
const char* message_template = "Opening tag `<%s>` at (%u:%u) doesn't have a matching closing tag `</%s>` in the same scope.";
|
|
167
156
|
|
|
168
|
-
|
|
169
|
-
char*
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
strncpy(truncated_argument_0, opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
174
|
-
truncated_argument_0[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
175
|
-
|
|
176
|
-
char truncated_argument_3[ERROR_MESSAGES_TRUNCATED_LENGTH + 1];
|
|
177
|
-
strncpy(truncated_argument_3, opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
178
|
-
truncated_argument_3[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
179
|
-
|
|
180
|
-
snprintf(
|
|
181
|
-
message,
|
|
182
|
-
message_size,
|
|
183
|
-
message_template,
|
|
184
|
-
truncated_argument_0,
|
|
185
|
-
opening_tag->location.start.line,
|
|
186
|
-
opening_tag->location.start.column,
|
|
187
|
-
truncated_argument_3
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
missing_closing_tag_error->base.message = herb_strdup(message);
|
|
191
|
-
free(message);
|
|
192
|
-
} else {
|
|
193
|
-
missing_closing_tag_error->base.message = herb_strdup("Opening tag `<%s>` at (%u:%u) doesn't have a matching closing tag `</%s>` in the same scope.");
|
|
194
|
-
}
|
|
157
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
158
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
159
|
+
|
|
160
|
+
hb_string_T truncated_argument_3 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
161
|
+
char* truncated_c_string_3 = hb_string_to_c_string_using_malloc(truncated_argument_3);
|
|
195
162
|
|
|
196
|
-
|
|
163
|
+
char message[369];
|
|
164
|
+
snprintf(
|
|
165
|
+
message,
|
|
166
|
+
sizeof(message),
|
|
167
|
+
message_template,
|
|
168
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
169
|
+
opening_tag->location.start.line,
|
|
170
|
+
opening_tag->location.start.column,
|
|
171
|
+
truncated_c_string_3 ? truncated_c_string_3 : ""
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
175
|
+
if (truncated_c_string_3) { free(truncated_c_string_3); }
|
|
176
|
+
missing_closing_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
177
|
+
|
|
178
|
+
missing_closing_tag_error->opening_tag = token_copy(opening_tag, allocator);
|
|
197
179
|
return missing_closing_tag_error;
|
|
198
180
|
}
|
|
199
181
|
|
|
200
|
-
void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors) {
|
|
201
|
-
hb_array_append(errors, missing_closing_tag_error_init(opening_tag, start, end));
|
|
182
|
+
void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
183
|
+
hb_array_append(errors, missing_closing_tag_error_init(opening_tag, start, end, allocator));
|
|
202
184
|
}
|
|
203
185
|
|
|
204
|
-
TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end) {
|
|
205
|
-
TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error =
|
|
186
|
+
TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
187
|
+
TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error = hb_allocator_alloc(allocator, sizeof(TAG_NAMES_MISMATCH_ERROR_T));
|
|
188
|
+
|
|
189
|
+
if (!tag_names_mismatch_error) { return NULL; }
|
|
206
190
|
|
|
207
191
|
error_init(&tag_names_mismatch_error->base, TAG_NAMES_MISMATCH_ERROR, start, end);
|
|
208
192
|
|
|
209
193
|
const char* message_template = "Opening tag `<%s>` at (%u:%u) closed with `</%s>` at (%u:%u).";
|
|
210
194
|
|
|
211
|
-
|
|
212
|
-
char*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
free(message);
|
|
237
|
-
} else {
|
|
238
|
-
tag_names_mismatch_error->base.message = herb_strdup("Opening tag `<%s>` at (%u:%u) closed with `</%s>` at (%u:%u).");
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
tag_names_mismatch_error->opening_tag = token_copy(opening_tag);
|
|
242
|
-
tag_names_mismatch_error->closing_tag = token_copy(closing_tag);
|
|
195
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
196
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
197
|
+
|
|
198
|
+
hb_string_T truncated_argument_3 = hb_string_truncate(closing_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
199
|
+
char* truncated_c_string_3 = hb_string_to_c_string_using_malloc(truncated_argument_3);
|
|
200
|
+
|
|
201
|
+
char message[358];
|
|
202
|
+
snprintf(
|
|
203
|
+
message,
|
|
204
|
+
sizeof(message),
|
|
205
|
+
message_template,
|
|
206
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
207
|
+
opening_tag->location.start.line,
|
|
208
|
+
opening_tag->location.start.column,
|
|
209
|
+
truncated_c_string_3 ? truncated_c_string_3 : "",
|
|
210
|
+
closing_tag->location.start.line,
|
|
211
|
+
closing_tag->location.start.column
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
215
|
+
if (truncated_c_string_3) { free(truncated_c_string_3); }
|
|
216
|
+
tag_names_mismatch_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
217
|
+
|
|
218
|
+
tag_names_mismatch_error->opening_tag = token_copy(opening_tag, allocator);
|
|
219
|
+
tag_names_mismatch_error->closing_tag = token_copy(closing_tag, allocator);
|
|
243
220
|
return tag_names_mismatch_error;
|
|
244
221
|
}
|
|
245
222
|
|
|
246
|
-
void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_array_T* errors) {
|
|
247
|
-
hb_array_append(errors, tag_names_mismatch_error_init(opening_tag, closing_tag, start, end));
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end) {
|
|
251
|
-
QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error = malloc(sizeof(QUOTES_MISMATCH_ERROR_T));
|
|
252
|
-
|
|
253
|
-
error_init("es_mismatch_error->base, QUOTES_MISMATCH_ERROR, start, end);
|
|
254
|
-
|
|
255
|
-
const char* message_template = "String opened with %s but closed with %s at (%u:%u).";
|
|
256
|
-
|
|
257
|
-
size_t message_size = 329;
|
|
258
|
-
char* message = (char*) malloc(message_size);
|
|
259
|
-
|
|
260
|
-
if (message) {
|
|
261
|
-
char truncated_argument_0[ERROR_MESSAGES_TRUNCATED_LENGTH + 1];
|
|
262
|
-
strncpy(truncated_argument_0, opening_quote->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
263
|
-
truncated_argument_0[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
264
|
-
|
|
265
|
-
char truncated_argument_1[ERROR_MESSAGES_TRUNCATED_LENGTH + 1];
|
|
266
|
-
strncpy(truncated_argument_1, closing_quote->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
267
|
-
truncated_argument_1[ERROR_MESSAGES_TRUNCATED_LENGTH] = '\0';
|
|
268
|
-
|
|
269
|
-
snprintf(
|
|
270
|
-
message,
|
|
271
|
-
message_size,
|
|
272
|
-
message_template,
|
|
273
|
-
truncated_argument_0,
|
|
274
|
-
truncated_argument_1,
|
|
275
|
-
closing_quote->location.start.line,
|
|
276
|
-
closing_quote->location.start.column
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
quotes_mismatch_error->base.message = herb_strdup(message);
|
|
280
|
-
free(message);
|
|
281
|
-
} else {
|
|
282
|
-
quotes_mismatch_error->base.message = herb_strdup("String opened with %s but closed with %s at (%u:%u).");
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
quotes_mismatch_error->opening_quote = token_copy(opening_quote);
|
|
286
|
-
quotes_mismatch_error->closing_quote = token_copy(closing_quote);
|
|
287
|
-
return quotes_mismatch_error;
|
|
223
|
+
void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
224
|
+
hb_array_append(errors, tag_names_mismatch_error_init(opening_tag, closing_tag, start, end, allocator));
|
|
288
225
|
}
|
|
289
226
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
227
|
+
VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
228
|
+
VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error = hb_allocator_alloc(allocator, sizeof(VOID_ELEMENT_CLOSING_TAG_ERROR_T));
|
|
293
229
|
|
|
294
|
-
|
|
295
|
-
VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error = malloc(sizeof(VOID_ELEMENT_CLOSING_TAG_ERROR_T));
|
|
230
|
+
if (!void_element_closing_tag_error) { return NULL; }
|
|
296
231
|
|
|
297
232
|
error_init(&void_element_closing_tag_error->base, VOID_ELEMENT_CLOSING_TAG_ERROR, start, end);
|
|
298
233
|
|
|
299
234
|
const char* message_template = "`%s` is a void element and should not be used as a closing tag. Use `<%s>` or `<%s />` instead of `</%s>`.";
|
|
300
235
|
|
|
301
|
-
|
|
302
|
-
char*
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
} else {
|
|
334
|
-
void_element_closing_tag_error->base.message = herb_strdup("`%s` is a void element and should not be used as a closing tag. Use `<%s>` or `<%s />` instead of `</%s>`.");
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
void_element_closing_tag_error->tag_name = token_copy(tag_name);
|
|
338
|
-
void_element_closing_tag_error->expected = herb_strdup(expected);
|
|
339
|
-
void_element_closing_tag_error->found = herb_strdup(found);
|
|
236
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
237
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
238
|
+
|
|
239
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
240
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
241
|
+
|
|
242
|
+
hb_string_T truncated_argument_2 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
243
|
+
char* truncated_c_string_2 = hb_string_to_c_string_using_malloc(truncated_argument_2);
|
|
244
|
+
|
|
245
|
+
hb_string_T truncated_argument_3 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
246
|
+
char* truncated_c_string_3 = hb_string_to_c_string_using_malloc(truncated_argument_3);
|
|
247
|
+
|
|
248
|
+
char message[619];
|
|
249
|
+
snprintf(
|
|
250
|
+
message,
|
|
251
|
+
sizeof(message),
|
|
252
|
+
message_template,
|
|
253
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
254
|
+
truncated_c_string_1 ? truncated_c_string_1 : "",
|
|
255
|
+
truncated_c_string_2 ? truncated_c_string_2 : "",
|
|
256
|
+
truncated_c_string_3 ? truncated_c_string_3 : ""
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
260
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
261
|
+
if (truncated_c_string_2) { free(truncated_c_string_2); }
|
|
262
|
+
if (truncated_c_string_3) { free(truncated_c_string_3); }
|
|
263
|
+
void_element_closing_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
264
|
+
|
|
265
|
+
void_element_closing_tag_error->tag_name = token_copy(tag_name, allocator);
|
|
266
|
+
void_element_closing_tag_error->expected = hb_string_copy(expected, allocator);
|
|
267
|
+
void_element_closing_tag_error->found = hb_string_copy(found, allocator);
|
|
340
268
|
return void_element_closing_tag_error;
|
|
341
269
|
}
|
|
342
270
|
|
|
343
|
-
void append_void_element_closing_tag_error(token_T* tag_name,
|
|
344
|
-
hb_array_append(errors, void_element_closing_tag_error_init(tag_name, expected, found, start, end));
|
|
271
|
+
void append_void_element_closing_tag_error(token_T* tag_name, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
272
|
+
hb_array_append(errors, void_element_closing_tag_error_init(tag_name, expected, found, start, end, allocator));
|
|
345
273
|
}
|
|
346
274
|
|
|
347
|
-
UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end) {
|
|
348
|
-
UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error =
|
|
275
|
+
UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
276
|
+
UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error = hb_allocator_alloc(allocator, sizeof(UNCLOSED_ELEMENT_ERROR_T));
|
|
277
|
+
|
|
278
|
+
if (!unclosed_element_error) { return NULL; }
|
|
349
279
|
|
|
350
280
|
error_init(&unclosed_element_error->base, UNCLOSED_ELEMENT_ERROR, start, end);
|
|
351
281
|
|
|
352
282
|
const char* message_template = "Tag `<%s>` opened at (%u:%u) was never closed before the end of document.";
|
|
353
283
|
|
|
354
|
-
|
|
355
|
-
char*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
unclosed_element_error->base.message = herb_strdup(message);
|
|
372
|
-
free(message);
|
|
373
|
-
} else {
|
|
374
|
-
unclosed_element_error->base.message = herb_strdup("Tag `<%s>` opened at (%u:%u) was never closed before the end of document.");
|
|
375
|
-
}
|
|
284
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
285
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
286
|
+
|
|
287
|
+
char message[222];
|
|
288
|
+
snprintf(
|
|
289
|
+
message,
|
|
290
|
+
sizeof(message),
|
|
291
|
+
message_template,
|
|
292
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
293
|
+
opening_tag->location.start.line,
|
|
294
|
+
opening_tag->location.start.column
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
298
|
+
unclosed_element_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
376
299
|
|
|
377
|
-
unclosed_element_error->opening_tag = token_copy(opening_tag);
|
|
300
|
+
unclosed_element_error->opening_tag = token_copy(opening_tag, allocator);
|
|
378
301
|
return unclosed_element_error;
|
|
379
302
|
}
|
|
380
303
|
|
|
381
|
-
void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors) {
|
|
382
|
-
hb_array_append(errors, unclosed_element_error_init(opening_tag, start, end));
|
|
304
|
+
void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
305
|
+
hb_array_append(errors, unclosed_element_error_init(opening_tag, start, end, allocator));
|
|
383
306
|
}
|
|
384
307
|
|
|
385
|
-
RUBY_PARSE_ERROR_T* ruby_parse_error_init(
|
|
386
|
-
RUBY_PARSE_ERROR_T* ruby_parse_error =
|
|
308
|
+
RUBY_PARSE_ERROR_T* ruby_parse_error_init(hb_string_T error_message, hb_string_T diagnostic_id, hb_string_T level, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
309
|
+
RUBY_PARSE_ERROR_T* ruby_parse_error = hb_allocator_alloc(allocator, sizeof(RUBY_PARSE_ERROR_T));
|
|
310
|
+
|
|
311
|
+
if (!ruby_parse_error) { return NULL; }
|
|
387
312
|
|
|
388
313
|
error_init(&ruby_parse_error->base, RUBY_PARSE_ERROR, start, end);
|
|
389
314
|
|
|
390
315
|
const char* message_template = "%s: %s";
|
|
391
316
|
|
|
392
|
-
|
|
393
|
-
char*
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
message_size,
|
|
407
|
-
message_template,
|
|
408
|
-
truncated_argument_0,
|
|
409
|
-
truncated_argument_1
|
|
410
|
-
);
|
|
411
|
-
|
|
412
|
-
ruby_parse_error->base.message = herb_strdup(message);
|
|
413
|
-
free(message);
|
|
414
|
-
} else {
|
|
415
|
-
ruby_parse_error->base.message = herb_strdup("%s: %s");
|
|
416
|
-
}
|
|
317
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(diagnostic_id, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
318
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
319
|
+
|
|
320
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(error_message, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
321
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
322
|
+
|
|
323
|
+
char message[263];
|
|
324
|
+
snprintf(
|
|
325
|
+
message,
|
|
326
|
+
sizeof(message),
|
|
327
|
+
message_template,
|
|
328
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
329
|
+
truncated_c_string_1 ? truncated_c_string_1 : ""
|
|
330
|
+
);
|
|
417
331
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
ruby_parse_error->
|
|
332
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
333
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
334
|
+
ruby_parse_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
335
|
+
|
|
336
|
+
ruby_parse_error->error_message = hb_string_copy(error_message, allocator);
|
|
337
|
+
ruby_parse_error->diagnostic_id = hb_string_copy(diagnostic_id, allocator);
|
|
338
|
+
ruby_parse_error->level = hb_string_copy(level, allocator);
|
|
421
339
|
return ruby_parse_error;
|
|
422
340
|
}
|
|
423
341
|
|
|
424
|
-
void append_ruby_parse_error(
|
|
425
|
-
hb_array_append(errors, ruby_parse_error_init(error_message, diagnostic_id, level, start, end));
|
|
342
|
+
void append_ruby_parse_error(hb_string_T error_message, hb_string_T diagnostic_id, hb_string_T level, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
343
|
+
hb_array_append(errors, ruby_parse_error_init(error_message, diagnostic_id, level, start, end, allocator));
|
|
426
344
|
}
|
|
427
345
|
|
|
428
|
-
ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(
|
|
429
|
-
ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error =
|
|
346
|
+
ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
347
|
+
ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error = hb_allocator_alloc(allocator, sizeof(ERB_CONTROL_FLOW_SCOPE_ERROR_T));
|
|
348
|
+
|
|
349
|
+
if (!erb_control_flow_scope_error) { return NULL; }
|
|
430
350
|
|
|
431
351
|
error_init(&erb_control_flow_scope_error->base, ERB_CONTROL_FLOW_SCOPE_ERROR, start, end);
|
|
432
352
|
|
|
433
353
|
const char* message_template = "%s appears outside its control flow block. Keep ERB control flow statements together within the same HTML scope (tag, attribute, or content).";
|
|
434
354
|
|
|
435
|
-
|
|
436
|
-
char*
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
message_size,
|
|
446
|
-
message_template,
|
|
447
|
-
truncated_argument_0
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
erb_control_flow_scope_error->base.message = herb_strdup(message);
|
|
451
|
-
free(message);
|
|
452
|
-
} else {
|
|
453
|
-
erb_control_flow_scope_error->base.message = herb_strdup("%s appears outside its control flow block. Keep ERB control flow statements together within the same HTML scope (tag, attribute, or content).");
|
|
454
|
-
}
|
|
355
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(keyword, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
356
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
357
|
+
|
|
358
|
+
char message[270];
|
|
359
|
+
snprintf(
|
|
360
|
+
message,
|
|
361
|
+
sizeof(message),
|
|
362
|
+
message_template,
|
|
363
|
+
truncated_c_string_0 ? truncated_c_string_0 : ""
|
|
364
|
+
);
|
|
455
365
|
|
|
456
|
-
|
|
366
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
367
|
+
erb_control_flow_scope_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
368
|
+
|
|
369
|
+
erb_control_flow_scope_error->keyword = hb_string_copy(keyword, allocator);
|
|
457
370
|
return erb_control_flow_scope_error;
|
|
458
371
|
}
|
|
459
372
|
|
|
460
|
-
void append_erb_control_flow_scope_error(
|
|
461
|
-
hb_array_append(errors, erb_control_flow_scope_error_init(keyword, start, end));
|
|
373
|
+
void append_erb_control_flow_scope_error(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
374
|
+
hb_array_append(errors, erb_control_flow_scope_error_init(keyword, start, end, allocator));
|
|
462
375
|
}
|
|
463
376
|
|
|
464
|
-
|
|
465
|
-
|
|
377
|
+
MISSING_ERB_END_TAG_ERROR_T* missing_erb_end_tag_error_init(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
378
|
+
MISSING_ERB_END_TAG_ERROR_T* missing_erb_end_tag_error = hb_allocator_alloc(allocator, sizeof(MISSING_ERB_END_TAG_ERROR_T));
|
|
379
|
+
|
|
380
|
+
if (!missing_erb_end_tag_error) { return NULL; }
|
|
466
381
|
|
|
467
|
-
error_init(&
|
|
382
|
+
error_init(&missing_erb_end_tag_error->base, MISSING_ERB_END_TAG_ERROR, start, end);
|
|
468
383
|
|
|
469
384
|
const char* message_template = "%s started here but never closed with an end tag. The end tag may be in a different scope.";
|
|
470
385
|
|
|
471
|
-
|
|
472
|
-
char*
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
message_size,
|
|
482
|
-
message_template,
|
|
483
|
-
truncated_argument_0
|
|
484
|
-
);
|
|
485
|
-
|
|
486
|
-
missingerb_end_tag_error->base.message = herb_strdup(message);
|
|
487
|
-
free(message);
|
|
488
|
-
} else {
|
|
489
|
-
missingerb_end_tag_error->base.message = herb_strdup("%s started here but never closed with an end tag. The end tag may be in a different scope.");
|
|
490
|
-
}
|
|
386
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(keyword, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
387
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
388
|
+
|
|
389
|
+
char message[219];
|
|
390
|
+
snprintf(
|
|
391
|
+
message,
|
|
392
|
+
sizeof(message),
|
|
393
|
+
message_template,
|
|
394
|
+
truncated_c_string_0 ? truncated_c_string_0 : ""
|
|
395
|
+
);
|
|
491
396
|
|
|
492
|
-
|
|
493
|
-
|
|
397
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
398
|
+
missing_erb_end_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
399
|
+
|
|
400
|
+
missing_erb_end_tag_error->keyword = hb_string_copy(keyword, allocator);
|
|
401
|
+
return missing_erb_end_tag_error;
|
|
494
402
|
}
|
|
495
403
|
|
|
496
|
-
void
|
|
497
|
-
hb_array_append(errors,
|
|
404
|
+
void append_missing_erb_end_tag_error(hb_string_T keyword, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
405
|
+
hb_array_append(errors, missing_erb_end_tag_error_init(keyword, start, end, allocator));
|
|
498
406
|
}
|
|
499
407
|
|
|
500
|
-
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error_init(position_T start, position_T end) {
|
|
501
|
-
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error =
|
|
408
|
+
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error_init(position_T start, position_T end, hb_allocator_T* allocator) {
|
|
409
|
+
ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error = hb_allocator_alloc(allocator, sizeof(ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T));
|
|
410
|
+
|
|
411
|
+
if (!erb_multiple_blocks_in_tag_error) { return NULL; }
|
|
502
412
|
|
|
503
413
|
error_init(&erb_multiple_blocks_in_tag_error->base, ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR, start, end);
|
|
504
414
|
|
|
505
|
-
erb_multiple_blocks_in_tag_error->base.message =
|
|
415
|
+
erb_multiple_blocks_in_tag_error->base.message = hb_string_copy(hb_string("Multiple unclosed control flow blocks in a single ERB tag. Split each block into its own ERB tag, or close all blocks within the same tag."), allocator);
|
|
506
416
|
|
|
507
417
|
return erb_multiple_blocks_in_tag_error;
|
|
508
418
|
}
|
|
509
419
|
|
|
510
|
-
void append_erb_multiple_blocks_in_tag_error(position_T start, position_T end, hb_array_T* errors) {
|
|
511
|
-
hb_array_append(errors, erb_multiple_blocks_in_tag_error_init(start, end));
|
|
420
|
+
void append_erb_multiple_blocks_in_tag_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
421
|
+
hb_array_append(errors, erb_multiple_blocks_in_tag_error_init(start, end, allocator));
|
|
512
422
|
}
|
|
513
423
|
|
|
514
|
-
ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error_init(position_T start, position_T end) {
|
|
515
|
-
ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error =
|
|
424
|
+
ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error_init(position_T start, position_T end, hb_allocator_T* allocator) {
|
|
425
|
+
ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error = hb_allocator_alloc(allocator, sizeof(ERB_CASE_WITH_CONDITIONS_ERROR_T));
|
|
426
|
+
|
|
427
|
+
if (!erb_case_with_conditions_error) { return NULL; }
|
|
516
428
|
|
|
517
429
|
error_init(&erb_case_with_conditions_error->base, ERB_CASE_WITH_CONDITIONS_ERROR, start, end);
|
|
518
430
|
|
|
519
|
-
erb_case_with_conditions_error->base.message =
|
|
431
|
+
erb_case_with_conditions_error->base.message = hb_string_copy(hb_string("A `case` statement with `when`/`in` conditions in a single ERB tag cannot be reliably parsed, compiled, and formatted. Use separate ERB tags for `case` and its conditions (e.g., `<% case x %>` followed by `<% when y %>`)."), allocator);
|
|
520
432
|
|
|
521
433
|
return erb_case_with_conditions_error;
|
|
522
434
|
}
|
|
523
435
|
|
|
524
|
-
void append_erb_case_with_conditions_error(position_T start, position_T end, hb_array_T* errors) {
|
|
525
|
-
hb_array_append(errors, erb_case_with_conditions_error_init(start, end));
|
|
436
|
+
void append_erb_case_with_conditions_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
437
|
+
hb_array_append(errors, erb_case_with_conditions_error_init(start, end, allocator));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T* conditional_element_multiple_tags_error_init(size_t line, size_t column, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
441
|
+
CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T* conditional_element_multiple_tags_error = hb_allocator_alloc(allocator, sizeof(CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T));
|
|
442
|
+
|
|
443
|
+
if (!conditional_element_multiple_tags_error) { return NULL; }
|
|
444
|
+
|
|
445
|
+
error_init(&conditional_element_multiple_tags_error->base, CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR, start, end);
|
|
446
|
+
|
|
447
|
+
const char* message_template = "Conditional element pattern detected at (%zu:%zu) but the conditional block contains multiple HTML tags. Each conditional element must wrap exactly one opening and one closing tag. Consider nesting the conditionals individually.";
|
|
448
|
+
|
|
449
|
+
char message[269];
|
|
450
|
+
snprintf(
|
|
451
|
+
message,
|
|
452
|
+
sizeof(message),
|
|
453
|
+
message_template,
|
|
454
|
+
line,
|
|
455
|
+
column
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
conditional_element_multiple_tags_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
459
|
+
|
|
460
|
+
conditional_element_multiple_tags_error->line = line;
|
|
461
|
+
conditional_element_multiple_tags_error->column = column;
|
|
462
|
+
return conditional_element_multiple_tags_error;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
void append_conditional_element_multiple_tags_error(size_t line, size_t column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
466
|
+
hb_array_append(errors, conditional_element_multiple_tags_error_init(line, column, start, end, allocator));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T* conditional_element_condition_mismatch_error_init(hb_string_T tag_name, hb_string_T open_condition, size_t open_line, size_t open_column, hb_string_T close_condition, size_t close_line, size_t close_column, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
470
|
+
CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T* conditional_element_condition_mismatch_error = hb_allocator_alloc(allocator, sizeof(CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T));
|
|
471
|
+
|
|
472
|
+
if (!conditional_element_condition_mismatch_error) { return NULL; }
|
|
473
|
+
|
|
474
|
+
error_init(&conditional_element_condition_mismatch_error->base, CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR, start, end);
|
|
475
|
+
|
|
476
|
+
const char* message_template = "Conditional element `<%s>` has mismatched conditions: opening uses `%s` at (%zu:%zu) but closing uses `%s` at (%zu:%zu). Both conditions must be identical.";
|
|
477
|
+
|
|
478
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(tag_name, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
479
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
480
|
+
|
|
481
|
+
hb_string_T truncated_argument_1 = hb_string_truncate(open_condition, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
482
|
+
char* truncated_c_string_1 = hb_string_to_c_string_using_malloc(truncated_argument_1);
|
|
483
|
+
|
|
484
|
+
hb_string_T truncated_argument_4 = hb_string_truncate(close_condition, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
485
|
+
char* truncated_c_string_4 = hb_string_to_c_string_using_malloc(truncated_argument_4);
|
|
486
|
+
|
|
487
|
+
char message[620];
|
|
488
|
+
snprintf(
|
|
489
|
+
message,
|
|
490
|
+
sizeof(message),
|
|
491
|
+
message_template,
|
|
492
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
493
|
+
truncated_c_string_1 ? truncated_c_string_1 : "",
|
|
494
|
+
open_line,
|
|
495
|
+
open_column,
|
|
496
|
+
truncated_c_string_4 ? truncated_c_string_4 : "",
|
|
497
|
+
close_line,
|
|
498
|
+
close_column
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
502
|
+
if (truncated_c_string_1) { free(truncated_c_string_1); }
|
|
503
|
+
if (truncated_c_string_4) { free(truncated_c_string_4); }
|
|
504
|
+
conditional_element_condition_mismatch_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
505
|
+
|
|
506
|
+
conditional_element_condition_mismatch_error->tag_name = hb_string_copy(tag_name, allocator);
|
|
507
|
+
conditional_element_condition_mismatch_error->open_condition = hb_string_copy(open_condition, allocator);
|
|
508
|
+
conditional_element_condition_mismatch_error->open_line = open_line;
|
|
509
|
+
conditional_element_condition_mismatch_error->open_column = open_column;
|
|
510
|
+
conditional_element_condition_mismatch_error->close_condition = hb_string_copy(close_condition, allocator);
|
|
511
|
+
conditional_element_condition_mismatch_error->close_line = close_line;
|
|
512
|
+
conditional_element_condition_mismatch_error->close_column = close_column;
|
|
513
|
+
return conditional_element_condition_mismatch_error;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
void append_conditional_element_condition_mismatch_error(hb_string_T tag_name, hb_string_T open_condition, size_t open_line, size_t open_column, hb_string_T close_condition, size_t close_line, size_t close_column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
517
|
+
hb_array_append(errors, conditional_element_condition_mismatch_error_init(tag_name, open_condition, open_line, open_column, close_condition, close_line, close_column, start, end, allocator));
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
INVALID_COMMENT_CLOSING_TAG_ERROR_T* invalid_comment_closing_tag_error_init(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
521
|
+
INVALID_COMMENT_CLOSING_TAG_ERROR_T* invalid_comment_closing_tag_error = hb_allocator_alloc(allocator, sizeof(INVALID_COMMENT_CLOSING_TAG_ERROR_T));
|
|
522
|
+
|
|
523
|
+
if (!invalid_comment_closing_tag_error) { return NULL; }
|
|
524
|
+
|
|
525
|
+
error_init(&invalid_comment_closing_tag_error->base, INVALID_COMMENT_CLOSING_TAG_ERROR, start, end);
|
|
526
|
+
|
|
527
|
+
const char* message_template = "Invalid comment closing tag `%s` at (%u:%u). Use `-->` instead of `--!>`.";
|
|
528
|
+
|
|
529
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(closing_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
530
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
531
|
+
|
|
532
|
+
char message[222];
|
|
533
|
+
snprintf(
|
|
534
|
+
message,
|
|
535
|
+
sizeof(message),
|
|
536
|
+
message_template,
|
|
537
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
538
|
+
closing_tag->location.start.line,
|
|
539
|
+
closing_tag->location.start.column
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
543
|
+
invalid_comment_closing_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
544
|
+
|
|
545
|
+
invalid_comment_closing_tag_error->closing_tag = token_copy(closing_tag, allocator);
|
|
546
|
+
return invalid_comment_closing_tag_error;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
void append_invalid_comment_closing_tag_error(token_T* closing_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
550
|
+
hb_array_append(errors, invalid_comment_closing_tag_error_init(closing_tag, start, end, allocator));
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
OMITTED_CLOSING_TAG_ERROR_T* omitted_closing_tag_error_init(token_T* opening_tag, position_T insertion_point, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
554
|
+
OMITTED_CLOSING_TAG_ERROR_T* omitted_closing_tag_error = hb_allocator_alloc(allocator, sizeof(OMITTED_CLOSING_TAG_ERROR_T));
|
|
555
|
+
|
|
556
|
+
if (!omitted_closing_tag_error) { return NULL; }
|
|
557
|
+
|
|
558
|
+
error_init(&omitted_closing_tag_error->base, OMITTED_CLOSING_TAG_ERROR, start, end);
|
|
559
|
+
|
|
560
|
+
const char* message_template = "Element `<%s>` at (%u:%u) has its closing tag omitted. While valid HTML, consider adding an explicit `</%s>` closing tag at (%u:%u) for clarity, or set `strict: false` to allow this.";
|
|
561
|
+
|
|
562
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
563
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
564
|
+
|
|
565
|
+
hb_string_T truncated_argument_3 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
566
|
+
char* truncated_c_string_3 = hb_string_to_c_string_using_malloc(truncated_argument_3);
|
|
567
|
+
|
|
568
|
+
char message[479];
|
|
569
|
+
snprintf(
|
|
570
|
+
message,
|
|
571
|
+
sizeof(message),
|
|
572
|
+
message_template,
|
|
573
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
574
|
+
opening_tag->location.start.line,
|
|
575
|
+
opening_tag->location.start.column,
|
|
576
|
+
truncated_c_string_3 ? truncated_c_string_3 : "",
|
|
577
|
+
insertion_point.line,
|
|
578
|
+
insertion_point.column
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
582
|
+
if (truncated_c_string_3) { free(truncated_c_string_3); }
|
|
583
|
+
omitted_closing_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
584
|
+
|
|
585
|
+
omitted_closing_tag_error->opening_tag = token_copy(opening_tag, allocator);
|
|
586
|
+
omitted_closing_tag_error->insertion_point = insertion_point;
|
|
587
|
+
return omitted_closing_tag_error;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
void append_omitted_closing_tag_error(token_T* opening_tag, position_T insertion_point, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
591
|
+
hb_array_append(errors, omitted_closing_tag_error_init(opening_tag, insertion_point, start, end, allocator));
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
UNCLOSED_OPEN_TAG_ERROR_T* unclosed_open_tag_error_init(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
595
|
+
UNCLOSED_OPEN_TAG_ERROR_T* unclosed_open_tag_error = hb_allocator_alloc(allocator, sizeof(UNCLOSED_OPEN_TAG_ERROR_T));
|
|
596
|
+
|
|
597
|
+
if (!unclosed_open_tag_error) { return NULL; }
|
|
598
|
+
|
|
599
|
+
error_init(&unclosed_open_tag_error->base, UNCLOSED_OPEN_TAG_ERROR, start, end);
|
|
600
|
+
|
|
601
|
+
const char* message_template = "Opening tag `<%s>` at (%u:%u) is missing closing `>`.";
|
|
602
|
+
|
|
603
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
604
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
605
|
+
|
|
606
|
+
char message[202];
|
|
607
|
+
snprintf(
|
|
608
|
+
message,
|
|
609
|
+
sizeof(message),
|
|
610
|
+
message_template,
|
|
611
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
612
|
+
tag_name->location.start.line,
|
|
613
|
+
tag_name->location.start.column
|
|
614
|
+
);
|
|
615
|
+
|
|
616
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
617
|
+
unclosed_open_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
618
|
+
|
|
619
|
+
unclosed_open_tag_error->tag_name = token_copy(tag_name, allocator);
|
|
620
|
+
return unclosed_open_tag_error;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
void append_unclosed_open_tag_error(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
624
|
+
hb_array_append(errors, unclosed_open_tag_error_init(tag_name, start, end, allocator));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
UNCLOSED_CLOSE_TAG_ERROR_T* unclosed_close_tag_error_init(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
628
|
+
UNCLOSED_CLOSE_TAG_ERROR_T* unclosed_close_tag_error = hb_allocator_alloc(allocator, sizeof(UNCLOSED_CLOSE_TAG_ERROR_T));
|
|
629
|
+
|
|
630
|
+
if (!unclosed_close_tag_error) { return NULL; }
|
|
631
|
+
|
|
632
|
+
error_init(&unclosed_close_tag_error->base, UNCLOSED_CLOSE_TAG_ERROR, start, end);
|
|
633
|
+
|
|
634
|
+
const char* message_template = "Closing tag `</%s>` at (%u:%u) is missing closing `>`.";
|
|
635
|
+
|
|
636
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(tag_name->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
637
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
638
|
+
|
|
639
|
+
char message[203];
|
|
640
|
+
snprintf(
|
|
641
|
+
message,
|
|
642
|
+
sizeof(message),
|
|
643
|
+
message_template,
|
|
644
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
645
|
+
tag_name->location.start.line,
|
|
646
|
+
tag_name->location.start.column
|
|
647
|
+
);
|
|
648
|
+
|
|
649
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
650
|
+
unclosed_close_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
651
|
+
|
|
652
|
+
unclosed_close_tag_error->tag_name = token_copy(tag_name, allocator);
|
|
653
|
+
return unclosed_close_tag_error;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
void append_unclosed_close_tag_error(token_T* tag_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
657
|
+
hb_array_append(errors, unclosed_close_tag_error_init(tag_name, start, end, allocator));
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
UNCLOSED_QUOTE_ERROR_T* unclosed_quote_error_init(token_T* opening_quote, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
661
|
+
UNCLOSED_QUOTE_ERROR_T* unclosed_quote_error = hb_allocator_alloc(allocator, sizeof(UNCLOSED_QUOTE_ERROR_T));
|
|
662
|
+
|
|
663
|
+
if (!unclosed_quote_error) { return NULL; }
|
|
664
|
+
|
|
665
|
+
error_init(&unclosed_quote_error->base, UNCLOSED_QUOTE_ERROR, start, end);
|
|
666
|
+
|
|
667
|
+
const char* message_template = "Attribute value opened with %s at (%u:%u) was never closed.";
|
|
668
|
+
|
|
669
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_quote->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
670
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
671
|
+
|
|
672
|
+
char message[208];
|
|
673
|
+
snprintf(
|
|
674
|
+
message,
|
|
675
|
+
sizeof(message),
|
|
676
|
+
message_template,
|
|
677
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
678
|
+
opening_quote->location.start.line,
|
|
679
|
+
opening_quote->location.start.column
|
|
680
|
+
);
|
|
681
|
+
|
|
682
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
683
|
+
unclosed_quote_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
684
|
+
|
|
685
|
+
unclosed_quote_error->opening_quote = token_copy(opening_quote, allocator);
|
|
686
|
+
return unclosed_quote_error;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
void append_unclosed_quote_error(token_T* opening_quote, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
690
|
+
hb_array_append(errors, unclosed_quote_error_init(opening_quote, start, end, allocator));
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
MISSING_ATTRIBUTE_VALUE_ERROR_T* missing_attribute_value_error_init(hb_string_T attribute_name, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
694
|
+
MISSING_ATTRIBUTE_VALUE_ERROR_T* missing_attribute_value_error = hb_allocator_alloc(allocator, sizeof(MISSING_ATTRIBUTE_VALUE_ERROR_T));
|
|
695
|
+
|
|
696
|
+
if (!missing_attribute_value_error) { return NULL; }
|
|
697
|
+
|
|
698
|
+
error_init(&missing_attribute_value_error->base, MISSING_ATTRIBUTE_VALUE_ERROR, start, end);
|
|
699
|
+
|
|
700
|
+
const char* message_template = "Attribute `%s` at (%u:%u) is missing a value after the equals sign.";
|
|
701
|
+
|
|
702
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(attribute_name, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
703
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
704
|
+
|
|
705
|
+
char message[216];
|
|
706
|
+
snprintf(
|
|
707
|
+
message,
|
|
708
|
+
sizeof(message),
|
|
709
|
+
message_template,
|
|
710
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
711
|
+
start.line,
|
|
712
|
+
start.column
|
|
713
|
+
);
|
|
714
|
+
|
|
715
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
716
|
+
missing_attribute_value_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
717
|
+
|
|
718
|
+
missing_attribute_value_error->attribute_name = hb_string_copy(attribute_name, allocator);
|
|
719
|
+
return missing_attribute_value_error;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
void append_missing_attribute_value_error(hb_string_T attribute_name, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
723
|
+
hb_array_append(errors, missing_attribute_value_error_init(attribute_name, start, end, allocator));
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
UNCLOSED_ERB_TAG_ERROR_T* unclosed_erb_tag_error_init(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
727
|
+
UNCLOSED_ERB_TAG_ERROR_T* unclosed_erb_tag_error = hb_allocator_alloc(allocator, sizeof(UNCLOSED_ERB_TAG_ERROR_T));
|
|
728
|
+
|
|
729
|
+
if (!unclosed_erb_tag_error) { return NULL; }
|
|
730
|
+
|
|
731
|
+
error_init(&unclosed_erb_tag_error->base, UNCLOSED_ERB_TAG_ERROR, start, end);
|
|
732
|
+
|
|
733
|
+
const char* message_template = "ERB tag `%s` at (%u:%u) is missing closing `%%>`.";
|
|
734
|
+
|
|
735
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
736
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
737
|
+
|
|
738
|
+
char message[198];
|
|
739
|
+
snprintf(
|
|
740
|
+
message,
|
|
741
|
+
sizeof(message),
|
|
742
|
+
message_template,
|
|
743
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
744
|
+
opening_tag->location.start.line,
|
|
745
|
+
opening_tag->location.start.column
|
|
746
|
+
);
|
|
747
|
+
|
|
748
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
749
|
+
unclosed_erb_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
750
|
+
|
|
751
|
+
unclosed_erb_tag_error->opening_tag = token_copy(opening_tag, allocator);
|
|
752
|
+
return unclosed_erb_tag_error;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
void append_unclosed_erb_tag_error(token_T* opening_tag, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
756
|
+
hb_array_append(errors, unclosed_erb_tag_error_init(opening_tag, start, end, allocator));
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
STRAY_ERB_CLOSING_TAG_ERROR_T* stray_erb_closing_tag_error_init(position_T start, position_T end, hb_allocator_T* allocator) {
|
|
760
|
+
STRAY_ERB_CLOSING_TAG_ERROR_T* stray_erb_closing_tag_error = hb_allocator_alloc(allocator, sizeof(STRAY_ERB_CLOSING_TAG_ERROR_T));
|
|
761
|
+
|
|
762
|
+
if (!stray_erb_closing_tag_error) { return NULL; }
|
|
763
|
+
|
|
764
|
+
error_init(&stray_erb_closing_tag_error->base, STRAY_ERB_CLOSING_TAG_ERROR, start, end);
|
|
765
|
+
|
|
766
|
+
const char* message_template = "Stray `%%>` found at (%u:%u). This closing delimiter is not part of an ERB tag and will be treated as plain text. If you want a literal `%%>`, use the HTML entities `%>` instead.";
|
|
767
|
+
|
|
768
|
+
char message[209];
|
|
769
|
+
snprintf(
|
|
770
|
+
message,
|
|
771
|
+
sizeof(message),
|
|
772
|
+
message_template,
|
|
773
|
+
start.line,
|
|
774
|
+
start.column
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
stray_erb_closing_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
778
|
+
|
|
779
|
+
return stray_erb_closing_tag_error;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
void append_stray_erb_closing_tag_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
783
|
+
hb_array_append(errors, stray_erb_closing_tag_error_init(start, end, allocator));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
NESTED_ERB_TAG_ERROR_T* nested_erb_tag_error_init(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator) {
|
|
787
|
+
NESTED_ERB_TAG_ERROR_T* nested_erb_tag_error = hb_allocator_alloc(allocator, sizeof(NESTED_ERB_TAG_ERROR_T));
|
|
788
|
+
|
|
789
|
+
if (!nested_erb_tag_error) { return NULL; }
|
|
790
|
+
|
|
791
|
+
error_init(&nested_erb_tag_error->base, NESTED_ERB_TAG_ERROR, start, end);
|
|
792
|
+
|
|
793
|
+
const char* message_template = "ERB tag `%s` at (%u:%u) was terminated by nested `<%%` tag at (%zu:%zu). Nesting `<%%` tags is not supported.";
|
|
794
|
+
|
|
795
|
+
hb_string_T truncated_argument_0 = hb_string_truncate(opening_tag->value, ERROR_MESSAGES_TRUNCATED_LENGTH);
|
|
796
|
+
char* truncated_c_string_0 = hb_string_to_c_string_using_malloc(truncated_argument_0);
|
|
797
|
+
|
|
798
|
+
char message[298];
|
|
799
|
+
snprintf(
|
|
800
|
+
message,
|
|
801
|
+
sizeof(message),
|
|
802
|
+
message_template,
|
|
803
|
+
truncated_c_string_0 ? truncated_c_string_0 : "",
|
|
804
|
+
opening_tag->location.start.line,
|
|
805
|
+
opening_tag->location.start.column,
|
|
806
|
+
nested_tag_line,
|
|
807
|
+
nested_tag_column
|
|
808
|
+
);
|
|
809
|
+
|
|
810
|
+
if (truncated_c_string_0) { free(truncated_c_string_0); }
|
|
811
|
+
nested_erb_tag_error->base.message = hb_string_copy(hb_string(message), allocator);
|
|
812
|
+
|
|
813
|
+
nested_erb_tag_error->opening_tag = token_copy(opening_tag, allocator);
|
|
814
|
+
nested_erb_tag_error->nested_tag_line = nested_tag_line;
|
|
815
|
+
nested_erb_tag_error->nested_tag_column = nested_tag_column;
|
|
816
|
+
return nested_erb_tag_error;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
void append_nested_erb_tag_error(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors) {
|
|
820
|
+
hb_array_append(errors, nested_erb_tag_error_init(opening_tag, nested_tag_line, nested_tag_column, start, end, allocator));
|
|
821
|
+
}
|
|
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));
|
|
526
1030
|
}
|
|
527
1031
|
|
|
528
|
-
|
|
1032
|
+
hb_string_T error_type_to_string(ERROR_T* error) {
|
|
529
1033
|
switch (error->type) {
|
|
530
|
-
case UNEXPECTED_ERROR: return "UNEXPECTED_ERROR";
|
|
531
|
-
case UNEXPECTED_TOKEN_ERROR: return "UNEXPECTED_TOKEN_ERROR";
|
|
532
|
-
case MISSING_OPENING_TAG_ERROR: return "MISSING_OPENING_TAG_ERROR";
|
|
533
|
-
case MISSING_CLOSING_TAG_ERROR: return "MISSING_CLOSING_TAG_ERROR";
|
|
534
|
-
case TAG_NAMES_MISMATCH_ERROR: return "TAG_NAMES_MISMATCH_ERROR";
|
|
535
|
-
case
|
|
536
|
-
case
|
|
537
|
-
case
|
|
538
|
-
case
|
|
539
|
-
case
|
|
540
|
-
case
|
|
541
|
-
case
|
|
542
|
-
case
|
|
1034
|
+
case UNEXPECTED_ERROR: return hb_string("UNEXPECTED_ERROR");
|
|
1035
|
+
case UNEXPECTED_TOKEN_ERROR: return hb_string("UNEXPECTED_TOKEN_ERROR");
|
|
1036
|
+
case MISSING_OPENING_TAG_ERROR: return hb_string("MISSING_OPENING_TAG_ERROR");
|
|
1037
|
+
case MISSING_CLOSING_TAG_ERROR: return hb_string("MISSING_CLOSING_TAG_ERROR");
|
|
1038
|
+
case TAG_NAMES_MISMATCH_ERROR: return hb_string("TAG_NAMES_MISMATCH_ERROR");
|
|
1039
|
+
case VOID_ELEMENT_CLOSING_TAG_ERROR: return hb_string("VOID_ELEMENT_CLOSING_TAG_ERROR");
|
|
1040
|
+
case UNCLOSED_ELEMENT_ERROR: return hb_string("UNCLOSED_ELEMENT_ERROR");
|
|
1041
|
+
case RUBY_PARSE_ERROR: return hb_string("RUBY_PARSE_ERROR");
|
|
1042
|
+
case ERB_CONTROL_FLOW_SCOPE_ERROR: return hb_string("ERB_CONTROL_FLOW_SCOPE_ERROR");
|
|
1043
|
+
case MISSING_ERB_END_TAG_ERROR: return hb_string("MISSING_ERB_END_TAG_ERROR");
|
|
1044
|
+
case ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR: return hb_string("ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR");
|
|
1045
|
+
case ERB_CASE_WITH_CONDITIONS_ERROR: return hb_string("ERB_CASE_WITH_CONDITIONS_ERROR");
|
|
1046
|
+
case CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR: return hb_string("CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR");
|
|
1047
|
+
case CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR: return hb_string("CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR");
|
|
1048
|
+
case INVALID_COMMENT_CLOSING_TAG_ERROR: return hb_string("INVALID_COMMENT_CLOSING_TAG_ERROR");
|
|
1049
|
+
case OMITTED_CLOSING_TAG_ERROR: return hb_string("OMITTED_CLOSING_TAG_ERROR");
|
|
1050
|
+
case UNCLOSED_OPEN_TAG_ERROR: return hb_string("UNCLOSED_OPEN_TAG_ERROR");
|
|
1051
|
+
case UNCLOSED_CLOSE_TAG_ERROR: return hb_string("UNCLOSED_CLOSE_TAG_ERROR");
|
|
1052
|
+
case UNCLOSED_QUOTE_ERROR: return hb_string("UNCLOSED_QUOTE_ERROR");
|
|
1053
|
+
case MISSING_ATTRIBUTE_VALUE_ERROR: return hb_string("MISSING_ATTRIBUTE_VALUE_ERROR");
|
|
1054
|
+
case UNCLOSED_ERB_TAG_ERROR: return hb_string("UNCLOSED_ERB_TAG_ERROR");
|
|
1055
|
+
case STRAY_ERB_CLOSING_TAG_ERROR: return hb_string("STRAY_ERB_CLOSING_TAG_ERROR");
|
|
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");
|
|
543
1064
|
}
|
|
544
1065
|
|
|
545
|
-
return "Unknown error_type_T";
|
|
1066
|
+
return hb_string("Unknown error_type_T");
|
|
546
1067
|
}
|
|
547
1068
|
|
|
548
|
-
|
|
1069
|
+
hb_string_T error_human_type(ERROR_T* error) {
|
|
549
1070
|
switch (error->type) {
|
|
550
|
-
case UNEXPECTED_ERROR: return "UnexpectedError";
|
|
551
|
-
case UNEXPECTED_TOKEN_ERROR: return "UnexpectedTokenError";
|
|
552
|
-
case MISSING_OPENING_TAG_ERROR: return "MissingOpeningTagError";
|
|
553
|
-
case MISSING_CLOSING_TAG_ERROR: return "MissingClosingTagError";
|
|
554
|
-
case TAG_NAMES_MISMATCH_ERROR: return "TagNamesMismatchError";
|
|
555
|
-
case
|
|
556
|
-
case
|
|
557
|
-
case
|
|
558
|
-
case
|
|
559
|
-
case
|
|
560
|
-
case
|
|
561
|
-
case
|
|
562
|
-
case
|
|
1071
|
+
case UNEXPECTED_ERROR: return hb_string("UnexpectedError");
|
|
1072
|
+
case UNEXPECTED_TOKEN_ERROR: return hb_string("UnexpectedTokenError");
|
|
1073
|
+
case MISSING_OPENING_TAG_ERROR: return hb_string("MissingOpeningTagError");
|
|
1074
|
+
case MISSING_CLOSING_TAG_ERROR: return hb_string("MissingClosingTagError");
|
|
1075
|
+
case TAG_NAMES_MISMATCH_ERROR: return hb_string("TagNamesMismatchError");
|
|
1076
|
+
case VOID_ELEMENT_CLOSING_TAG_ERROR: return hb_string("VoidElementClosingTagError");
|
|
1077
|
+
case UNCLOSED_ELEMENT_ERROR: return hb_string("UnclosedElementError");
|
|
1078
|
+
case RUBY_PARSE_ERROR: return hb_string("RubyParseError");
|
|
1079
|
+
case ERB_CONTROL_FLOW_SCOPE_ERROR: return hb_string("ERBControlFlowScopeError");
|
|
1080
|
+
case MISSING_ERB_END_TAG_ERROR: return hb_string("MissingERBEndTagError");
|
|
1081
|
+
case ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR: return hb_string("ERBMultipleBlocksInTagError");
|
|
1082
|
+
case ERB_CASE_WITH_CONDITIONS_ERROR: return hb_string("ERBCaseWithConditionsError");
|
|
1083
|
+
case CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR: return hb_string("ConditionalElementMultipleTagsError");
|
|
1084
|
+
case CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR: return hb_string("ConditionalElementConditionMismatchError");
|
|
1085
|
+
case INVALID_COMMENT_CLOSING_TAG_ERROR: return hb_string("InvalidCommentClosingTagError");
|
|
1086
|
+
case OMITTED_CLOSING_TAG_ERROR: return hb_string("OmittedClosingTagError");
|
|
1087
|
+
case UNCLOSED_OPEN_TAG_ERROR: return hb_string("UnclosedOpenTagError");
|
|
1088
|
+
case UNCLOSED_CLOSE_TAG_ERROR: return hb_string("UnclosedCloseTagError");
|
|
1089
|
+
case UNCLOSED_QUOTE_ERROR: return hb_string("UnclosedQuoteError");
|
|
1090
|
+
case MISSING_ATTRIBUTE_VALUE_ERROR: return hb_string("MissingAttributeValueError");
|
|
1091
|
+
case UNCLOSED_ERB_TAG_ERROR: return hb_string("UnclosedERBTagError");
|
|
1092
|
+
case STRAY_ERB_CLOSING_TAG_ERROR: return hb_string("StrayERBClosingTagError");
|
|
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");
|
|
563
1101
|
}
|
|
564
1102
|
|
|
565
|
-
return "Unknown error_type_T";
|
|
1103
|
+
return hb_string("Unknown error_type_T");
|
|
566
1104
|
}
|
|
567
1105
|
|
|
568
|
-
void error_free_base_error(ERROR_T* error) {
|
|
1106
|
+
void error_free_base_error(ERROR_T* error, hb_allocator_T* allocator) {
|
|
569
1107
|
if (error == NULL) { return; }
|
|
570
1108
|
|
|
571
|
-
if (error->message
|
|
1109
|
+
if (!hb_string_is_null(error->message)) { hb_allocator_dealloc(allocator, error->message.data); }
|
|
572
1110
|
|
|
573
|
-
|
|
1111
|
+
hb_allocator_dealloc(allocator, error);
|
|
574
1112
|
}
|
|
575
1113
|
|
|
576
|
-
static void error_free_unexpected_error(UNEXPECTED_ERROR_T* unexpected_error) {
|
|
577
|
-
if (unexpected_error->description != NULL) {
|
|
578
|
-
if (unexpected_error->expected != NULL) {
|
|
579
|
-
if (unexpected_error->found != NULL) {
|
|
1114
|
+
static void error_free_unexpected_error(UNEXPECTED_ERROR_T* unexpected_error, hb_allocator_T* allocator) {
|
|
1115
|
+
if (unexpected_error->description.data != NULL) { hb_allocator_dealloc(allocator, unexpected_error->description.data); }
|
|
1116
|
+
if (unexpected_error->expected.data != NULL) { hb_allocator_dealloc(allocator, unexpected_error->expected.data); }
|
|
1117
|
+
if (unexpected_error->found.data != NULL) { hb_allocator_dealloc(allocator, unexpected_error->found.data); }
|
|
580
1118
|
|
|
581
|
-
error_free_base_error(&unexpected_error->base);
|
|
1119
|
+
error_free_base_error(&unexpected_error->base, allocator);
|
|
582
1120
|
}
|
|
583
1121
|
|
|
584
|
-
static void error_free_unexpected_token_error(UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error) {
|
|
1122
|
+
static void error_free_unexpected_token_error(UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error, hb_allocator_T* allocator) {
|
|
585
1123
|
// token_type_T is part of struct
|
|
586
|
-
if (unexpected_token_error->found != NULL) { token_free(unexpected_token_error->found); }
|
|
1124
|
+
if (unexpected_token_error->found != NULL) { token_free(unexpected_token_error->found, allocator); }
|
|
587
1125
|
|
|
588
|
-
error_free_base_error(&unexpected_token_error->base);
|
|
1126
|
+
error_free_base_error(&unexpected_token_error->base, allocator);
|
|
589
1127
|
}
|
|
590
1128
|
|
|
591
|
-
static void error_free_missing_opening_tag_error(MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error) {
|
|
592
|
-
if (missing_opening_tag_error->closing_tag != NULL) { token_free(missing_opening_tag_error->closing_tag); }
|
|
1129
|
+
static void error_free_missing_opening_tag_error(MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error, hb_allocator_T* allocator) {
|
|
1130
|
+
if (missing_opening_tag_error->closing_tag != NULL) { token_free(missing_opening_tag_error->closing_tag, allocator); }
|
|
593
1131
|
|
|
594
|
-
error_free_base_error(&missing_opening_tag_error->base);
|
|
1132
|
+
error_free_base_error(&missing_opening_tag_error->base, allocator);
|
|
595
1133
|
}
|
|
596
1134
|
|
|
597
|
-
static void error_free_missing_closing_tag_error(MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error) {
|
|
598
|
-
if (missing_closing_tag_error->opening_tag != NULL) { token_free(missing_closing_tag_error->opening_tag); }
|
|
1135
|
+
static void error_free_missing_closing_tag_error(MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error, hb_allocator_T* allocator) {
|
|
1136
|
+
if (missing_closing_tag_error->opening_tag != NULL) { token_free(missing_closing_tag_error->opening_tag, allocator); }
|
|
599
1137
|
|
|
600
|
-
error_free_base_error(&missing_closing_tag_error->base);
|
|
1138
|
+
error_free_base_error(&missing_closing_tag_error->base, allocator);
|
|
601
1139
|
}
|
|
602
1140
|
|
|
603
|
-
static void error_free_tag_names_mismatch_error(TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error) {
|
|
604
|
-
if (tag_names_mismatch_error->opening_tag != NULL) { token_free(tag_names_mismatch_error->opening_tag); }
|
|
605
|
-
if (tag_names_mismatch_error->closing_tag != NULL) { token_free(tag_names_mismatch_error->closing_tag); }
|
|
1141
|
+
static void error_free_tag_names_mismatch_error(TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error, hb_allocator_T* allocator) {
|
|
1142
|
+
if (tag_names_mismatch_error->opening_tag != NULL) { token_free(tag_names_mismatch_error->opening_tag, allocator); }
|
|
1143
|
+
if (tag_names_mismatch_error->closing_tag != NULL) { token_free(tag_names_mismatch_error->closing_tag, allocator); }
|
|
606
1144
|
|
|
607
|
-
error_free_base_error(&tag_names_mismatch_error->base);
|
|
1145
|
+
error_free_base_error(&tag_names_mismatch_error->base, allocator);
|
|
608
1146
|
}
|
|
609
1147
|
|
|
610
|
-
static void
|
|
611
|
-
if (
|
|
612
|
-
if (
|
|
1148
|
+
static void error_free_void_element_closing_tag_error(VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error, hb_allocator_T* allocator) {
|
|
1149
|
+
if (void_element_closing_tag_error->tag_name != NULL) { token_free(void_element_closing_tag_error->tag_name, allocator); }
|
|
1150
|
+
if (void_element_closing_tag_error->expected.data != NULL) { hb_allocator_dealloc(allocator, void_element_closing_tag_error->expected.data); }
|
|
1151
|
+
if (void_element_closing_tag_error->found.data != NULL) { hb_allocator_dealloc(allocator, void_element_closing_tag_error->found.data); }
|
|
613
1152
|
|
|
614
|
-
error_free_base_error(&
|
|
1153
|
+
error_free_base_error(&void_element_closing_tag_error->base, allocator);
|
|
615
1154
|
}
|
|
616
1155
|
|
|
617
|
-
static void
|
|
618
|
-
if (
|
|
619
|
-
if (void_element_closing_tag_error->expected != NULL) { free((char*) void_element_closing_tag_error->expected); }
|
|
620
|
-
if (void_element_closing_tag_error->found != NULL) { free((char*) void_element_closing_tag_error->found); }
|
|
1156
|
+
static void error_free_unclosed_element_error(UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error, hb_allocator_T* allocator) {
|
|
1157
|
+
if (unclosed_element_error->opening_tag != NULL) { token_free(unclosed_element_error->opening_tag, allocator); }
|
|
621
1158
|
|
|
622
|
-
error_free_base_error(&
|
|
1159
|
+
error_free_base_error(&unclosed_element_error->base, allocator);
|
|
623
1160
|
}
|
|
624
1161
|
|
|
625
|
-
static void
|
|
626
|
-
if (
|
|
1162
|
+
static void error_free_ruby_parse_error(RUBY_PARSE_ERROR_T* ruby_parse_error, hb_allocator_T* allocator) {
|
|
1163
|
+
if (ruby_parse_error->error_message.data != NULL) { hb_allocator_dealloc(allocator, ruby_parse_error->error_message.data); }
|
|
1164
|
+
if (ruby_parse_error->diagnostic_id.data != NULL) { hb_allocator_dealloc(allocator, ruby_parse_error->diagnostic_id.data); }
|
|
1165
|
+
if (ruby_parse_error->level.data != NULL) { hb_allocator_dealloc(allocator, ruby_parse_error->level.data); }
|
|
627
1166
|
|
|
628
|
-
error_free_base_error(&
|
|
1167
|
+
error_free_base_error(&ruby_parse_error->base, allocator);
|
|
629
1168
|
}
|
|
630
1169
|
|
|
631
|
-
static void
|
|
632
|
-
if (
|
|
633
|
-
if (ruby_parse_error->diagnostic_id != NULL) { free((char*) ruby_parse_error->diagnostic_id); }
|
|
634
|
-
if (ruby_parse_error->level != NULL) { free((char*) ruby_parse_error->level); }
|
|
1170
|
+
static void error_free_erb_control_flow_scope_error(ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error, hb_allocator_T* allocator) {
|
|
1171
|
+
if (erb_control_flow_scope_error->keyword.data != NULL) { hb_allocator_dealloc(allocator, erb_control_flow_scope_error->keyword.data); }
|
|
635
1172
|
|
|
636
|
-
error_free_base_error(&
|
|
1173
|
+
error_free_base_error(&erb_control_flow_scope_error->base, allocator);
|
|
637
1174
|
}
|
|
638
1175
|
|
|
639
|
-
static void
|
|
640
|
-
if (
|
|
1176
|
+
static void error_free_missing_erb_end_tag_error(MISSING_ERB_END_TAG_ERROR_T* missing_erb_end_tag_error, hb_allocator_T* allocator) {
|
|
1177
|
+
if (missing_erb_end_tag_error->keyword.data != NULL) { hb_allocator_dealloc(allocator, missing_erb_end_tag_error->keyword.data); }
|
|
641
1178
|
|
|
642
|
-
error_free_base_error(&
|
|
1179
|
+
error_free_base_error(&missing_erb_end_tag_error->base, allocator);
|
|
643
1180
|
}
|
|
644
1181
|
|
|
645
|
-
static void
|
|
646
|
-
|
|
1182
|
+
static void error_free_erb_multiple_blocks_in_tag_error(ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* erb_multiple_blocks_in_tag_error, hb_allocator_T* allocator) {
|
|
1183
|
+
/* no ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T specific fields to free up */
|
|
647
1184
|
|
|
648
|
-
error_free_base_error(&
|
|
1185
|
+
error_free_base_error(&erb_multiple_blocks_in_tag_error->base, allocator);
|
|
649
1186
|
}
|
|
650
1187
|
|
|
651
|
-
static void
|
|
652
|
-
/* no
|
|
1188
|
+
static void error_free_erb_case_with_conditions_error(ERB_CASE_WITH_CONDITIONS_ERROR_T* erb_case_with_conditions_error, hb_allocator_T* allocator) {
|
|
1189
|
+
/* no ERB_CASE_WITH_CONDITIONS_ERROR_T specific fields to free up */
|
|
653
1190
|
|
|
654
|
-
error_free_base_error(&
|
|
1191
|
+
error_free_base_error(&erb_case_with_conditions_error->base, allocator);
|
|
655
1192
|
}
|
|
656
1193
|
|
|
657
|
-
static void
|
|
658
|
-
|
|
1194
|
+
static void error_free_conditional_element_multiple_tags_error(CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T* conditional_element_multiple_tags_error, hb_allocator_T* allocator) {
|
|
1195
|
+
// size_t is part of struct
|
|
1196
|
+
// size_t is part of struct
|
|
1197
|
+
|
|
1198
|
+
error_free_base_error(&conditional_element_multiple_tags_error->base, allocator);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
static void error_free_conditional_element_condition_mismatch_error(CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T* conditional_element_condition_mismatch_error, hb_allocator_T* allocator) {
|
|
1202
|
+
if (conditional_element_condition_mismatch_error->tag_name.data != NULL) { hb_allocator_dealloc(allocator, conditional_element_condition_mismatch_error->tag_name.data); }
|
|
1203
|
+
if (conditional_element_condition_mismatch_error->open_condition.data != NULL) { hb_allocator_dealloc(allocator, conditional_element_condition_mismatch_error->open_condition.data); }
|
|
1204
|
+
// size_t is part of struct
|
|
1205
|
+
// size_t is part of struct
|
|
1206
|
+
if (conditional_element_condition_mismatch_error->close_condition.data != NULL) { hb_allocator_dealloc(allocator, conditional_element_condition_mismatch_error->close_condition.data); }
|
|
1207
|
+
// size_t is part of struct
|
|
1208
|
+
// size_t is part of struct
|
|
1209
|
+
|
|
1210
|
+
error_free_base_error(&conditional_element_condition_mismatch_error->base, allocator);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
static void error_free_invalid_comment_closing_tag_error(INVALID_COMMENT_CLOSING_TAG_ERROR_T* invalid_comment_closing_tag_error, hb_allocator_T* allocator) {
|
|
1214
|
+
if (invalid_comment_closing_tag_error->closing_tag != NULL) { token_free(invalid_comment_closing_tag_error->closing_tag, allocator); }
|
|
1215
|
+
|
|
1216
|
+
error_free_base_error(&invalid_comment_closing_tag_error->base, allocator);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
static void error_free_omitted_closing_tag_error(OMITTED_CLOSING_TAG_ERROR_T* omitted_closing_tag_error, hb_allocator_T* allocator) {
|
|
1220
|
+
if (omitted_closing_tag_error->opening_tag != NULL) { token_free(omitted_closing_tag_error->opening_tag, allocator); }
|
|
1221
|
+
// position_T is part of struct
|
|
1222
|
+
|
|
1223
|
+
error_free_base_error(&omitted_closing_tag_error->base, allocator);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
static void error_free_unclosed_open_tag_error(UNCLOSED_OPEN_TAG_ERROR_T* unclosed_open_tag_error, hb_allocator_T* allocator) {
|
|
1227
|
+
if (unclosed_open_tag_error->tag_name != NULL) { token_free(unclosed_open_tag_error->tag_name, allocator); }
|
|
1228
|
+
|
|
1229
|
+
error_free_base_error(&unclosed_open_tag_error->base, allocator);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
static void error_free_unclosed_close_tag_error(UNCLOSED_CLOSE_TAG_ERROR_T* unclosed_close_tag_error, hb_allocator_T* allocator) {
|
|
1233
|
+
if (unclosed_close_tag_error->tag_name != NULL) { token_free(unclosed_close_tag_error->tag_name, allocator); }
|
|
1234
|
+
|
|
1235
|
+
error_free_base_error(&unclosed_close_tag_error->base, allocator);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
static void error_free_unclosed_quote_error(UNCLOSED_QUOTE_ERROR_T* unclosed_quote_error, hb_allocator_T* allocator) {
|
|
1239
|
+
if (unclosed_quote_error->opening_quote != NULL) { token_free(unclosed_quote_error->opening_quote, allocator); }
|
|
1240
|
+
|
|
1241
|
+
error_free_base_error(&unclosed_quote_error->base, allocator);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
static void error_free_missing_attribute_value_error(MISSING_ATTRIBUTE_VALUE_ERROR_T* missing_attribute_value_error, hb_allocator_T* allocator) {
|
|
1245
|
+
if (missing_attribute_value_error->attribute_name.data != NULL) { hb_allocator_dealloc(allocator, missing_attribute_value_error->attribute_name.data); }
|
|
1246
|
+
|
|
1247
|
+
error_free_base_error(&missing_attribute_value_error->base, allocator);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
static void error_free_unclosed_erb_tag_error(UNCLOSED_ERB_TAG_ERROR_T* unclosed_erb_tag_error, hb_allocator_T* allocator) {
|
|
1251
|
+
if (unclosed_erb_tag_error->opening_tag != NULL) { token_free(unclosed_erb_tag_error->opening_tag, allocator); }
|
|
1252
|
+
|
|
1253
|
+
error_free_base_error(&unclosed_erb_tag_error->base, allocator);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
static void error_free_stray_erb_closing_tag_error(STRAY_ERB_CLOSING_TAG_ERROR_T* stray_erb_closing_tag_error, hb_allocator_T* allocator) {
|
|
1257
|
+
/* no STRAY_ERB_CLOSING_TAG_ERROR_T specific fields to free up */
|
|
659
1258
|
|
|
660
|
-
error_free_base_error(&
|
|
1259
|
+
error_free_base_error(&stray_erb_closing_tag_error->base, allocator);
|
|
661
1260
|
}
|
|
662
1261
|
|
|
663
|
-
void
|
|
1262
|
+
static void error_free_nested_erb_tag_error(NESTED_ERB_TAG_ERROR_T* nested_erb_tag_error, hb_allocator_T* allocator) {
|
|
1263
|
+
if (nested_erb_tag_error->opening_tag != NULL) { token_free(nested_erb_tag_error->opening_tag, allocator); }
|
|
1264
|
+
// size_t is part of struct
|
|
1265
|
+
// size_t is part of struct
|
|
1266
|
+
|
|
1267
|
+
error_free_base_error(&nested_erb_tag_error->base, allocator);
|
|
1268
|
+
}
|
|
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
|
+
|
|
1314
|
+
void error_free(ERROR_T* error, hb_allocator_T* allocator) {
|
|
664
1315
|
if (!error) { return; }
|
|
665
1316
|
|
|
666
1317
|
switch (error->type) {
|
|
667
|
-
case UNEXPECTED_ERROR: error_free_unexpected_error((UNEXPECTED_ERROR_T*) error); break;
|
|
668
|
-
case UNEXPECTED_TOKEN_ERROR: error_free_unexpected_token_error((UNEXPECTED_TOKEN_ERROR_T*) error); break;
|
|
669
|
-
case MISSING_OPENING_TAG_ERROR: error_free_missing_opening_tag_error((MISSING_OPENING_TAG_ERROR_T*) error); break;
|
|
670
|
-
case MISSING_CLOSING_TAG_ERROR: error_free_missing_closing_tag_error((MISSING_CLOSING_TAG_ERROR_T*) error); break;
|
|
671
|
-
case TAG_NAMES_MISMATCH_ERROR: error_free_tag_names_mismatch_error((TAG_NAMES_MISMATCH_ERROR_T*) error); break;
|
|
672
|
-
case
|
|
673
|
-
case
|
|
674
|
-
case
|
|
675
|
-
case
|
|
676
|
-
case
|
|
677
|
-
case
|
|
678
|
-
case
|
|
679
|
-
case
|
|
1318
|
+
case UNEXPECTED_ERROR: error_free_unexpected_error((UNEXPECTED_ERROR_T*) error, allocator); break;
|
|
1319
|
+
case UNEXPECTED_TOKEN_ERROR: error_free_unexpected_token_error((UNEXPECTED_TOKEN_ERROR_T*) error, allocator); break;
|
|
1320
|
+
case MISSING_OPENING_TAG_ERROR: error_free_missing_opening_tag_error((MISSING_OPENING_TAG_ERROR_T*) error, allocator); break;
|
|
1321
|
+
case MISSING_CLOSING_TAG_ERROR: error_free_missing_closing_tag_error((MISSING_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
1322
|
+
case TAG_NAMES_MISMATCH_ERROR: error_free_tag_names_mismatch_error((TAG_NAMES_MISMATCH_ERROR_T*) error, allocator); break;
|
|
1323
|
+
case VOID_ELEMENT_CLOSING_TAG_ERROR: error_free_void_element_closing_tag_error((VOID_ELEMENT_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
1324
|
+
case UNCLOSED_ELEMENT_ERROR: error_free_unclosed_element_error((UNCLOSED_ELEMENT_ERROR_T*) error, allocator); break;
|
|
1325
|
+
case RUBY_PARSE_ERROR: error_free_ruby_parse_error((RUBY_PARSE_ERROR_T*) error, allocator); break;
|
|
1326
|
+
case ERB_CONTROL_FLOW_SCOPE_ERROR: error_free_erb_control_flow_scope_error((ERB_CONTROL_FLOW_SCOPE_ERROR_T*) error, allocator); break;
|
|
1327
|
+
case MISSING_ERB_END_TAG_ERROR: error_free_missing_erb_end_tag_error((MISSING_ERB_END_TAG_ERROR_T*) error, allocator); break;
|
|
1328
|
+
case ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR: error_free_erb_multiple_blocks_in_tag_error((ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T*) error, allocator); break;
|
|
1329
|
+
case ERB_CASE_WITH_CONDITIONS_ERROR: error_free_erb_case_with_conditions_error((ERB_CASE_WITH_CONDITIONS_ERROR_T*) error, allocator); break;
|
|
1330
|
+
case CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR: error_free_conditional_element_multiple_tags_error((CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T*) error, allocator); break;
|
|
1331
|
+
case CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR: error_free_conditional_element_condition_mismatch_error((CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T*) error, allocator); break;
|
|
1332
|
+
case INVALID_COMMENT_CLOSING_TAG_ERROR: error_free_invalid_comment_closing_tag_error((INVALID_COMMENT_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
1333
|
+
case OMITTED_CLOSING_TAG_ERROR: error_free_omitted_closing_tag_error((OMITTED_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
1334
|
+
case UNCLOSED_OPEN_TAG_ERROR: error_free_unclosed_open_tag_error((UNCLOSED_OPEN_TAG_ERROR_T*) error, allocator); break;
|
|
1335
|
+
case UNCLOSED_CLOSE_TAG_ERROR: error_free_unclosed_close_tag_error((UNCLOSED_CLOSE_TAG_ERROR_T*) error, allocator); break;
|
|
1336
|
+
case UNCLOSED_QUOTE_ERROR: error_free_unclosed_quote_error((UNCLOSED_QUOTE_ERROR_T*) error, allocator); break;
|
|
1337
|
+
case MISSING_ATTRIBUTE_VALUE_ERROR: error_free_missing_attribute_value_error((MISSING_ATTRIBUTE_VALUE_ERROR_T*) error, allocator); break;
|
|
1338
|
+
case UNCLOSED_ERB_TAG_ERROR: error_free_unclosed_erb_tag_error((UNCLOSED_ERB_TAG_ERROR_T*) error, allocator); break;
|
|
1339
|
+
case STRAY_ERB_CLOSING_TAG_ERROR: error_free_stray_erb_closing_tag_error((STRAY_ERB_CLOSING_TAG_ERROR_T*) error, allocator); break;
|
|
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;
|
|
680
1348
|
}
|
|
681
1349
|
}
|
|
682
1350
|
|
|
1351
|
+
#ifndef HERB_EXCLUDE_PRETTYPRINT
|
|
1352
|
+
|
|
683
1353
|
void error_pretty_print_array(
|
|
684
1354
|
const char* name, hb_array_T* array, const size_t indent, const size_t relative_indent, const bool last_property,
|
|
685
1355
|
hb_buffer_T* buffer
|
|
@@ -728,30 +1398,30 @@ static void error_pretty_print_unexpected_error(UNEXPECTED_ERROR_T* error, const
|
|
|
728
1398
|
if (!error) { return; }
|
|
729
1399
|
|
|
730
1400
|
hb_buffer_append(buffer, "@ ");
|
|
731
|
-
|
|
1401
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
732
1402
|
hb_buffer_append(buffer, " ");
|
|
733
1403
|
|
|
734
1404
|
pretty_print_location(error->base.location, buffer);
|
|
735
1405
|
hb_buffer_append(buffer, "\n");
|
|
736
1406
|
|
|
737
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
738
|
-
pretty_print_quoted_property(hb_string("description"),
|
|
739
|
-
pretty_print_quoted_property(hb_string("expected"),
|
|
740
|
-
pretty_print_quoted_property(hb_string("found"),
|
|
1407
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1408
|
+
pretty_print_quoted_property(hb_string("description"), error->description, indent, relative_indent, false, buffer);
|
|
1409
|
+
pretty_print_quoted_property(hb_string("expected"), error->expected, indent, relative_indent, false, buffer);
|
|
1410
|
+
pretty_print_quoted_property(hb_string("found"), error->found, indent, relative_indent, true, buffer);
|
|
741
1411
|
}
|
|
742
1412
|
|
|
743
1413
|
static void error_pretty_print_unexpected_token_error(UNEXPECTED_TOKEN_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
744
1414
|
if (!error) { return; }
|
|
745
1415
|
|
|
746
1416
|
hb_buffer_append(buffer, "@ ");
|
|
747
|
-
|
|
1417
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
748
1418
|
hb_buffer_append(buffer, " ");
|
|
749
1419
|
|
|
750
1420
|
pretty_print_location(error->base.location, buffer);
|
|
751
1421
|
hb_buffer_append(buffer, "\n");
|
|
752
1422
|
|
|
753
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
754
|
-
pretty_print_property(
|
|
1423
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1424
|
+
pretty_print_property(token_type_to_string(error->expected_type), hb_string("expected_type"), indent, relative_indent, false, buffer);
|
|
755
1425
|
pretty_print_token_property(error->found, hb_string("found"), indent, relative_indent, true, buffer);
|
|
756
1426
|
}
|
|
757
1427
|
|
|
@@ -759,13 +1429,13 @@ static void error_pretty_print_missing_opening_tag_error(MISSING_OPENING_TAG_ERR
|
|
|
759
1429
|
if (!error) { return; }
|
|
760
1430
|
|
|
761
1431
|
hb_buffer_append(buffer, "@ ");
|
|
762
|
-
|
|
1432
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
763
1433
|
hb_buffer_append(buffer, " ");
|
|
764
1434
|
|
|
765
1435
|
pretty_print_location(error->base.location, buffer);
|
|
766
1436
|
hb_buffer_append(buffer, "\n");
|
|
767
1437
|
|
|
768
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
1438
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
769
1439
|
pretty_print_token_property(error->closing_tag, hb_string("closing_tag"), indent, relative_indent, true, buffer);
|
|
770
1440
|
}
|
|
771
1441
|
|
|
@@ -773,13 +1443,13 @@ static void error_pretty_print_missing_closing_tag_error(MISSING_CLOSING_TAG_ERR
|
|
|
773
1443
|
if (!error) { return; }
|
|
774
1444
|
|
|
775
1445
|
hb_buffer_append(buffer, "@ ");
|
|
776
|
-
|
|
1446
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
777
1447
|
hb_buffer_append(buffer, " ");
|
|
778
1448
|
|
|
779
1449
|
pretty_print_location(error->base.location, buffer);
|
|
780
1450
|
hb_buffer_append(buffer, "\n");
|
|
781
1451
|
|
|
782
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
1452
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
783
1453
|
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, true, buffer);
|
|
784
1454
|
}
|
|
785
1455
|
|
|
@@ -787,130 +1457,376 @@ static void error_pretty_print_tag_names_mismatch_error(TAG_NAMES_MISMATCH_ERROR
|
|
|
787
1457
|
if (!error) { return; }
|
|
788
1458
|
|
|
789
1459
|
hb_buffer_append(buffer, "@ ");
|
|
790
|
-
|
|
1460
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
791
1461
|
hb_buffer_append(buffer, " ");
|
|
792
1462
|
|
|
793
1463
|
pretty_print_location(error->base.location, buffer);
|
|
794
1464
|
hb_buffer_append(buffer, "\n");
|
|
795
1465
|
|
|
796
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
1466
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
797
1467
|
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, false, buffer);
|
|
798
1468
|
pretty_print_token_property(error->closing_tag, hb_string("closing_tag"), indent, relative_indent, true, buffer);
|
|
799
1469
|
}
|
|
800
1470
|
|
|
801
|
-
static void
|
|
1471
|
+
static void error_pretty_print_void_element_closing_tag_error(VOID_ELEMENT_CLOSING_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
802
1472
|
if (!error) { return; }
|
|
803
1473
|
|
|
804
1474
|
hb_buffer_append(buffer, "@ ");
|
|
805
|
-
|
|
1475
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
806
1476
|
hb_buffer_append(buffer, " ");
|
|
807
1477
|
|
|
808
1478
|
pretty_print_location(error->base.location, buffer);
|
|
809
1479
|
hb_buffer_append(buffer, "\n");
|
|
810
1480
|
|
|
811
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
812
|
-
pretty_print_token_property(error->
|
|
813
|
-
|
|
1481
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1482
|
+
pretty_print_token_property(error->tag_name, hb_string("tag_name"), indent, relative_indent, false, buffer);
|
|
1483
|
+
pretty_print_quoted_property(hb_string("expected"), error->expected, indent, relative_indent, false, buffer);
|
|
1484
|
+
pretty_print_quoted_property(hb_string("found"), error->found, indent, relative_indent, true, buffer);
|
|
814
1485
|
}
|
|
815
1486
|
|
|
816
|
-
static void
|
|
1487
|
+
static void error_pretty_print_unclosed_element_error(UNCLOSED_ELEMENT_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
817
1488
|
if (!error) { return; }
|
|
818
1489
|
|
|
819
1490
|
hb_buffer_append(buffer, "@ ");
|
|
820
|
-
|
|
1491
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
821
1492
|
hb_buffer_append(buffer, " ");
|
|
822
1493
|
|
|
823
1494
|
pretty_print_location(error->base.location, buffer);
|
|
824
1495
|
hb_buffer_append(buffer, "\n");
|
|
825
1496
|
|
|
826
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
827
|
-
pretty_print_token_property(error->
|
|
828
|
-
pretty_print_quoted_property(hb_string("expected"), hb_string(error->expected), indent, relative_indent, false, buffer);
|
|
829
|
-
pretty_print_quoted_property(hb_string("found"), hb_string(error->found), indent, relative_indent, true, buffer);
|
|
1497
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1498
|
+
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, true, buffer);
|
|
830
1499
|
}
|
|
831
1500
|
|
|
832
|
-
static void
|
|
1501
|
+
static void error_pretty_print_ruby_parse_error(RUBY_PARSE_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1502
|
+
if (!error) { return; }
|
|
1503
|
+
|
|
1504
|
+
hb_buffer_append(buffer, "@ ");
|
|
1505
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1506
|
+
hb_buffer_append(buffer, " ");
|
|
1507
|
+
|
|
1508
|
+
pretty_print_location(error->base.location, buffer);
|
|
1509
|
+
hb_buffer_append(buffer, "\n");
|
|
1510
|
+
|
|
1511
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1512
|
+
pretty_print_quoted_property(hb_string("error_message"), error->error_message, indent, relative_indent, false, buffer);
|
|
1513
|
+
pretty_print_quoted_property(hb_string("diagnostic_id"), error->diagnostic_id, indent, relative_indent, false, buffer);
|
|
1514
|
+
pretty_print_quoted_property(hb_string("level"), error->level, indent, relative_indent, true, buffer);
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
static void error_pretty_print_erb_control_flow_scope_error(ERB_CONTROL_FLOW_SCOPE_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
833
1518
|
if (!error) { return; }
|
|
834
1519
|
|
|
835
1520
|
hb_buffer_append(buffer, "@ ");
|
|
836
|
-
|
|
1521
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
837
1522
|
hb_buffer_append(buffer, " ");
|
|
838
1523
|
|
|
839
1524
|
pretty_print_location(error->base.location, buffer);
|
|
840
1525
|
hb_buffer_append(buffer, "\n");
|
|
841
1526
|
|
|
842
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
1527
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1528
|
+
pretty_print_quoted_property(hb_string("keyword"), error->keyword, indent, relative_indent, true, buffer);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
static void error_pretty_print_missing_erb_end_tag_error(MISSING_ERB_END_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1532
|
+
if (!error) { return; }
|
|
1533
|
+
|
|
1534
|
+
hb_buffer_append(buffer, "@ ");
|
|
1535
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1536
|
+
hb_buffer_append(buffer, " ");
|
|
1537
|
+
|
|
1538
|
+
pretty_print_location(error->base.location, buffer);
|
|
1539
|
+
hb_buffer_append(buffer, "\n");
|
|
1540
|
+
|
|
1541
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1542
|
+
pretty_print_quoted_property(hb_string("keyword"), error->keyword, indent, relative_indent, true, buffer);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
static void error_pretty_print_erb_multiple_blocks_in_tag_error(ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1546
|
+
if (!error) { return; }
|
|
1547
|
+
|
|
1548
|
+
hb_buffer_append(buffer, "@ ");
|
|
1549
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1550
|
+
hb_buffer_append(buffer, " ");
|
|
1551
|
+
|
|
1552
|
+
pretty_print_location(error->base.location, buffer);
|
|
1553
|
+
hb_buffer_append(buffer, "\n");
|
|
1554
|
+
|
|
1555
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, true, buffer);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
static void error_pretty_print_erb_case_with_conditions_error(ERB_CASE_WITH_CONDITIONS_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1559
|
+
if (!error) { return; }
|
|
1560
|
+
|
|
1561
|
+
hb_buffer_append(buffer, "@ ");
|
|
1562
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1563
|
+
hb_buffer_append(buffer, " ");
|
|
1564
|
+
|
|
1565
|
+
pretty_print_location(error->base.location, buffer);
|
|
1566
|
+
hb_buffer_append(buffer, "\n");
|
|
1567
|
+
|
|
1568
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, true, buffer);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
static void error_pretty_print_conditional_element_multiple_tags_error(CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1572
|
+
if (!error) { return; }
|
|
1573
|
+
|
|
1574
|
+
hb_buffer_append(buffer, "@ ");
|
|
1575
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1576
|
+
hb_buffer_append(buffer, " ");
|
|
1577
|
+
|
|
1578
|
+
pretty_print_location(error->base.location, buffer);
|
|
1579
|
+
hb_buffer_append(buffer, "\n");
|
|
1580
|
+
|
|
1581
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1582
|
+
pretty_print_size_t_property(error->line, hb_string("line"), indent, relative_indent, false, buffer);
|
|
1583
|
+
pretty_print_size_t_property(error->column, hb_string("column"), indent, relative_indent, true, buffer);
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
static void error_pretty_print_conditional_element_condition_mismatch_error(CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1587
|
+
if (!error) { return; }
|
|
1588
|
+
|
|
1589
|
+
hb_buffer_append(buffer, "@ ");
|
|
1590
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1591
|
+
hb_buffer_append(buffer, " ");
|
|
1592
|
+
|
|
1593
|
+
pretty_print_location(error->base.location, buffer);
|
|
1594
|
+
hb_buffer_append(buffer, "\n");
|
|
1595
|
+
|
|
1596
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1597
|
+
pretty_print_quoted_property(hb_string("tag_name"), error->tag_name, indent, relative_indent, false, buffer);
|
|
1598
|
+
pretty_print_quoted_property(hb_string("open_condition"), error->open_condition, indent, relative_indent, false, buffer);
|
|
1599
|
+
pretty_print_size_t_property(error->open_line, hb_string("open_line"), indent, relative_indent, false, buffer);
|
|
1600
|
+
pretty_print_size_t_property(error->open_column, hb_string("open_column"), indent, relative_indent, false, buffer);
|
|
1601
|
+
pretty_print_quoted_property(hb_string("close_condition"), error->close_condition, indent, relative_indent, false, buffer);
|
|
1602
|
+
pretty_print_size_t_property(error->close_line, hb_string("close_line"), indent, relative_indent, false, buffer);
|
|
1603
|
+
pretty_print_size_t_property(error->close_column, hb_string("close_column"), indent, relative_indent, true, buffer);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
static void error_pretty_print_invalid_comment_closing_tag_error(INVALID_COMMENT_CLOSING_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1607
|
+
if (!error) { return; }
|
|
1608
|
+
|
|
1609
|
+
hb_buffer_append(buffer, "@ ");
|
|
1610
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1611
|
+
hb_buffer_append(buffer, " ");
|
|
1612
|
+
|
|
1613
|
+
pretty_print_location(error->base.location, buffer);
|
|
1614
|
+
hb_buffer_append(buffer, "\n");
|
|
1615
|
+
|
|
1616
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1617
|
+
pretty_print_token_property(error->closing_tag, hb_string("closing_tag"), indent, relative_indent, true, buffer);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
static void error_pretty_print_omitted_closing_tag_error(OMITTED_CLOSING_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1621
|
+
if (!error) { return; }
|
|
1622
|
+
|
|
1623
|
+
hb_buffer_append(buffer, "@ ");
|
|
1624
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1625
|
+
hb_buffer_append(buffer, " ");
|
|
1626
|
+
|
|
1627
|
+
pretty_print_location(error->base.location, buffer);
|
|
1628
|
+
hb_buffer_append(buffer, "\n");
|
|
1629
|
+
|
|
1630
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1631
|
+
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, false, buffer);
|
|
1632
|
+
pretty_print_position_property(&error->insertion_point, hb_string("insertion_point"), indent, relative_indent, true, buffer);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
static void error_pretty_print_unclosed_open_tag_error(UNCLOSED_OPEN_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1636
|
+
if (!error) { return; }
|
|
1637
|
+
|
|
1638
|
+
hb_buffer_append(buffer, "@ ");
|
|
1639
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1640
|
+
hb_buffer_append(buffer, " ");
|
|
1641
|
+
|
|
1642
|
+
pretty_print_location(error->base.location, buffer);
|
|
1643
|
+
hb_buffer_append(buffer, "\n");
|
|
1644
|
+
|
|
1645
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1646
|
+
pretty_print_token_property(error->tag_name, hb_string("tag_name"), indent, relative_indent, true, buffer);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
static void error_pretty_print_unclosed_close_tag_error(UNCLOSED_CLOSE_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1650
|
+
if (!error) { return; }
|
|
1651
|
+
|
|
1652
|
+
hb_buffer_append(buffer, "@ ");
|
|
1653
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1654
|
+
hb_buffer_append(buffer, " ");
|
|
1655
|
+
|
|
1656
|
+
pretty_print_location(error->base.location, buffer);
|
|
1657
|
+
hb_buffer_append(buffer, "\n");
|
|
1658
|
+
|
|
1659
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1660
|
+
pretty_print_token_property(error->tag_name, hb_string("tag_name"), indent, relative_indent, true, buffer);
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
static void error_pretty_print_unclosed_quote_error(UNCLOSED_QUOTE_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1664
|
+
if (!error) { return; }
|
|
1665
|
+
|
|
1666
|
+
hb_buffer_append(buffer, "@ ");
|
|
1667
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1668
|
+
hb_buffer_append(buffer, " ");
|
|
1669
|
+
|
|
1670
|
+
pretty_print_location(error->base.location, buffer);
|
|
1671
|
+
hb_buffer_append(buffer, "\n");
|
|
1672
|
+
|
|
1673
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1674
|
+
pretty_print_token_property(error->opening_quote, hb_string("opening_quote"), indent, relative_indent, true, buffer);
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
static void error_pretty_print_missing_attribute_value_error(MISSING_ATTRIBUTE_VALUE_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1678
|
+
if (!error) { return; }
|
|
1679
|
+
|
|
1680
|
+
hb_buffer_append(buffer, "@ ");
|
|
1681
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1682
|
+
hb_buffer_append(buffer, " ");
|
|
1683
|
+
|
|
1684
|
+
pretty_print_location(error->base.location, buffer);
|
|
1685
|
+
hb_buffer_append(buffer, "\n");
|
|
1686
|
+
|
|
1687
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1688
|
+
pretty_print_quoted_property(hb_string("attribute_name"), error->attribute_name, indent, relative_indent, true, buffer);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
static void error_pretty_print_unclosed_erb_tag_error(UNCLOSED_ERB_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
1692
|
+
if (!error) { return; }
|
|
1693
|
+
|
|
1694
|
+
hb_buffer_append(buffer, "@ ");
|
|
1695
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
1696
|
+
hb_buffer_append(buffer, " ");
|
|
1697
|
+
|
|
1698
|
+
pretty_print_location(error->base.location, buffer);
|
|
1699
|
+
hb_buffer_append(buffer, "\n");
|
|
1700
|
+
|
|
1701
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
843
1702
|
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, true, buffer);
|
|
844
1703
|
}
|
|
845
1704
|
|
|
846
|
-
static void
|
|
1705
|
+
static void error_pretty_print_stray_erb_closing_tag_error(STRAY_ERB_CLOSING_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
847
1706
|
if (!error) { return; }
|
|
848
1707
|
|
|
849
1708
|
hb_buffer_append(buffer, "@ ");
|
|
850
|
-
|
|
1709
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
851
1710
|
hb_buffer_append(buffer, " ");
|
|
852
1711
|
|
|
853
1712
|
pretty_print_location(error->base.location, buffer);
|
|
854
1713
|
hb_buffer_append(buffer, "\n");
|
|
855
1714
|
|
|
856
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
857
|
-
pretty_print_quoted_property(hb_string("error_message"), hb_string(error->error_message), indent, relative_indent, false, buffer);
|
|
858
|
-
pretty_print_quoted_property(hb_string("diagnostic_id"), hb_string(error->diagnostic_id), indent, relative_indent, false, buffer);
|
|
859
|
-
pretty_print_quoted_property(hb_string("level"), hb_string(error->level), indent, relative_indent, true, buffer);
|
|
1715
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, true, buffer);
|
|
860
1716
|
}
|
|
861
1717
|
|
|
862
|
-
static void
|
|
1718
|
+
static void error_pretty_print_nested_erb_tag_error(NESTED_ERB_TAG_ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
863
1719
|
if (!error) { return; }
|
|
864
1720
|
|
|
865
1721
|
hb_buffer_append(buffer, "@ ");
|
|
866
|
-
|
|
1722
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
867
1723
|
hb_buffer_append(buffer, " ");
|
|
868
1724
|
|
|
869
1725
|
pretty_print_location(error->base.location, buffer);
|
|
870
1726
|
hb_buffer_append(buffer, "\n");
|
|
871
1727
|
|
|
872
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
873
|
-
|
|
1728
|
+
pretty_print_quoted_property(hb_string("message"), error->base.message, indent, relative_indent, false, buffer);
|
|
1729
|
+
pretty_print_token_property(error->opening_tag, hb_string("opening_tag"), indent, relative_indent, false, buffer);
|
|
1730
|
+
pretty_print_size_t_property(error->nested_tag_line, hb_string("nested_tag_line"), indent, relative_indent, false, buffer);
|
|
1731
|
+
pretty_print_size_t_property(error->nested_tag_column, hb_string("nested_tag_column"), indent, relative_indent, true, buffer);
|
|
874
1732
|
}
|
|
875
1733
|
|
|
876
|
-
static void
|
|
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) {
|
|
877
1735
|
if (!error) { return; }
|
|
878
1736
|
|
|
879
1737
|
hb_buffer_append(buffer, "@ ");
|
|
880
|
-
|
|
1738
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
881
1739
|
hb_buffer_append(buffer, " ");
|
|
882
1740
|
|
|
883
1741
|
pretty_print_location(error->base.location, buffer);
|
|
884
1742
|
hb_buffer_append(buffer, "\n");
|
|
885
1743
|
|
|
886
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
887
|
-
pretty_print_quoted_property(hb_string("
|
|
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);
|
|
888
1746
|
}
|
|
889
1747
|
|
|
890
|
-
static void
|
|
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) {
|
|
891
1749
|
if (!error) { return; }
|
|
892
1750
|
|
|
893
1751
|
hb_buffer_append(buffer, "@ ");
|
|
894
|
-
|
|
1752
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
895
1753
|
hb_buffer_append(buffer, " ");
|
|
896
1754
|
|
|
897
1755
|
pretty_print_location(error->base.location, buffer);
|
|
898
1756
|
hb_buffer_append(buffer, "\n");
|
|
899
1757
|
|
|
900
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
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);
|
|
901
1761
|
}
|
|
902
1762
|
|
|
903
|
-
static void
|
|
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) {
|
|
904
1764
|
if (!error) { return; }
|
|
905
1765
|
|
|
906
1766
|
hb_buffer_append(buffer, "@ ");
|
|
907
|
-
|
|
1767
|
+
hb_buffer_append_string(buffer, error_human_type((ERROR_T*) error));
|
|
908
1768
|
hb_buffer_append(buffer, " ");
|
|
909
1769
|
|
|
910
1770
|
pretty_print_location(error->base.location, buffer);
|
|
911
1771
|
hb_buffer_append(buffer, "\n");
|
|
912
1772
|
|
|
913
|
-
pretty_print_quoted_property(hb_string("message"),
|
|
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);
|
|
914
1830
|
}
|
|
915
1831
|
|
|
916
1832
|
void error_pretty_print(ERROR_T* error, const size_t indent, const size_t relative_indent, hb_buffer_T* buffer) {
|
|
@@ -922,13 +1838,32 @@ void error_pretty_print(ERROR_T* error, const size_t indent, const size_t relati
|
|
|
922
1838
|
case MISSING_OPENING_TAG_ERROR: error_pretty_print_missing_opening_tag_error((MISSING_OPENING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
923
1839
|
case MISSING_CLOSING_TAG_ERROR: error_pretty_print_missing_closing_tag_error((MISSING_CLOSING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
924
1840
|
case TAG_NAMES_MISMATCH_ERROR: error_pretty_print_tag_names_mismatch_error((TAG_NAMES_MISMATCH_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
925
|
-
case QUOTES_MISMATCH_ERROR: error_pretty_print_quotes_mismatch_error((QUOTES_MISMATCH_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
926
1841
|
case VOID_ELEMENT_CLOSING_TAG_ERROR: error_pretty_print_void_element_closing_tag_error((VOID_ELEMENT_CLOSING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
927
1842
|
case UNCLOSED_ELEMENT_ERROR: error_pretty_print_unclosed_element_error((UNCLOSED_ELEMENT_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
928
1843
|
case RUBY_PARSE_ERROR: error_pretty_print_ruby_parse_error((RUBY_PARSE_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
929
1844
|
case ERB_CONTROL_FLOW_SCOPE_ERROR: error_pretty_print_erb_control_flow_scope_error((ERB_CONTROL_FLOW_SCOPE_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
930
|
-
case
|
|
1845
|
+
case MISSING_ERB_END_TAG_ERROR: error_pretty_print_missing_erb_end_tag_error((MISSING_ERB_END_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
931
1846
|
case ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR: error_pretty_print_erb_multiple_blocks_in_tag_error((ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
932
1847
|
case ERB_CASE_WITH_CONDITIONS_ERROR: error_pretty_print_erb_case_with_conditions_error((ERB_CASE_WITH_CONDITIONS_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1848
|
+
case CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR: error_pretty_print_conditional_element_multiple_tags_error((CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1849
|
+
case CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR: error_pretty_print_conditional_element_condition_mismatch_error((CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1850
|
+
case INVALID_COMMENT_CLOSING_TAG_ERROR: error_pretty_print_invalid_comment_closing_tag_error((INVALID_COMMENT_CLOSING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1851
|
+
case OMITTED_CLOSING_TAG_ERROR: error_pretty_print_omitted_closing_tag_error((OMITTED_CLOSING_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1852
|
+
case UNCLOSED_OPEN_TAG_ERROR: error_pretty_print_unclosed_open_tag_error((UNCLOSED_OPEN_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1853
|
+
case UNCLOSED_CLOSE_TAG_ERROR: error_pretty_print_unclosed_close_tag_error((UNCLOSED_CLOSE_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1854
|
+
case UNCLOSED_QUOTE_ERROR: error_pretty_print_unclosed_quote_error((UNCLOSED_QUOTE_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1855
|
+
case MISSING_ATTRIBUTE_VALUE_ERROR: error_pretty_print_missing_attribute_value_error((MISSING_ATTRIBUTE_VALUE_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
1856
|
+
case UNCLOSED_ERB_TAG_ERROR: error_pretty_print_unclosed_erb_tag_error((UNCLOSED_ERB_TAG_ERROR_T*) error, indent, relative_indent, buffer); break;
|
|
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;
|
|
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;
|
|
933
1866
|
}
|
|
934
1867
|
}
|
|
1868
|
+
|
|
1869
|
+
#endif
|