[ruby/prism] Remove Debug::static_inspect

https://github.com/ruby/prism/commit/486c71c426
This commit is contained in:
Kevin Newton 2024-05-24 11:22:29 -04:00 коммит произвёл git
Родитель 47b723f890
Коммит 870350253e
5 изменённых файлов: 5 добавлений и 42 удалений

Просмотреть файл

@ -1223,40 +1223,6 @@ format_errors(VALUE self, VALUE source, VALUE colorize) {
return result; return result;
} }
/**
* call-seq:
* Debug::static_inspect(source) -> String
*
* Inspect the node as it would be inspected by the warnings used in static
* literal sets.
*/
static VALUE
static_inspect(int argc, VALUE *argv, VALUE self) {
pm_string_t input;
pm_options_t options = { 0 };
string_options(argc, argv, &input, &options);
pm_parser_t parser;
pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), &options);
pm_node_t *program = pm_parse(&parser);
pm_node_t *node = ((pm_program_node_t *) program)->statements->body.nodes[0];
pm_buffer_t buffer = { 0 };
pm_static_literal_inspect(&buffer, &parser.newline_list, parser.start_line, parser.encoding->name, node);
rb_encoding *encoding = rb_enc_find(parser.encoding->name);
VALUE result = rb_enc_str_new(pm_buffer_value(&buffer), pm_buffer_length(&buffer), encoding);
pm_buffer_free(&buffer);
pm_node_destroy(&parser, program);
pm_parser_free(&parser);
pm_string_free(&input);
pm_options_free(&options);
return result;
}
/** /**
* call-seq: Debug::Encoding.all -> Array[Debug::Encoding] * call-seq: Debug::Encoding.all -> Array[Debug::Encoding]
* *
@ -1414,7 +1380,6 @@ Init_prism(void) {
rb_define_singleton_method(rb_cPrismDebug, "memsize", memsize, 1); rb_define_singleton_method(rb_cPrismDebug, "memsize", memsize, 1);
rb_define_singleton_method(rb_cPrismDebug, "profile_file", profile_file, 1); rb_define_singleton_method(rb_cPrismDebug, "profile_file", profile_file, 1);
rb_define_singleton_method(rb_cPrismDebug, "format_errors", format_errors, 2); rb_define_singleton_method(rb_cPrismDebug, "format_errors", format_errors, 2);
rb_define_singleton_method(rb_cPrismDebug, "static_inspect", static_inspect, -1);
#ifndef PRISM_EXCLUDE_PRETTYPRINT #ifndef PRISM_EXCLUDE_PRETTYPRINT
rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1); rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1);

Просмотреть файл

@ -603,7 +603,7 @@ pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_met
/** /**
* Create a string-based representation of the given static literal. * Create a string-based representation of the given static literal.
*/ */
PRISM_EXPORTED_FUNCTION void void
pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node) { pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node) {
pm_static_literal_inspect_node( pm_static_literal_inspect_node(
buffer, buffer,

Просмотреть файл

@ -116,6 +116,6 @@ void pm_static_literals_free(pm_static_literals_t *literals);
* @param encoding_name The name of the encoding of the source being parsed. * @param encoding_name The name of the encoding of the source being parsed.
* @param node The node to create a string representation of. * @param node The node to create a string representation of.
*/ */
PRISM_EXPORTED_FUNCTION void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node); void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node);
#endif #endif

Просмотреть файл

@ -34,8 +34,7 @@ size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
* @return The number of characters at the start of the string that are * @return The number of characters at the start of the string that are
* whitespace. * whitespace.
*/ */
size_t size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
/** /**
* Returns the number of characters at the start of the string that are inline * Returns the number of characters at the start of the string that are inline

Просмотреть файл

@ -2,8 +2,6 @@
require_relative "test_helper" require_relative "test_helper"
return if Prism::BACKEND == :FFI
module Prism module Prism
class StaticInspectTest < TestCase class StaticInspectTest < TestCase
def test_false def test_false
@ -84,7 +82,8 @@ module Prism
private private
def static_inspect(source, **options) def static_inspect(source, **options)
Debug.static_inspect(source, **options) warnings = Prism.parse("{ #{source} => 1, #{source} => 1 }", **options).warnings
warnings.last.message[/^key (.+) is duplicated and overwritten on line \d/, 1]
end end
end end
end end