Skip to content

Commit

Permalink
Remove name constant from classes/modules
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Sep 6, 2023
1 parent 9285989 commit 26105f0
Show file tree
Hide file tree
Showing 30 changed files with 5 additions and 89 deletions.
4 changes: 0 additions & 4 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,6 @@ nodes:
type: location
- name: name
type: constant
- name: name_constant
type: constant
comment: |
Represents a class declaration involving the `class` keyword.
Expand Down Expand Up @@ -1742,8 +1740,6 @@ nodes:
type: location
- name: name
type: constant
- name: name_constant
type: constant
comment: |
Represents a module declaration involving the `module` keyword.
Expand Down
8 changes: 2 additions & 6 deletions src/yarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,6 @@ yp_case_node_end_keyword_loc_set(yp_case_node_t *node, const yp_token_t *end_key
static yp_class_node_t *
yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *name, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *body, const yp_token_t *end_keyword) {
yp_class_node_t *node = YP_ALLOC_NODE(parser, yp_class_node_t);
yp_constant_id_t name_constant = yp_parser_constant_id_token(parser, name);

*node = (yp_class_node_t) {
{
Expand All @@ -1669,8 +1668,7 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
.superclass = superclass,
.body = body,
.end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword),
.name = name_constant,
.name_constant = name_constant
.name = yp_parser_constant_id_token(parser, name)
};

return node;
Expand Down Expand Up @@ -3305,7 +3303,6 @@ yp_match_required_node_create(yp_parser_t *parser, yp_node_t *value, yp_node_t *
static yp_module_node_t *
yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, const yp_token_t *name, yp_node_t *body, const yp_token_t *end_keyword) {
yp_module_node_t *node = YP_ALLOC_NODE(parser, yp_module_node_t);
yp_constant_id_t name_constant = yp_parser_constant_id_token(parser, name);

*node = (yp_module_node_t) {
{
Expand All @@ -3320,8 +3317,7 @@ yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const
.constant_path = constant_path,
.body = body,
.end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword),
.name = name_constant,
.name_constant = name_constant
.name = yp_parser_constant_id_token(parser, name)
};

return node;
Expand Down
10 changes: 3 additions & 7 deletions test/yarp/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def test_module_name_recoverable
Location(),
ConstantReadNode(:Parent),
StatementsNode(
[ModuleNode([], Location(), MissingNode(), nil, Location(), :"", :"")]
[ModuleNode([], Location(), MissingNode(), nil, Location(), :"")]
),
Location(),
:Parent,
:Parent
)

Expand Down Expand Up @@ -394,7 +393,7 @@ def test_module_definition_in_method_body
Location(),
nil,
nil,
StatementsNode([ModuleNode([], Location(), ConstantReadNode(:A), nil, Location(), :A, :A)]),
StatementsNode([ModuleNode([], Location(), ConstantReadNode(:A), nil, Location(), :A)]),
[],
Location(),
nil,
Expand Down Expand Up @@ -425,7 +424,7 @@ def test_module_definition_in_method_body_within_block
BlockNode(
[],
nil,
StatementsNode([ModuleNode([], Location(), ConstantReadNode(:Foo), nil, Location(), :Foo, :Foo)]),
StatementsNode([ModuleNode([], Location(), ConstantReadNode(:Foo), nil, Location(), :Foo)]),
Location(),
Location()
),
Expand Down Expand Up @@ -465,7 +464,6 @@ def test_class_definition_in_method_body
nil,
nil,
Location(),
:A,
:A
)]
),
Expand Down Expand Up @@ -981,7 +979,6 @@ def test_dont_allow_return_inside_class_body
nil,
StatementsNode([ReturnNode(Location(), nil)]),
Location(),
:A,
:A
)

Expand All @@ -997,7 +994,6 @@ def test_dont_allow_return_inside_module_body
ConstantReadNode(:A),
StatementsNode([ReturnNode(Location(), nil)]),
Location(),
:A,
:A
)

Expand Down
7 changes: 0 additions & 7 deletions test/yarp/snapshots/classes.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions test/yarp/snapshots/method_calls.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions test/yarp/snapshots/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions test/yarp/snapshots/seattlerb/TestRubyParserShared.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/yarp/snapshots/seattlerb/class_comments.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/yarp/snapshots/seattlerb/defn_oneliner_eq2.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/yarp/snapshots/seattlerb/defs_oneliner_eq2.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/yarp/snapshots/seattlerb/magic_encoding_comment.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/yarp/snapshots/seattlerb/module_comments.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions test/yarp/snapshots/unparser/corpus/literal/class.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 26105f0

Please sign in to comment.