mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Underline the complete declaration in diagnostics (#3508)
Builds upon @domisterwoozy 's excellent #3442 . Removes the need to store the first node of a declaration in the declaration state stack.
This commit is contained in:
@@ -15,17 +15,16 @@ auto HandleInterfaceIntroducer(Context& context, Parse::NodeId parse_node)
|
||||
// Push the bracketing node.
|
||||
context.node_stack().Push(parse_node);
|
||||
// Optional modifiers and the name follow.
|
||||
context.decl_state_stack().Push(DeclState::Interface, parse_node);
|
||||
context.decl_state_stack().Push(DeclState::Interface);
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto BuildInterfaceDecl(Context& context)
|
||||
static auto BuildInterfaceDecl(Context& context, Parse::NodeId parse_node)
|
||||
-> std::tuple<SemIR::InterfaceId, SemIR::InstId> {
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::InterfaceIntroducer>();
|
||||
auto first_node = context.decl_state_stack().innermost().first_node;
|
||||
|
||||
// Process modifiers.
|
||||
CheckAccessModifiersOnDecl(context, Lex::TokenKind::Interface);
|
||||
@@ -43,7 +42,7 @@ static auto BuildInterfaceDecl(Context& context)
|
||||
|
||||
// Add the interface declaration.
|
||||
auto interface_decl = SemIR::InterfaceDecl{
|
||||
first_node, SemIR::InterfaceId::Invalid, decl_block_id};
|
||||
parse_node, SemIR::InterfaceId::Invalid, decl_block_id};
|
||||
auto interface_decl_id = context.AddInst(interface_decl);
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
@@ -84,16 +83,16 @@ static auto BuildInterfaceDecl(Context& context)
|
||||
return {interface_decl.interface_id, interface_decl_id};
|
||||
}
|
||||
|
||||
auto HandleInterfaceDecl(Context& context, Parse::NodeId /*parse_node*/)
|
||||
-> bool {
|
||||
BuildInterfaceDecl(context);
|
||||
auto HandleInterfaceDecl(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
BuildInterfaceDecl(context, parse_node);
|
||||
context.decl_name_stack().PopScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleInterfaceDefinitionStart(Context& context, Parse::NodeId parse_node)
|
||||
-> bool {
|
||||
auto [interface_id, interface_decl_id] = BuildInterfaceDecl(context);
|
||||
auto [interface_id, interface_decl_id] =
|
||||
BuildInterfaceDecl(context, parse_node);
|
||||
auto& interface_info = context.interfaces().Get(interface_id);
|
||||
|
||||
// Track that this declaration is the definition.
|
||||
|
||||
Reference in New Issue
Block a user