Skip to content

Commit 53b2866

Browse files
committed
Remove error formatting, put directly in CRuby
1 parent 5050dfb commit 53b2866

File tree

5 files changed

+0
-463
lines changed

5 files changed

+0
-463
lines changed

ext/prism/extension.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,36 +1127,6 @@ inspect_node(VALUE self, VALUE source) {
11271127

11281128
#endif
11291129

1130-
/**
1131-
* call-seq:
1132-
* Debug::format_errors(source, colorize) -> String
1133-
*
1134-
* Format the errors that are found when parsing the given source string.
1135-
*/
1136-
static VALUE
1137-
format_errors(VALUE self, VALUE source, VALUE colorize) {
1138-
pm_string_t input;
1139-
input_load_string(&input, source);
1140-
1141-
pm_parser_t parser;
1142-
pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), NULL);
1143-
1144-
pm_node_t *node = pm_parse(&parser);
1145-
pm_buffer_t buffer = { 0 };
1146-
1147-
pm_parser_errors_format(&parser, &parser.error_list, &buffer, RTEST(colorize), true);
1148-
1149-
rb_encoding *encoding = rb_enc_find(parser.encoding->name);
1150-
VALUE result = rb_enc_str_new(pm_buffer_value(&buffer), pm_buffer_length(&buffer), encoding);
1151-
1152-
pm_buffer_free(&buffer);
1153-
pm_node_destroy(&parser, node);
1154-
pm_parser_free(&parser);
1155-
pm_string_free(&input);
1156-
1157-
return result;
1158-
}
1159-
11601130
/**
11611131
* call-seq: Debug::Encoding.all -> Array[Debug::Encoding]
11621132
*
@@ -1309,7 +1279,6 @@ Init_prism(void) {
13091279
// Next, the functions that will be called by the parser to perform various
13101280
// internal tasks. We expose these to make them easier to test.
13111281
VALUE rb_cPrismDebug = rb_define_module_under(rb_cPrism, "Debug");
1312-
rb_define_singleton_method(rb_cPrismDebug, "format_errors", format_errors, 2);
13131282

13141283
#ifndef PRISM_EXCLUDE_PRETTYPRINT
13151284
rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1);

include/prism.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,6 @@ PRISM_EXPORTED_FUNCTION const char * pm_token_type_name(pm_token_type_t token_ty
219219
*/
220220
const char * pm_token_type_human(pm_token_type_t token_type);
221221

222-
/**
223-
* Format the errors on the parser into the given buffer.
224-
*
225-
* @param parser The parser to format the errors for.
226-
* @param error_list The list of errors to format.
227-
* @param buffer The buffer to format the errors into.
228-
* @param colorize Whether or not to colorize the errors with ANSI escape sequences.
229-
* @param inline_messages Whether or not to inline the messages with the source.
230-
*/
231-
PRISM_EXPORTED_FUNCTION void pm_parser_errors_format(const pm_parser_t *parser, const pm_list_t *error_list, pm_buffer_t *buffer, bool colorize, bool inline_messages);
232-
233222
// We optionally support dumping to JSON. For systems that don't want or need
234223
// this functionality, it can be turned off with the PRISM_EXCLUDE_JSON define.
235224
#ifndef PRISM_EXCLUDE_JSON

0 commit comments

Comments
 (0)