Rename parse_node -> node_id (#3760)

This was previously discussed at
https://discord.com/channels/655572317891461132/655578254970716160/1209975051588210729.
I'm initiating this mainly because we typically use "id" suffixes to
indicate an `IdBase` being passed around and the non-id suffix of
`parse_node` suggests at it carrying more data than it actually does.
There used to be more reason for avoiding `node_id` because
`SemIR::InstId` used to be named `NodeId`, but that's no longer
necessary. As a consequence, I'd like to rename `parse_node` to more
precisely reflect its type.

In full, this is doing:

```
parse_node_kind -> node_kind
parse_node -> node_id
ParseNodeCategory -> NodeCategory
ParseNodeKind -> NodeKind
ParseNode -> NodeId
```

This is primarily in check and sem_ir, but with some `parse_node_kind`
references in parse too.

Pluralization is consistent with name forms on both sides, so that
wasn't part of my replacements.
This commit is contained in:
Jon Ross-Perkins
2024-03-09 00:21:29 +00:00
committed by GitHub
parent a1317e61e0
commit 86a7c9ff45
57 changed files with 1050 additions and 1115 deletions
+7 -7
View File
@@ -11,19 +11,19 @@
namespace Carbon::Check {
auto HandleAliasIntroducer(Context& context,
Parse::AliasIntroducerId /*parse_node*/) -> bool {
Parse::AliasIntroducerId /*node_id*/) -> bool {
context.decl_state_stack().Push(DeclState::Alias);
context.decl_name_stack().PushScopeAndStartName();
return true;
}
auto HandleAliasInitializer(Context& /*context*/,
Parse::AliasInitializerId /*parse_node*/) -> bool {
Parse::AliasInitializerId /*node_id*/) -> bool {
return true;
}
auto HandleAlias(Context& context, Parse::AliasId /*parse_node*/) -> bool {
auto [expr_node, expr_id] = context.node_stack().PopExprWithParseNode();
auto HandleAlias(Context& context, Parse::AliasId /*node_id*/) -> bool {
auto [expr_node, expr_id] = context.node_stack().PopExprWithNodeId();
auto name_context = context.decl_name_stack().FinishName();
@@ -48,20 +48,20 @@ auto HandleAlias(Context& context, Parse::AliasId /*parse_node*/) -> bool {
// TODO: Look into handling `false`, this doesn't do it right now because it
// sees a value instruction instead of a builtin.
alias_id = context.AddInst(
{name_context.parse_node,
{name_context.node_id,
SemIR::BindAlias{context.insts().Get(expr_id).type_id(), bind_name_id,
expr_id}});
} else if (auto inst = context.insts().TryGetAs<SemIR::NameRef>(expr_id)) {
// Pass through name references, albeit changing the name in use.
alias_id = context.AddInst(
{name_context.parse_node,
{name_context.node_id,
SemIR::BindAlias{inst->type_id, bind_name_id, inst->value_id}});
} else {
CARBON_DIAGNOSTIC(AliasRequiresNameRef, Error,
"Alias initializer must be a name reference.");
context.emitter().Emit(expr_node, AliasRequiresNameRef);
alias_id =
context.AddInst({name_context.parse_node,
context.AddInst({name_context.node_id,
SemIR::BindAlias{SemIR::TypeId::Error, bind_name_id,
SemIR::InstId::BuiltinError}});
}