diff --git a/src/protocol/parser/symbol_table2.rs b/src/protocol/parser/symbol_table2.rs index 9242f9aaccb1348fb7cc46722ed977d0e023e690..b6b5668e65e700ec1ddb62d4861e57154d3de566 100644 --- a/src/protocol/parser/symbol_table2.rs +++ b/src/protocol/parser/symbol_table2.rs @@ -128,6 +128,20 @@ pub enum SymbolVariant { } impl SymbolVariant { + /// Returns the span at which the item was introduced. For an imported + /// item (all modules, and imported types) this returns the span of the + /// import. For a defined type this returns the span of the identifier + pub(crate) fn span_of_introduction(&self, heap: &Heap) -> InputSpan { + match self { + SymbolVariant::Module(v) => heap[v.introduced_at].span(), + SymbolVariant::Definition(v) => if let Some(import_id) = v.imported_at { + heap[import_id].span() + } else { + v.identifier_span + }, + } + } + pub(crate) fn as_module(&self) -> &SymbolModule { match self { SymbolVariant::Module(v) => v,