@herb-tools/node 0.7.2 → 0.7.3
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/dist/herb-node.esm.js +1 -1
- package/extension/error_helpers.cpp +1 -1
- package/extension/error_helpers.h +1 -1
- package/extension/libherb/analyze.c +5 -9
- package/extension/libherb/analyze_helpers.c +17 -6
- package/extension/libherb/ast_nodes.c +1 -1
- package/extension/libherb/ast_nodes.h +1 -1
- package/extension/libherb/ast_pretty_print.c +1 -1
- package/extension/libherb/ast_pretty_print.h +1 -1
- package/extension/libherb/errors.c +1 -1
- package/extension/libherb/errors.h +1 -1
- package/extension/libherb/include/ast_nodes.h +1 -1
- package/extension/libherb/include/ast_pretty_print.h +1 -1
- package/extension/libherb/include/errors.h +1 -1
- package/extension/libherb/include/pretty_print.h +1 -1
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/parser.c +1 -0
- package/extension/libherb/pretty_print.c +1 -1
- package/extension/libherb/pretty_print.h +1 -1
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +1 -1
- package/extension/nodes.cpp +1 -1
- package/extension/nodes.h +1 -1
- package/package.json +2 -2
package/dist/herb-node.esm.js
CHANGED
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/javascript/packages/node/extension/error_helpers.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/javascript/packages/node/extension/error_helpers.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_ERRORS_H
|
|
5
5
|
#define HERB_EXTENSION_ERRORS_H
|
|
@@ -54,7 +54,7 @@ static bool analyze_erb_content(const AST_NODE_T* node, void* data) {
|
|
|
54
54
|
if (strcmp(opening, "<%%") != 0 && strcmp(opening, "<%%=") != 0 && strcmp(opening, "<%#") != 0) {
|
|
55
55
|
analyzed_ruby_T* analyzed = herb_analyze_ruby(erb_content_node->content->value);
|
|
56
56
|
|
|
57
|
-
if (false) {
|
|
57
|
+
if (false) { pretty_print_analyzed_ruby(analyzed, erb_content_node->content->value); }
|
|
58
58
|
|
|
59
59
|
erb_content_node->parsed = true;
|
|
60
60
|
erb_content_node->valid = analyzed->valid;
|
|
@@ -1107,7 +1107,8 @@ void herb_analyze_parse_errors(AST_DOCUMENT_NODE_T* document, const char* source
|
|
|
1107
1107
|
char* extracted_ruby = herb_extract_ruby_with_semicolons(source);
|
|
1108
1108
|
|
|
1109
1109
|
pm_parser_t parser;
|
|
1110
|
-
|
|
1110
|
+
pm_options_t options = { 0, .partial_script = true };
|
|
1111
|
+
pm_parser_init(&parser, (const uint8_t*) extracted_ruby, strlen(extracted_ruby), &options);
|
|
1111
1112
|
|
|
1112
1113
|
pm_node_t* root = pm_parse(&parser);
|
|
1113
1114
|
|
|
@@ -1115,16 +1116,11 @@ void herb_analyze_parse_errors(AST_DOCUMENT_NODE_T* document, const char* source
|
|
|
1115
1116
|
error = (const pm_diagnostic_t*) error->node.next) {
|
|
1116
1117
|
|
|
1117
1118
|
RUBY_PARSE_ERROR_T* parse_error = ruby_parse_error_from_prism_error(error, (AST_NODE_T*) document, source, &parser);
|
|
1118
|
-
|
|
1119
|
-
// TODO: ideally this shouldn't be hard-coded
|
|
1120
|
-
if (strcmp(parse_error->diagnostic_id, "invalid_yield") == 0) {
|
|
1121
|
-
error_free((ERROR_T*) parse_error);
|
|
1122
|
-
} else {
|
|
1123
|
-
array_append(document->base.errors, parse_error);
|
|
1124
|
-
}
|
|
1119
|
+
array_append(document->base.errors, parse_error);
|
|
1125
1120
|
}
|
|
1126
1121
|
|
|
1127
1122
|
pm_node_destroy(&parser, root);
|
|
1128
1123
|
pm_parser_free(&parser);
|
|
1124
|
+
pm_options_free(&options);
|
|
1129
1125
|
free(extracted_ruby);
|
|
1130
1126
|
}
|
|
@@ -91,9 +91,12 @@ bool search_if_nodes(const pm_node_t* node, void* data) {
|
|
|
91
91
|
if (node->type == PM_IF_NODE) {
|
|
92
92
|
const pm_if_node_t* if_node = (const pm_if_node_t*) node;
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
bool has_if_keyword = if_node->if_keyword_loc.start != NULL && if_node->if_keyword_loc.end != NULL;
|
|
95
|
+
bool has_end_keyword = if_node->end_keyword_loc.start != NULL && if_node->end_keyword_loc.end != NULL;
|
|
96
|
+
|
|
97
|
+
if (has_if_keyword && has_end_keyword) {
|
|
96
98
|
analyzed->has_if_node = true;
|
|
99
|
+
|
|
97
100
|
return true;
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -198,12 +201,20 @@ bool search_unless_nodes(const pm_node_t* node, void* data) {
|
|
|
198
201
|
analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data;
|
|
199
202
|
|
|
200
203
|
if (node->type == PM_UNLESS_NODE) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
const pm_unless_node_t* unless_node = (const pm_unless_node_t*) node;
|
|
205
|
+
|
|
206
|
+
bool has_if_keyword = unless_node->keyword_loc.start != NULL && unless_node->keyword_loc.end != NULL;
|
|
207
|
+
bool has_end_keyword = unless_node->end_keyword_loc.start != NULL && unless_node->end_keyword_loc.end != NULL;
|
|
208
|
+
|
|
209
|
+
if (has_if_keyword && has_end_keyword) {
|
|
210
|
+
analyzed->has_unless_node = true;
|
|
211
|
+
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
205
214
|
}
|
|
206
215
|
|
|
216
|
+
pm_visit_child_nodes(node, search_unless_nodes, analyzed);
|
|
217
|
+
|
|
207
218
|
return false;
|
|
208
219
|
}
|
|
209
220
|
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/ast_nodes.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
#include <stdbool.h>
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/ast_pretty_print.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/ast_node.h"
|
|
5
5
|
#include "include/ast_nodes.h"
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/errors.c.erb
|
|
3
3
|
|
|
4
4
|
#include "include/array.h"
|
|
5
5
|
#include "include/errors.h"
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/ast_nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_NODES_H
|
|
5
5
|
#define HERB_AST_NODES_H
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/ast_pretty_print.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_AST_PRETTY_PRINT_H
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/include/errors.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
@@ -88,6 +88,6 @@ void pretty_print_array(
|
|
|
88
88
|
|
|
89
89
|
void pretty_print_errors(AST_NODE_T* node, size_t indent, size_t relative_indent, bool last_property, buffer_T* buffer);
|
|
90
90
|
|
|
91
|
-
void
|
|
91
|
+
void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source);
|
|
92
92
|
|
|
93
93
|
#endif
|
|
@@ -254,7 +254,7 @@ void pretty_print_string_property(
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
void
|
|
257
|
+
void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source) {
|
|
258
258
|
printf(
|
|
259
259
|
"------------------------\nanalyzed (%p)\n------------------------\n%s\n------------------------\n if: %i\n "
|
|
260
260
|
" elsif: %i\n else: %i\n end: %i\n block: %i\n block_closing: %i\n case: %i\n when: %i\n for: "
|
|
@@ -88,6 +88,6 @@ void pretty_print_array(
|
|
|
88
88
|
|
|
89
89
|
void pretty_print_errors(AST_NODE_T* node, size_t indent, size_t relative_indent, bool last_property, buffer_T* buffer);
|
|
90
90
|
|
|
91
|
-
void
|
|
91
|
+
void pretty_print_analyzed_ruby(analyzed_ruby_T* analyzed, const char* source);
|
|
92
92
|
|
|
93
93
|
#endif
|
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/src/visitor.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
package/extension/nodes.cpp
CHANGED
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
package/extension/nodes.h
CHANGED
|
@@ -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.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.3/templates/javascript/packages/node/extension/nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_NODES_H
|
|
5
5
|
#define HERB_EXTENSION_NODES_H
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/node",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Native Node.js addon for HTML-aware ERB parsing using Herb.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"host": "https://github.com/marcoroth/herb/releases/download/"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@herb-tools/core": "0.7.
|
|
51
|
+
"@herb-tools/core": "0.7.3",
|
|
52
52
|
"@mapbox/node-pre-gyp": "^2.0.0",
|
|
53
53
|
"node-addon-api": "^5.1.0",
|
|
54
54
|
"node-pre-gyp-github": "^2.0.0"
|