Skip to content

Commit 486c71c

Browse files
committed
Remove Debug::static_inspect
1 parent ca62c3f commit 486c71c

File tree

5 files changed

+5
-42
lines changed

5 files changed

+5
-42
lines changed

ext/prism/extension.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,40 +1223,6 @@ format_errors(VALUE self, VALUE source, VALUE colorize) {
12231223
return result;
12241224
}
12251225

1226-
/**
1227-
* call-seq:
1228-
* Debug::static_inspect(source) -> String
1229-
*
1230-
* Inspect the node as it would be inspected by the warnings used in static
1231-
* literal sets.
1232-
*/
1233-
static VALUE
1234-
static_inspect(int argc, VALUE *argv, VALUE self) {
1235-
pm_string_t input;
1236-
pm_options_t options = { 0 };
1237-
string_options(argc, argv, &input, &options);
1238-
1239-
pm_parser_t parser;
1240-
pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), &options);
1241-
1242-
pm_node_t *program = pm_parse(&parser);
1243-
pm_node_t *node = ((pm_program_node_t *) program)->statements->body.nodes[0];
1244-
1245-
pm_buffer_t buffer = { 0 };
1246-
pm_static_literal_inspect(&buffer, &parser.newline_list, parser.start_line, parser.encoding->name, node);
1247-
1248-
rb_encoding *encoding = rb_enc_find(parser.encoding->name);
1249-
VALUE result = rb_enc_str_new(pm_buffer_value(&buffer), pm_buffer_length(&buffer), encoding);
1250-
1251-
pm_buffer_free(&buffer);
1252-
pm_node_destroy(&parser, program);
1253-
pm_parser_free(&parser);
1254-
pm_string_free(&input);
1255-
pm_options_free(&options);
1256-
1257-
return result;
1258-
}
1259-
12601226
/**
12611227
* call-seq: Debug::Encoding.all -> Array[Debug::Encoding]
12621228
*
@@ -1414,7 +1380,6 @@ Init_prism(void) {
14141380
rb_define_singleton_method(rb_cPrismDebug, "memsize", memsize, 1);
14151381
rb_define_singleton_method(rb_cPrismDebug, "profile_file", profile_file, 1);
14161382
rb_define_singleton_method(rb_cPrismDebug, "format_errors", format_errors, 2);
1417-
rb_define_singleton_method(rb_cPrismDebug, "static_inspect", static_inspect, -1);
14181383

14191384
#ifndef PRISM_EXCLUDE_PRETTYPRINT
14201385
rb_define_singleton_method(rb_cPrismDebug, "inspect_node", inspect_node, 1);

include/prism/static_literals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ void pm_static_literals_free(pm_static_literals_t *literals);
115115
* @param encoding_name The name of the encoding of the source being parsed.
116116
* @param node The node to create a string representation of.
117117
*/
118-
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);
118+
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);
119119

120120
#endif

include/prism/util/pm_char.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
3434
* @return The number of characters at the start of the string that are
3535
* whitespace.
3636
*/
37-
size_t
38-
pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
37+
size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
3938

4039
/**
4140
* Returns the number of characters at the start of the string that are inline

src/static_literals.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_met
592592
/**
593593
* Create a string-based representation of the given static literal.
594594
*/
595-
PRISM_EXPORTED_FUNCTION void
595+
void
596596
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) {
597597
pm_static_literal_inspect_node(
598598
buffer,

test/prism/static_inspect_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require_relative "test_helper"
44

5-
return if Prism::BACKEND == :FFI
6-
75
module Prism
86
class StaticInspectTest < TestCase
97
def test_false
@@ -84,7 +82,8 @@ def test_true
8482
private
8583

8684
def static_inspect(source, **options)
87-
Debug.static_inspect(source, **options)
85+
warnings = Prism.parse("{ #{source} => 1, #{source} => 1 }", **options).warnings
86+
warnings.last.message[/^key (.+) is duplicated and overwritten on line \d/, 1]
8887
end
8988
end
9089
end

0 commit comments

Comments
 (0)