From e78db9f1e2214a485c0f1664c2f88efd7b51d39a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 6 Nov 2023 11:07:16 -0500 Subject: [PATCH] feat(symbols): symbol members (#318) --- src/ast.rs | 1 + src/symbols/analyzer.rs | 607 +++++++++++++++--- src/symbols/cross_module.rs | 10 +- src/symbols/mod.rs | 3 + tests/helpers/test_builder.rs | 7 +- tests/specs/symbols/Basic.txt | 155 +++-- tests/specs/symbols/Classes01.txt | 416 ++++++++---- tests/specs/symbols/DeclarationMerging01.txt | 38 +- tests/specs/symbols/ExportAssignment01.txt | 14 +- tests/specs/symbols/ExportDefault01.txt | 168 +++-- tests/specs/symbols/ExportDefault02.txt | 14 +- tests/specs/symbols/ExportDefault03.txt | 36 +- tests/specs/symbols/ExportDefault04.txt | 2 +- .../specs/symbols/ExportDefaultLiteral01.txt | 8 +- .../specs/symbols/ExportDefaultLiteral02.txt | 8 +- tests/specs/symbols/ExportDestructured.txt | 32 +- tests/specs/symbols/ExportStar01.txt | 144 +++-- tests/specs/symbols/ExportedDeclare01.txt | 67 +- tests/specs/symbols/ExportedDeclare02.txt | 14 +- tests/specs/symbols/FunctionOverloads01.txt | 26 +- tests/specs/symbols/Functions01.txt | 74 ++- tests/specs/symbols/ImportEquals01.txt | 20 +- tests/specs/symbols/ImportEquals02.txt | 85 ++- tests/specs/symbols/ImportType01.txt | 79 +-- tests/specs/symbols/ImportType02.txt | 49 +- tests/specs/symbols/Interfaces01.txt | 249 ++++--- tests/specs/symbols/Interfaces02.txt | 164 +++-- tests/specs/symbols/ModuleExportNameStr01.txt | 32 +- tests/specs/symbols/Namespaces01.txt | 38 +- tests/specs/symbols/Namespaces02.txt | 26 +- tests/specs/symbols/ReExportJson01.txt | 26 +- tests/specs/symbols/ReexportExport.txt | 8 +- tests/specs/symbols/TsExternalModuleRef01.txt | 40 +- tests/specs/symbols/TsExternalModuleRef02.txt | 34 +- tests/specs/symbols/TsNamespaceExport01.txt | 8 +- tests/specs/symbols/TsQualifiedName01.txt | 44 +- tests/specs/symbols/TypeAlias01.txt | 135 ++++ tests/specs/symbols/TypeScriptTypesHeader.txt | 150 +++-- tests/specs/symbols/TypesEntrypoint.txt | 37 +- 39 files changed, 2191 insertions(+), 877 deletions(-) create mode 100644 tests/specs/symbols/TypeAlias01.txt diff --git a/src/ast.rs b/src/ast.rs index 5ae004d6c..c4b2e7f55 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -142,6 +142,7 @@ impl ParsedSourceStore for DefaultParsedSourceStore { /// Note that this will insert into the store whatever was /// last parsed, so if two threads race to parse, when they're /// both done it will have whatever was last stored. +#[derive(Clone, Copy)] pub struct CapturingModuleParser<'a> { parser: Option<&'a dyn ModuleParser>, store: &'a dyn ParsedSourceStore, diff --git a/src/symbols/analyzer.rs b/src/symbols/analyzer.rs index b87e01f06..17cc70731 100644 --- a/src/symbols/analyzer.rs +++ b/src/symbols/analyzer.rs @@ -33,9 +33,12 @@ use super::cross_module; use super::cross_module::Definition; use super::ResolvedSymbolDepEntry; +/// The root symbol from which module symbols can be retrieved. +/// +/// Building the symbols for modules is lazy. pub struct RootSymbol<'a> { module_graph: &'a ModuleGraph, - parser: &'a CapturingModuleParser<'a>, + parser: CapturingModuleParser<'a>, specifiers_to_ids: AdditiveOnlyMap, ids_to_symbols: AdditiveOnlyMap, diagnostics: RefCell>, @@ -44,7 +47,7 @@ pub struct RootSymbol<'a> { impl<'a> RootSymbol<'a> { pub fn new( module_graph: &'a ModuleGraph, - parser: &'a CapturingModuleParser<'a>, + parser: CapturingModuleParser<'a>, ) -> Self { Self { module_graph, @@ -86,11 +89,13 @@ impl<'a> RootSymbol<'a> { self.ids_to_symbols.get(&module_id).map(|s| s.as_ref()) } + /// Goes to the definitions of the specified symbol. pub fn go_to_definitions<'b>( &'b self, module: ModuleSymbolRef<'b>, symbol: &'b Symbol, ) -> Vec> { + debug_assert_eq!(symbol.module_id(), module.module_id()); super::cross_module::go_to_definitions( self.module_graph, module, @@ -126,7 +131,7 @@ impl<'a> RootSymbol<'a> { module_id: ModuleId(self.ids_to_symbols.len() as u32), source: source.clone(), next_symbol_id: Default::default(), - child_decls: Default::default(), + child_ids: Default::default(), exports: Default::default(), re_exports: Default::default(), swc_id_to_symbol_id: Default::default(), @@ -137,6 +142,7 @@ impl<'a> RootSymbol<'a> { source: &source, specifier, diagnostics: Vec::new(), + next_symbol_member_id: SymbolMemberId(0), }; filler.fill_module(&mut module_symbol, module); if !filler.diagnostics.is_empty() { @@ -151,11 +157,13 @@ impl<'a> RootSymbol<'a> { // it easier to interop with ParsedSource let source_text_info = SourceTextInfo::new(json_module.source.clone()); let range = source_text_info.range(); + let module_id = ModuleId(self.ids_to_symbols.len() as u32); let module_symbol = JsonModuleSymbol { specifier: specifier.clone(), - module_id: ModuleId(self.ids_to_symbols.len() as u32), + module_id, exports: IndexMap::from([("default".to_string(), SymbolId(0))]), default_symbol: Symbol { + module_id, symbol_id: SymbolId(0), decls: { let range = { @@ -178,8 +186,9 @@ impl<'a> RootSymbol<'a> { )]) }, deps: Default::default(), - child_decls: Default::default(), + child_ids: Default::default(), exports: Default::default(), + members: Default::default(), }, source_text_info, }; @@ -468,63 +477,108 @@ impl From for SymbolDep { #[derive(Clone)] pub struct Symbol { + module_id: ModuleId, symbol_id: SymbolId, // todo(dsherret): the IndexMap is just to prevent duplicates // a better solution should be thought out decls: IndexMap, deps: IndexSet, /// The child declarations of module declarations. - child_decls: IndexSet, + child_ids: IndexSet, exports: IndexMap, + members: IndexMap, } impl std::fmt::Debug for Symbol { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Symbol") + .field("module_id", &self.module_id) .field("symbol_id", &self.symbol_id) .field("decls", &self.decls.values().collect::>()) .field("deps", &self.deps) - .field("child_decls", &self.child_decls) + .field("child_ids", &self.child_ids) .field("exports", &self.exports) + .field("members", &self.members) .finish() } } impl Symbol { - pub fn new(symbol_id: SymbolId) -> Self { + pub fn new(module_id: ModuleId, symbol_id: SymbolId) -> Self { Symbol { + module_id, symbol_id, decls: Default::default(), deps: Default::default(), - child_decls: Default::default(), + child_ids: Default::default(), exports: Default::default(), + members: Default::default(), } } + /// A unique identifier of the symbol, which consists of the module id and symbol id. + pub fn unique_id(&self) -> UniqueSymbolId { + UniqueSymbolId::new(self.module_id, self.symbol_id) + } + + /// Module id of where the symbol is located. + pub fn module_id(&self) -> ModuleId { + self.module_id + } + + /// Symbol id within the module. + /// + /// This is module specific. If you need a global identifier, then use unique_id(). pub fn symbol_id(&self) -> SymbolId { self.symbol_id } + /// Export of the symbol by name. pub fn export(&self, name: &str) -> Option { self.exports.get(name).copied() } + /// Map of exports pub fn exports(&self) -> &IndexMap { &self.exports } - pub fn child_decls(&self) -> impl Iterator + '_ { - self.child_decls.iter().copied() + /// Identifiers of namespace children (ex. functions, interface found in a namespace). + pub fn child_ids(&self) -> impl Iterator + '_ { + self.child_ids.iter().copied() } - pub fn deps(&self) -> impl Iterator { - self.deps.iter() + /// Gets the dependencies along with an of the symbol members' dependencies. + pub fn deps( + &self, + ) -> impl Iterator, &SymbolDep)> { + self.deps.iter().map(|d| (None, d)).chain( + self + .members + .values() + .flat_map(|member| member.deps().map(move |d| (Some(member), d))), + ) } + /// The symbol's associated declarations. A symbol can represent many declarations + /// if they have the same name via declaration merging. pub fn decls(&self) -> impl Iterator { self.decls.values() } + /// Gets a member of a symbol by member identifier. + /// + /// This will return members of classes and interfaces. + pub fn member(&self, member_id: SymbolMemberId) -> Option<&SymbolMember> { + self.members.get(&member_id) + } + + /// Gets a map of members by member ids. + pub fn members(&self) -> &IndexMap { + &self.members + } + + /// Gets if this symbol represents a file dependency. pub fn file_dep(&self) -> Option<&FileDep> { for dep in self.decls() { if let SymbolDeclKind::FileRef(file_ref) = &dep.kind { @@ -539,6 +593,138 @@ impl Symbol { } } +#[derive(Clone)] +enum SymbolMemberDecl { + AutoAccessor(NodeRefBox), + ClassMethod(NodeRefBox), + ClassProp(NodeRefBox), + Constructor(NodeRefBox), + TsIndexSignature(NodeRefBox), + TsCallSignatureDecl(NodeRefBox), + TsConstructSignatureDecl(NodeRefBox), + TsPropertySignature(NodeRefBox), + TsGetterSignature(NodeRefBox), + TsSetterSignature(NodeRefBox), + TsMethodSignature(NodeRefBox), +} + +impl std::fmt::Debug for SymbolMemberDecl { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple("SymbolMemberDecl") + .field(&"") + .finish() + } +} + +impl SymbolMemberDecl { + /// Node of the symbol member declaration. + pub fn node(&self) -> SymbolMemberNodeRef { + match &self { + SymbolMemberDecl::AutoAccessor(n) => { + SymbolMemberNodeRef::AutoAccessor(n.value()) + } + SymbolMemberDecl::ClassMethod(n) => { + SymbolMemberNodeRef::ClassMethod(n.value()) + } + SymbolMemberDecl::ClassProp(n) => { + SymbolMemberNodeRef::ClassProp(n.value()) + } + SymbolMemberDecl::Constructor(n) => { + SymbolMemberNodeRef::Constructor(n.value()) + } + SymbolMemberDecl::TsIndexSignature(n) => { + SymbolMemberNodeRef::TsIndexSignature(n.value()) + } + SymbolMemberDecl::TsCallSignatureDecl(n) => { + SymbolMemberNodeRef::TsCallSignatureDecl(n.value()) + } + SymbolMemberDecl::TsConstructSignatureDecl(n) => { + SymbolMemberNodeRef::TsConstructSignatureDecl(n.value()) + } + SymbolMemberDecl::TsPropertySignature(n) => { + SymbolMemberNodeRef::TsPropertySignature(n.value()) + } + SymbolMemberDecl::TsGetterSignature(n) => { + SymbolMemberNodeRef::TsGetterSignature(n.value()) + } + SymbolMemberDecl::TsSetterSignature(n) => { + SymbolMemberNodeRef::TsSetterSignature(n.value()) + } + SymbolMemberDecl::TsMethodSignature(n) => { + SymbolMemberNodeRef::TsMethodSignature(n.value()) + } + } + } + + /// Range of the symbol member. + pub fn range(&self) -> SourceRange { + match self.node() { + SymbolMemberNodeRef::AutoAccessor(n) => n.range(), + SymbolMemberNodeRef::ClassMethod(n) => n.range(), + SymbolMemberNodeRef::ClassProp(n) => n.range(), + SymbolMemberNodeRef::Constructor(n) => n.range(), + SymbolMemberNodeRef::TsIndexSignature(n) => n.range(), + SymbolMemberNodeRef::TsCallSignatureDecl(n) => n.range(), + SymbolMemberNodeRef::TsConstructSignatureDecl(n) => n.range(), + SymbolMemberNodeRef::TsPropertySignature(n) => n.range(), + SymbolMemberNodeRef::TsGetterSignature(n) => n.range(), + SymbolMemberNodeRef::TsSetterSignature(n) => n.range(), + SymbolMemberNodeRef::TsMethodSignature(n) => n.range(), + } + } +} + +#[derive(Debug, Clone, Copy)] +pub enum SymbolMemberNodeRef<'a> { + AutoAccessor(&'a AutoAccessor), + ClassMethod(&'a ClassMethod), + ClassProp(&'a ClassProp), + Constructor(&'a Constructor), + TsIndexSignature(&'a TsIndexSignature), + TsCallSignatureDecl(&'a TsCallSignatureDecl), + TsConstructSignatureDecl(&'a TsConstructSignatureDecl), + TsPropertySignature(&'a TsPropertySignature), + TsGetterSignature(&'a TsGetterSignature), + TsSetterSignature(&'a TsSetterSignature), + TsMethodSignature(&'a TsMethodSignature), +} + +#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] +pub struct SymbolMemberId(u32); + +impl std::fmt::Debug for SymbolMemberId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // for less verbose debugging + write!(f, "{}", self.0) + } +} + +#[derive(Debug, Clone)] +pub struct SymbolMember { + symbol_member_id: SymbolMemberId, + decl: SymbolMemberDecl, + deps: IndexSet, +} + +impl SymbolMember { + pub fn symbol_member_id(&self) -> SymbolMemberId { + self.symbol_member_id + } + + pub fn deps(&self) -> impl Iterator { + self.deps.iter() + } + + pub fn node(&self) -> SymbolMemberNodeRef { + self.decl.node() + } + + pub fn range(&self) -> SourceRange { + self.decl.range() + } +} + +/// A unique identifier for a symbol, which consists of the module id and symbol id. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct UniqueSymbolId { pub module_id: ModuleId, @@ -740,7 +926,7 @@ pub struct EsmModuleSymbol { source: ParsedSource, next_symbol_id: SymbolId, exports: IndexMap, - child_decls: IndexSet, + child_ids: IndexSet, /// The re-export specifiers. re_exports: Vec, // note: not all symbol ids have an swc id. For example, default exports @@ -753,7 +939,7 @@ impl std::fmt::Debug for EsmModuleSymbol { f.debug_struct("EsmModuleSymbol") .field("module_id", &self.module_id) .field("specifier", &self.specifier.as_str()) - .field("child_decls", &self.child_decls) + .field("child_ids", &self.child_ids) .field("exports", &self.exports) .field("re_exports", &self.re_exports) .field("swc_id_to_symbol_id", &self.swc_id_to_symbol_id) @@ -787,8 +973,8 @@ impl EsmModuleSymbol { self.as_ref().exports(module_graph, root_symbol) } - pub fn child_decls(&self) -> impl Iterator + '_ { - self.child_decls.iter().copied() + pub fn child_ids(&self) -> impl Iterator + '_ { + self.child_ids.iter().copied() } pub(crate) fn ensure_default_export_symbol( @@ -801,7 +987,7 @@ impl EsmModuleSymbol { *symbol_id } else { let symbol_id = self.get_next_symbol_id(); - let mut symbol = Symbol::new(symbol_id); + let mut symbol = Symbol::new(self.module_id, symbol_id); symbol.insert_decl(symbol_decl); self.symbols.insert(symbol_id, symbol); self.exports.insert("default".to_string(), symbol_id); @@ -811,7 +997,9 @@ impl EsmModuleSymbol { pub(crate) fn create_new_symbol(&mut self) -> &mut Symbol { let symbol_id = self.get_next_symbol_id(); - self.symbols.insert(symbol_id, Symbol::new(symbol_id)); + self + .symbols + .insert(symbol_id, Symbol::new(self.module_id, symbol_id)); self.symbols.get_mut(&symbol_id).unwrap() } @@ -868,7 +1056,7 @@ impl EsmModuleSymbol { if let Some(symbol) = self.symbols.get_mut(&symbol_id) { symbol.insert_decl(symbol_decl); } else { - let mut symbol = Symbol::new(symbol_id); + let mut symbol = Symbol::new(self.module_id, symbol_id); symbol.insert_decl(symbol_decl); self.symbols.insert(symbol_id, symbol); } @@ -892,6 +1080,7 @@ struct SymbolFiller<'a> { specifier: &'a ModuleSpecifier, source: &'a ParsedSource, diagnostics: Vec, + next_symbol_member_id: SymbolMemberId, } impl<'a> SymbolFiller<'a> { @@ -924,7 +1113,7 @@ impl<'a> SymbolFiller<'a> { file_module.exports.insert(name, symbol_id); }, &|file_module, symbol_id| { - file_module.child_decls.insert(symbol_id); + file_module.child_ids.insert(symbol_id); }, ); } @@ -1631,11 +1820,11 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_class_decl(&self, symbol: &mut Symbol, n: &ClassDecl) { + fn fill_class_decl(&mut self, symbol: &mut Symbol, n: &ClassDecl) { self.fill_class(symbol, &n.class); } - fn fill_class(&self, symbol: &mut Symbol, n: &Class) { + fn fill_class(&mut self, symbol: &mut Symbol, n: &Class) { if let Some(type_params) = &n.type_params { self.fill_ts_type_param_decl(symbol, type_params); } @@ -1671,14 +1860,46 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_ts_interface(&self, symbol: &mut Symbol, n: &TsInterfaceDecl) { - let mut visitor = SymbolFillVisitor { symbol }; - n.visit_with(&mut visitor); + fn fill_ts_interface(&mut self, symbol: &mut Symbol, n: &TsInterfaceDecl) { + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(symbol, type_params); + } + for extends in &n.extends { + self.fill_ts_expr_with_type_args(symbol, extends); + } + + for member in &n.body.body { + match member { + TsTypeElement::TsCallSignatureDecl(n) => { + self.fill_ts_call_signature_decl(symbol, n); + } + TsTypeElement::TsConstructSignatureDecl(n) => { + self.fill_ts_construct_signature(symbol, n); + } + TsTypeElement::TsPropertySignature(n) => { + self.fill_ts_property_signature(symbol, n); + } + TsTypeElement::TsIndexSignature(n) => { + self.fill_ts_index_signature(symbol, n); + } + TsTypeElement::TsMethodSignature(n) => { + self.fill_ts_method_signature(symbol, n); + } + TsTypeElement::TsGetterSignature(n) => { + self.fill_ts_getter_signature(symbol, n); + } + TsTypeElement::TsSetterSignature(n) => { + self.fill_ts_setter_signature(symbol, n); + } + } + } } fn fill_ts_type_alias(&self, symbol: &mut Symbol, n: &TsTypeAliasDecl) { - let mut visitor = SymbolFillVisitor { symbol }; - n.visit_with(&mut visitor); + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(symbol, type_params); + } + self.fill_ts_type(symbol, &n.type_ann) } fn fill_ts_enum(&self, symbol: &mut Symbol, n: &TsEnumDecl) { @@ -1771,7 +1992,7 @@ impl<'a> SymbolFiller<'a> { file_module .symbol_mut(mod_symbol_id) .unwrap() - .child_decls + .child_ids .insert(symbol_id); }, ); @@ -2047,7 +2268,7 @@ impl<'a> SymbolFiller<'a> { fn fill_ts_type_param_decl( &self, - symbol: &mut Symbol, + symbol: &mut impl SymbolFillable, type_params: &TsTypeParamDecl, ) { for param in &type_params.params { @@ -2055,7 +2276,11 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_ts_type_param(&self, symbol: &mut Symbol, param: &TsTypeParam) { + fn fill_ts_type_param( + &self, + symbol: &mut impl SymbolFillable, + param: &TsTypeParam, + ) { if let Some(constraint) = ¶m.constraint { self.fill_ts_type(symbol, constraint); } @@ -2074,13 +2299,13 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_expr(&self, symbol: &mut Symbol, n: &Expr) { + fn fill_expr(&self, symbol: &mut impl SymbolFillable, n: &Expr) { let mut visitor = SymbolFillVisitor { symbol }; n.visit_with(&mut visitor); } fn fill_ts_class_members( - &self, + &mut self, symbol: &mut Symbol, members: &[ClassMember], ) { @@ -2122,11 +2347,13 @@ impl<'a> SymbolFiller<'a> { match member { ClassMember::Constructor(ctor) => self.fill_ctor(symbol, ctor), ClassMember::Method(method) => self.fill_method(symbol, method), - ClassMember::PrivateMethod(method) => { - self.fill_private_method(symbol, method) + ClassMember::PrivateMethod(_) => { + // do nothing, private } ClassMember::ClassProp(prop) => self.fill_class_prop(symbol, prop), - ClassMember::PrivateProp(prop) => self.fill_private_prop(symbol, prop), + ClassMember::PrivateProp(_) => { + // do nothing, private properties are not emitted with their type + } ClassMember::TsIndexSignature(signature) => { self.fill_ts_index_signature(symbol, signature) } @@ -2140,42 +2367,48 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_ctor(&self, symbol: &mut Symbol, ctor: &Constructor) { + fn fill_ctor(&mut self, symbol: &mut Symbol, ctor: &Constructor) { if ctor.accessibility == Some(Accessibility::Private) { return; // ignore, private } + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::Constructor(ctor)); + for param in &ctor.params { match param { ParamOrTsParamProp::TsParamProp(param) => { - self.fill_ts_param_prop(symbol, param) + self.fill_ts_param_prop(member, param) } - ParamOrTsParamProp::Param(param) => self.fill_param(symbol, param), + ParamOrTsParamProp::Param(param) => self.fill_param(member, param), } } } - fn fill_method(&self, symbol: &mut Symbol, method: &ClassMethod) { + fn fill_method(&mut self, symbol: &mut Symbol, method: &ClassMethod) { if method.accessibility == Some(Accessibility::Private) { return; // ignore, private } - self.fill_prop_name(symbol, &method.key); + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::ClassMethod(method)); + + self.fill_prop_name(member, &method.key); if let Some(type_params) = &method.function.type_params { - self.fill_ts_type_param_decl(symbol, type_params) + self.fill_ts_type_param_decl(member, type_params) } for param in &method.function.params { - self.fill_param(symbol, param) + self.fill_param(member, param) } if let Some(return_type) = &method.function.return_type { - self.fill_ts_type_ann(symbol, return_type) + self.fill_ts_type_ann(member, return_type) } } - fn fill_prop_name(&self, symbol: &mut Symbol, key: &PropName) { + fn fill_prop_name(&self, member: &mut SymbolMember, key: &PropName) { match key { PropName::Computed(name) => { - self.fill_expr(symbol, &name.expr); + self.fill_expr(member, &name.expr); } PropName::Ident(_) | PropName::Str(_) @@ -2186,11 +2419,15 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_ts_param_prop(&self, symbol: &mut Symbol, param: &TsParamProp) { + fn fill_ts_param_prop( + &self, + symbol_member: &mut SymbolMember, + param: &TsParamProp, + ) { match ¶m.param { TsParamPropParam::Ident(ident) => { if let Some(type_ann) = &ident.type_ann { - self.fill_ts_type_ann(symbol, type_ann) + self.fill_ts_type_ann(symbol_member, type_ann) } } TsParamPropParam::Assign(_) => { @@ -2199,11 +2436,11 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_param(&self, symbol: &mut Symbol, param: &Param) { + fn fill_param(&self, symbol: &mut impl SymbolFillable, param: &Param) { self.fill_pat(symbol, ¶m.pat); } - fn fill_pat(&self, symbol: &mut Symbol, pat: &Pat) { + fn fill_pat(&self, symbol: &mut impl SymbolFillable, pat: &Pat) { match pat { Pat::Ident(n) => { if let Some(type_ann) = &n.type_ann { @@ -2237,62 +2474,285 @@ impl<'a> SymbolFiller<'a> { } } - fn fill_ts_type_ann(&self, symbol: &mut Symbol, type_ann: &TsTypeAnn) { + fn fill_ts_type_ann( + &self, + symbol: &mut impl SymbolFillable, + type_ann: &TsTypeAnn, + ) { self.fill_ts_type(symbol, &type_ann.type_ann) } - fn fill_ts_type(&self, symbol: &mut Symbol, n: &TsType) { + fn fill_ts_type(&self, symbol: &mut impl SymbolFillable, n: &TsType) { let mut visitor = SymbolFillVisitor { symbol }; n.visit_with(&mut visitor); } - fn fill_private_method(&self, _symbol: &mut Symbol, _method: &PrivateMethod) { - // do nothing, private - } - - fn fill_class_prop(&self, symbol: &mut Symbol, prop: &ClassProp) { + fn fill_class_prop(&mut self, symbol: &mut Symbol, prop: &ClassProp) { if prop.accessibility == Some(Accessibility::Private) { return; // ignore, private } + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::ClassProp(prop)); + if let Some(type_ann) = &prop.type_ann { - self.fill_ts_type_ann(symbol, type_ann) + self.fill_ts_type_ann(member, type_ann) } } - fn fill_private_prop(&self, _symbol: &mut Symbol, _prop: &PrivateProp) { - // do nothing, private properties are not emitted with their type + fn fill_ts_call_signature_decl( + &mut self, + symbol: &mut Symbol, + n: &TsCallSignatureDecl, + ) { + let member = self + .get_symbol_member(symbol, SymbolMemberNodeRef::TsCallSignatureDecl(n)); + + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(member, type_params); + } + for param in &n.params { + self.fill_ts_fn_param(member, param); + } + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) + } + } + + fn fill_ts_construct_signature( + &mut self, + symbol: &mut Symbol, + n: &TsConstructSignatureDecl, + ) { + let member = self.get_symbol_member( + symbol, + SymbolMemberNodeRef::TsConstructSignatureDecl(n), + ); + + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(member, type_params); + } + for param in &n.params { + self.fill_ts_fn_param(member, param); + } + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) + } + } + + fn fill_ts_property_signature( + &mut self, + symbol: &mut Symbol, + n: &TsPropertySignature, + ) { + let member = self + .get_symbol_member(symbol, SymbolMemberNodeRef::TsPropertySignature(n)); + + if let Some(init) = &n.init { + self.fill_expr(member, init); + } + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(member, type_params); + } + for param in &n.params { + self.fill_ts_fn_param(member, param); + } + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) + } } fn fill_ts_index_signature( - &self, + &mut self, + symbol: &mut Symbol, + n: &TsIndexSignature, + ) { + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::TsIndexSignature(n)); + for param in &n.params { + self.fill_ts_fn_param(member, param) + } + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) + } + } + + fn fill_ts_method_signature( + &mut self, symbol: &mut Symbol, - signature: &TsIndexSignature, + n: &TsMethodSignature, ) { - if let Some(type_ann) = &signature.type_ann { - self.fill_ts_type_ann(symbol, type_ann) + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::TsMethodSignature(n)); + + if let Some(type_params) = &n.type_params { + self.fill_ts_type_param_decl(member, type_params); + } + for param in &n.params { + self.fill_ts_fn_param(member, param) + } + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) } } - fn fill_auto_accessor(&self, symbol: &mut Symbol, prop: &AutoAccessor) { - if let Some(type_ann) = &prop.type_ann { - self.fill_ts_type_ann(symbol, type_ann) + fn fill_ts_getter_signature( + &mut self, + symbol: &mut Symbol, + n: &TsGetterSignature, + ) { + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::TsGetterSignature(n)); + + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) } } + fn fill_ts_setter_signature( + &mut self, + symbol: &mut Symbol, + n: &TsSetterSignature, + ) { + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::TsSetterSignature(n)); + + self.fill_ts_fn_param(member, &n.param); + } + + fn fill_auto_accessor(&mut self, symbol: &mut Symbol, n: &AutoAccessor) { + match &n.key { + Key::Private(_) => { + return; // ignore, private + } + Key::Public(_) => {} + } + + let member = + self.get_symbol_member(symbol, SymbolMemberNodeRef::AutoAccessor(n)); + if let Some(type_ann) = &n.type_ann { + self.fill_ts_type_ann(member, type_ann) + } + } + + fn fill_ts_fn_param(&self, member: &mut SymbolMember, param: &TsFnParam) { + let mut visitor = SymbolFillVisitor { symbol: member }; + param.visit_with(&mut visitor); + } + fn has_internal_jsdoc(&self, pos: SourcePos) -> bool { has_internal_jsdoc(self.source, pos) } + + fn get_symbol_member<'b>( + &mut self, + symbol: &'b mut Symbol, + node_ref: SymbolMemberNodeRef, + ) -> &'b mut SymbolMember { + let decl = match node_ref { + SymbolMemberNodeRef::AutoAccessor(n) => { + SymbolMemberDecl::AutoAccessor(NodeRefBox::unsafe_new(self.source, n)) + } + + SymbolMemberNodeRef::ClassMethod(n) => { + SymbolMemberDecl::ClassMethod(NodeRefBox::unsafe_new(self.source, n)) + } + + SymbolMemberNodeRef::ClassProp(n) => { + SymbolMemberDecl::ClassProp(NodeRefBox::unsafe_new(self.source, n)) + } + + SymbolMemberNodeRef::Constructor(n) => { + SymbolMemberDecl::Constructor(NodeRefBox::unsafe_new(self.source, n)) + } + + SymbolMemberNodeRef::TsIndexSignature(n) => { + SymbolMemberDecl::TsIndexSignature(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + + SymbolMemberNodeRef::TsCallSignatureDecl(n) => { + SymbolMemberDecl::TsCallSignatureDecl(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + + SymbolMemberNodeRef::TsConstructSignatureDecl(n) => { + SymbolMemberDecl::TsConstructSignatureDecl(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + + SymbolMemberNodeRef::TsPropertySignature(n) => { + SymbolMemberDecl::TsPropertySignature(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + SymbolMemberNodeRef::TsGetterSignature(n) => { + SymbolMemberDecl::TsGetterSignature(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + + SymbolMemberNodeRef::TsSetterSignature(n) => { + SymbolMemberDecl::TsSetterSignature(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + + SymbolMemberNodeRef::TsMethodSignature(n) => { + SymbolMemberDecl::TsMethodSignature(NodeRefBox::unsafe_new( + self.source, + n, + )) + } + }; + let next_id = self.next_symbol_member_id; + self.next_symbol_member_id = SymbolMemberId(next_id.0 + 1); + let result = symbol.members.insert( + next_id, + SymbolMember { + symbol_member_id: next_id, + decl, + deps: Default::default(), + }, + ); + debug_assert!(result.is_none()); // should never re-insert + symbol.members.get_mut(&next_id).unwrap() + } +} + +trait SymbolFillable { + fn add_dep(&mut self, symbol_dep: SymbolDep); +} + +impl SymbolFillable for Symbol { + fn add_dep(&mut self, symbol_dep: SymbolDep) { + self.deps.insert(symbol_dep); + } +} + +impl SymbolFillable for SymbolMember { + fn add_dep(&mut self, symbol_dep: SymbolDep) { + self.deps.insert(symbol_dep); + } } -struct SymbolFillVisitor<'a> { - symbol: &'a mut Symbol, +struct SymbolFillVisitor<'a, T: SymbolFillable> { + symbol: &'a mut T, } -impl<'a> Visit for SymbolFillVisitor<'a> { +impl<'a, T: SymbolFillable> Visit for SymbolFillVisitor<'a, T> { fn visit_ident(&mut self, n: &Ident) { let id = n.to_id(); - self.symbol.deps.insert(id.into()); + self.symbol.add_dep(id.into()); } fn visit_ts_import_type(&mut self, n: &TsImportType) { @@ -2306,14 +2766,13 @@ impl<'a> Visit for SymbolFillVisitor<'a> { }; self .symbol - .deps - .insert(SymbolDep::ImportType(n.arg.value.to_string(), parts)); + .add_dep(SymbolDep::ImportType(n.arg.value.to_string(), parts)); n.type_args.visit_with(self); } fn visit_ts_qualified_name(&mut self, n: &TsQualifiedName) { let (id, parts) = ts_qualified_name_parts(n); - self.symbol.deps.insert(SymbolDep::QualifiedId(id, parts)); + self.symbol.add_dep(SymbolDep::QualifiedId(id, parts)); } } diff --git a/src/symbols/cross_module.rs b/src/symbols/cross_module.rs index ec5c4308a..df649c0c0 100644 --- a/src/symbols/cross_module.rs +++ b/src/symbols/cross_module.rs @@ -34,10 +34,7 @@ pub struct Definition<'a> { impl<'a> Definition<'a> { pub fn unique_id(&self) -> UniqueSymbolId { - UniqueSymbolId { - module_id: self.module.module_id(), - symbol_id: self.symbol.symbol_id(), - } + self.symbol.unique_id() } pub fn range(&self) -> &SourceRange { @@ -77,10 +74,7 @@ fn go_to_definitions_internal<'a>( visited_symbols: &mut HashSet, specifier_to_module: &impl Fn(&ModuleSpecifier) -> Option>, ) -> Vec> { - if !visited_symbols.insert(UniqueSymbolId { - module_id: module.module_id(), - symbol_id: symbol.symbol_id(), - }) { + if !visited_symbols.insert(symbol.unique_id()) { return Vec::new(); } let mut definitions = Vec::new(); diff --git a/src/symbols/mod.rs b/src/symbols/mod.rs index d40ed618c..f1b3cb078 100644 --- a/src/symbols/mod.rs +++ b/src/symbols/mod.rs @@ -14,6 +14,9 @@ pub use self::analyzer::SymbolDecl; pub use self::analyzer::SymbolFillDiagnostic; pub use self::analyzer::SymbolFillDiagnosticKind; pub use self::analyzer::SymbolId; +pub use self::analyzer::SymbolMember; +pub use self::analyzer::SymbolMemberId; +pub use self::analyzer::SymbolMemberNodeRef; pub use self::analyzer::SymbolNodeRef; pub use self::analyzer::UniqueSymbolId; pub use self::cross_module::Definition; diff --git a/tests/helpers/test_builder.rs b/tests/helpers/test_builder.rs index 6b10f319a..9f5f59157 100644 --- a/tests/helpers/test_builder.rs +++ b/tests/helpers/test_builder.rs @@ -141,9 +141,10 @@ impl TestBuilder { Some(Box::new(source_parser)), None, ); - let capturing_parser = capturing_analyzer.as_capturing_parser(); - let root_symbol = - deno_graph::symbols::RootSymbol::new(&graph, &capturing_parser); + let root_symbol = deno_graph::symbols::RootSymbol::new( + &graph, + capturing_analyzer.as_capturing_parser(), + ); Ok(symbols::SymbolsResult { output: { let entrypoint_symbol = root_symbol diff --git a/tests/specs/symbols/Basic.txt b/tests/specs/symbols/Basic.txt index 4352f3624..145aace39 100644 --- a/tests/specs/symbols/Basic.txt +++ b/tests/specs/symbols/Basic.txt @@ -32,7 +32,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -74,6 +74,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -92,24 +95,23 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "AInner", - #2, - ), - ), - Id( - ( - "prop", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -128,24 +130,23 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "AInnerUnused", - #2, - ), - ), - Id( - ( - "prop2", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -164,18 +165,30 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "AInner", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 2: SymbolMember { + symbol_member_id: 2, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "AInner", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 3: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -194,18 +207,15 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -225,10 +235,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -248,12 +262,6 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "D", - #2, - ), - ), Id( ( "C", @@ -261,8 +269,9 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -271,7 +280,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 3, 5, }, @@ -304,6 +313,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -326,10 +338,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -352,10 +368,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -400,10 +420,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -426,10 +450,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -456,10 +484,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -486,8 +518,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Classes01.txt b/tests/specs/symbols/Classes01.txt index 252f74121..babd98cf2 100644 --- a/tests/specs/symbols/Classes01.txt +++ b/tests/specs/symbols/Classes01.txt @@ -1,8 +1,12 @@ # mod.ts export class A { b: B; + constructor(c: C) { + } } +interface C {} + class BBase { } @@ -51,7 +55,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -67,6 +71,7 @@ file:///mod.ts: EsmModuleSymbol { 12, 13, 14, + 15, }, exports: { "A": 0, @@ -78,64 +83,71 @@ file:///mod.ts: EsmModuleSymbol { #2, ): 0, ( - "BBase", + "C", #2, ): 1, ( - "IBase", + "BBase", #2, ): 2, ( - "B", + "IBase", #2, ): 3, ( - "PropValue", + "B", #2, ): 4, ( - "ReturnValue", + "PropValue", #2, ): 5, ( - "Param", + "ReturnValue", #2, ): 6, ( - "PrivateParam", + "Param", #2, ): 7, ( - "PrivateReturn", + "PrivateParam", #2, ): 8, ( - "PrivateProp", + "PrivateReturn", #2, ): 9, ( - "CtorProp", + "PrivateProp", #2, ): 10, ( - "OverloadParam", + "CtorProp", #2, ): 11, ( - "OverloadReturn", + "OverloadParam", #2, ): 12, ( - "PrivateImplementationParam", + "OverloadReturn", #2, ): 13, ( - "PrivateImplementationReturn", + "PrivateImplementationParam", #2, ): 14, + ( + "PrivateImplementationReturn", + #2, + ): 15, }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -144,7 +156,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 26, + 52, ), }, kind: Definition( @@ -154,27 +166,53 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "B", + #2, + ), + ), + }, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "C", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 28, + 54, ), end: SourcePos( - 44, + 68, ), }, kind: Definition( @@ -185,19 +223,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 46, + 70, ), end: SourcePos( - 65, + 86, ), }, kind: Definition( @@ -207,27 +249,51 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "IBase", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 67, + 88, + ), + end: SourcePos( + 107, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_ids: {}, + exports: {}, + members: {}, + }, + 4: Symbol { + module_id: ModuleId( + 0, + ), + symbol_id: 4, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 109, ), end: SourcePos( - 557, + 599, ), }, kind: Definition( @@ -250,85 +316,107 @@ file:///mod.ts: EsmModuleSymbol { #2, ), ), - Id( - ( - "PropValue", - #2, - ), - ), - Id( - ( - "ReturnValue", - #2, - ), - ), - Id( - ( - "Param", - #2, - ), - ), - Id( - ( - "OverloadParam", - #2, - ), - ), - Id( - ( - "OverloadReturn", - #2, - ), - ), - Id( - ( - "PrivateImplementationParam", - #2, - ), - ), - Id( - ( - "PrivateImplementationReturn", - #2, - ), - ), }, - child_decls: {}, + child_ids: {}, exports: {}, - }, - 4: Symbol { - symbol_id: 4, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 559, + members: { + 2: SymbolMember { + symbol_member_id: 2, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "PropValue", + #2, + ), ), - end: SourcePos( - 577, + }, + }, + 3: SymbolMember { + symbol_member_id: 3, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "ReturnValue", + #2, + ), ), }, - kind: Definition( - SymbolNode( - "", + }, + 4: SymbolMember { + symbol_member_id: 4, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "Param", + #2, + ), + ), + }, + }, + 5: SymbolMember { + symbol_member_id: 5, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "OverloadParam", + #2, + ), + ), + Id( + ( + "OverloadReturn", + #2, + ), ), + }, + }, + 6: SymbolMember { + symbol_member_id: 6, + decl: SymbolMemberDecl( + "", ), + deps: { + Id( + ( + "PrivateImplementationParam", + #2, + ), + ), + Id( + ( + "PrivateImplementationReturn", + #2, + ), + ), + }, }, - ], - deps: {}, - child_decls: {}, - exports: {}, + }, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 578, + 601, ), end: SourcePos( - 598, + 619, ), }, kind: Definition( @@ -339,19 +427,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 6: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 6, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 599, + 620, ), end: SourcePos( - 613, + 640, ), }, kind: Definition( @@ -362,19 +454,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 7: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 7, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 614, + 641, ), end: SourcePos( - 635, + 655, ), }, kind: Definition( @@ -385,19 +481,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 8: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 8, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 636, + 656, ), end: SourcePos( - 658, + 677, ), }, kind: Definition( @@ -408,19 +508,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 9: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 9, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 659, + 678, ), end: SourcePos( - 679, + 700, ), }, kind: Definition( @@ -431,19 +535,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 10: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 10, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 680, + 701, ), end: SourcePos( - 697, + 721, ), }, kind: Definition( @@ -454,19 +562,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 11: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 11, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 698, + 722, ), end: SourcePos( - 720, + 739, ), }, kind: Definition( @@ -477,19 +589,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 12: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 12, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 721, + 740, ), end: SourcePos( - 744, + 762, ), }, kind: Definition( @@ -500,19 +616,23 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 13: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 13, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 745, + 763, ), end: SourcePos( - 780, + 786, ), }, kind: Definition( @@ -523,19 +643,50 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 14: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 14, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 781, + 787, + ), + end: SourcePos( + 822, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_ids: {}, + exports: {}, + members: {}, + }, + 15: Symbol { + module_id: ModuleId( + 0, + ), + symbol_id: 15, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 823, ), end: SourcePos( - 817, + 859, ), }, kind: Definition( @@ -546,13 +697,16 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } == export definitions == -[A]: file:///mod.ts:0..26 +[A]: file:///mod.ts:0..52 export class A { b: B; + ... + } } diff --git a/tests/specs/symbols/DeclarationMerging01.txt b/tests/specs/symbols/DeclarationMerging01.txt index f4f7ccf78..eea348afe 100644 --- a/tests/specs/symbols/DeclarationMerging01.txt +++ b/tests/specs/symbols/DeclarationMerging01.txt @@ -30,7 +30,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 2, 4, @@ -69,6 +69,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -132,14 +135,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, }, exports: { "Label": 1, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -159,10 +166,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -226,14 +237,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 3, }, exports: { "mixColor": 3, }, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -253,10 +268,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -320,14 +339,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 5, }, exports: { "other": 5, }, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -347,8 +370,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportAssignment01.txt b/tests/specs/symbols/ExportAssignment01.txt index 5a991a38b..8eaf99c43 100644 --- a/tests/specs/symbols/ExportAssignment01.txt +++ b/tests/specs/symbols/ExportAssignment01.txt @@ -11,7 +11,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -26,6 +26,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -61,10 +64,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -92,8 +99,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDefault01.txt b/tests/specs/symbols/ExportDefault01.txt index 9aecf989d..cab592fa0 100644 --- a/tests/specs/symbols/ExportDefault01.txt +++ b/tests/specs/symbols/ExportDefault01.txt @@ -46,7 +46,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 4, 5, 6, @@ -78,6 +78,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -100,10 +103,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -126,10 +133,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -152,10 +163,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -174,18 +189,30 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "A", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "A", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 4: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -204,18 +231,37 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, + 2: SymbolMember { + symbol_member_id: 2, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "B", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 5: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -235,10 +281,22 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: { + 3: SymbolMember { + symbol_member_id: 3, + decl: SymbolMemberDecl( + "", + ), + deps: {}, + }, + }, }, 6: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 6, decls: [ SymbolDecl { @@ -258,8 +316,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -268,7 +327,7 @@ file:///class.ts: EsmModuleSymbol { 2, ), specifier: "file:///class.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -281,6 +340,9 @@ file:///class.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -300,8 +362,9 @@ file:///class.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -310,7 +373,7 @@ file:///function.ts: EsmModuleSymbol { 3, ), specifier: "file:///function.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -323,6 +386,9 @@ file:///function.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 3, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -342,8 +408,9 @@ file:///function.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -352,7 +419,7 @@ file:///interface.ts: EsmModuleSymbol { 4, ), specifier: "file:///interface.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -365,6 +432,9 @@ file:///interface.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 4, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -383,16 +453,10 @@ file:///interface.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -401,7 +465,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 4, "C1": 1, @@ -429,6 +493,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -467,10 +534,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -515,10 +586,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -563,10 +638,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -611,10 +690,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -642,8 +725,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDefault02.txt b/tests/specs/symbols/ExportDefault02.txt index f428faeed..84b94af73 100644 --- a/tests/specs/symbols/ExportDefault02.txt +++ b/tests/specs/symbols/ExportDefault02.txt @@ -7,7 +7,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 1, }, exports: { @@ -22,6 +22,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -49,10 +52,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -88,8 +95,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDefault03.txt b/tests/specs/symbols/ExportDefault03.txt index b5da48be0..412ceadc6 100644 --- a/tests/specs/symbols/ExportDefault03.txt +++ b/tests/specs/symbols/ExportDefault03.txt @@ -18,7 +18,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -31,6 +31,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -64,8 +67,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -74,7 +78,7 @@ file:///b.ts: EsmModuleSymbol { 2, ), specifier: "file:///b.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -95,6 +99,9 @@ file:///b.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -114,10 +121,14 @@ file:///b.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -137,8 +148,9 @@ file:///b.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -147,7 +159,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 1, }, exports: { @@ -163,6 +175,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -185,10 +200,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -208,8 +227,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDefault04.txt b/tests/specs/symbols/ExportDefault04.txt index 959ad8a47..b19180a06 100644 --- a/tests/specs/symbols/ExportDefault04.txt +++ b/tests/specs/symbols/ExportDefault04.txt @@ -7,7 +7,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: {}, re_exports: [], swc_id_to_symbol_id: {}, diff --git a/tests/specs/symbols/ExportDefaultLiteral01.txt b/tests/specs/symbols/ExportDefaultLiteral01.txt index be41b9676..61045135e 100644 --- a/tests/specs/symbols/ExportDefaultLiteral01.txt +++ b/tests/specs/symbols/ExportDefaultLiteral01.txt @@ -7,7 +7,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -15,6 +15,9 @@ file:///mod.ts: EsmModuleSymbol { swc_id_to_symbol_id: {}, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -34,8 +37,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDefaultLiteral02.txt b/tests/specs/symbols/ExportDefaultLiteral02.txt index 9987c1a4b..1a2135ad5 100644 --- a/tests/specs/symbols/ExportDefaultLiteral02.txt +++ b/tests/specs/symbols/ExportDefaultLiteral02.txt @@ -7,7 +7,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -15,6 +15,9 @@ file:///mod.ts: EsmModuleSymbol { swc_id_to_symbol_id: {}, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -34,8 +37,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportDestructured.txt b/tests/specs/symbols/ExportDestructured.txt index 968bd9f48..2af12bbd8 100644 --- a/tests/specs/symbols/ExportDestructured.txt +++ b/tests/specs/symbols/ExportDestructured.txt @@ -20,7 +20,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -50,6 +50,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -69,10 +72,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -105,10 +112,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -137,10 +148,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -173,10 +188,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -209,8 +228,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportStar01.txt b/tests/specs/symbols/ExportStar01.txt index d9fe8c476..c4900d6bf 100644 --- a/tests/specs/symbols/ExportStar01.txt +++ b/tests/specs/symbols/ExportStar01.txt @@ -41,7 +41,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 4, 5, 6, @@ -73,6 +73,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -95,10 +98,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -121,10 +128,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -147,10 +158,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -169,18 +184,30 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "A", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "A", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 4: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -199,18 +226,37 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", + ), + deps: {}, + }, + 2: SymbolMember { + symbol_member_id: 2, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "B", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 5: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -230,10 +276,22 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: { + 3: SymbolMember { + symbol_member_id: 3, + decl: SymbolMemberDecl( + "", + ), + deps: {}, + }, + }, }, 6: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 6, decls: [ SymbolDecl { @@ -253,8 +311,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -263,7 +322,7 @@ file:///class.ts: EsmModuleSymbol { 2, ), specifier: "file:///class.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -276,6 +335,9 @@ file:///class.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -295,8 +357,9 @@ file:///class.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -305,7 +368,7 @@ file:///function.ts: EsmModuleSymbol { 3, ), specifier: "file:///function.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -318,6 +381,9 @@ file:///function.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 3, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -337,8 +403,9 @@ file:///function.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -347,7 +414,7 @@ file:///interface.ts: EsmModuleSymbol { 4, ), specifier: "file:///interface.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 0, }, @@ -360,6 +427,9 @@ file:///interface.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 4, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -378,16 +448,10 @@ file:///interface.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -396,7 +460,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "namespace": 0, }, @@ -404,6 +468,9 @@ file:///mod.ts: EsmModuleSymbol { swc_id_to_symbol_id: {}, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -424,8 +491,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportedDeclare01.txt b/tests/specs/symbols/ExportedDeclare01.txt index e90ff0c48..8e05c4ed3 100644 --- a/tests/specs/symbols/ExportedDeclare01.txt +++ b/tests/specs/symbols/ExportedDeclare01.txt @@ -18,7 +18,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 3, @@ -58,6 +58,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -88,10 +91,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -111,14 +118,18 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: { + child_ids: { 2, }, exports: { "test": 2, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -160,10 +171,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -183,10 +198,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -227,18 +246,37 @@ file:///mod.ts: EsmModuleSymbol { kind: TargetSelf, }, ], - deps: { - Id( - ( - "Other", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", + ), + deps: { + Id( + ( + "Other", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -283,8 +321,9 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ExportedDeclare02.txt b/tests/specs/symbols/ExportedDeclare02.txt index 73622f1ce..f4a725ab9 100644 --- a/tests/specs/symbols/ExportedDeclare02.txt +++ b/tests/specs/symbols/ExportedDeclare02.txt @@ -8,7 +8,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -28,6 +28,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -47,10 +50,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -70,8 +77,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/FunctionOverloads01.txt b/tests/specs/symbols/FunctionOverloads01.txt index 1a51bf061..a1244271d 100644 --- a/tests/specs/symbols/FunctionOverloads01.txt +++ b/tests/specs/symbols/FunctionOverloads01.txt @@ -20,7 +20,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -49,6 +49,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -98,10 +101,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -128,14 +135,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 2, }, exports: { "inner": 2, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -185,10 +196,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -244,8 +259,9 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Functions01.txt b/tests/specs/symbols/Functions01.txt index 57cebb76d..63603eecb 100644 --- a/tests/specs/symbols/Functions01.txt +++ b/tests/specs/symbols/Functions01.txt @@ -27,7 +27,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -98,6 +98,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -142,10 +145,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -165,10 +172,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -188,10 +199,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -211,10 +226,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -234,10 +253,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -306,10 +329,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 6: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 6, decls: [ SymbolDecl { @@ -329,10 +356,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 7: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 7, decls: [ SymbolDecl { @@ -352,10 +383,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 8: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 8, decls: [ SymbolDecl { @@ -375,10 +410,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 9: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 9, decls: [ SymbolDecl { @@ -398,10 +437,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 10: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 10, decls: [ SymbolDecl { @@ -421,10 +464,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 11: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 11, decls: [ SymbolDecl { @@ -444,8 +491,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ImportEquals01.txt b/tests/specs/symbols/ImportEquals01.txt index 22b3c559f..4aa129696 100644 --- a/tests/specs/symbols/ImportEquals01.txt +++ b/tests/specs/symbols/ImportEquals01.txt @@ -12,7 +12,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 1, }, exports: { @@ -35,6 +35,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -68,10 +71,14 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -98,14 +105,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 2, }, exports: { "Inner": 2, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -125,8 +136,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ImportEquals02.txt b/tests/specs/symbols/ImportEquals02.txt index 517efe7a7..d4688cbb5 100644 --- a/tests/specs/symbols/ImportEquals02.txt +++ b/tests/specs/symbols/ImportEquals02.txt @@ -30,7 +30,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -57,6 +57,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -105,12 +108,16 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: { "B": 1, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -143,14 +150,18 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 2, }, exports: { "Other": 2, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -200,24 +211,6 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "Other", - #3, - ), - ), - Id( - ( - "prop1", - #0, - ), - ), - Id( - ( - "prop2", - #0, - ), - ), Id( ( "MyTest", @@ -225,14 +218,33 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 3, }, exports: { "MyTest": 3, }, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", + ), + deps: {}, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", + ), + deps: {}, + }, + }, }, 3: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -252,8 +264,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -262,7 +275,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 2, }, exports: { @@ -289,6 +302,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -311,10 +327,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -348,10 +368,14 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -371,12 +395,16 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: { "Inner": 3, }, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -423,8 +451,9 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ImportType01.txt b/tests/specs/symbols/ImportType01.txt index 5ac1c0d7d..6dac582ee 100644 --- a/tests/specs/symbols/ImportType01.txt +++ b/tests/specs/symbols/ImportType01.txt @@ -16,7 +16,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -35,6 +35,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -61,14 +64,18 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, }, exports: { "B": 1, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -87,22 +94,18 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #3, - ), - ), - Id( - ( - "prop", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, }, } @@ -111,7 +114,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -126,6 +129,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -144,29 +150,26 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - Id( - ( - "prop", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), - ImportType( - "./a.ts", - [ - "A", - "B", - ], - ), + deps: { + ImportType( + "./a.ts", + [ + "A", + "B", + ], + ), + }, + }, }, - child_decls: {}, - exports: {}, }, }, } diff --git a/tests/specs/symbols/ImportType02.txt b/tests/specs/symbols/ImportType02.txt index e5e07b336..da95bbded 100644 --- a/tests/specs/symbols/ImportType02.txt +++ b/tests/specs/symbols/ImportType02.txt @@ -16,7 +16,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -36,6 +36,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -54,24 +57,23 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - Id( - ( - "prop", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -91,8 +93,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -101,7 +104,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -116,6 +119,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -135,19 +141,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "Test", - #2, - ), - ), ImportType( "./a.ts", [], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Interfaces01.txt b/tests/specs/symbols/Interfaces01.txt index 1cfa8e3e1..497399ff4 100644 --- a/tests/specs/symbols/Interfaces01.txt +++ b/tests/specs/symbols/Interfaces01.txt @@ -25,7 +25,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -75,6 +75,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -93,18 +96,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "A", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -124,71 +124,82 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "Main", - #2, - ), - ), Id( ( "Extends", #2, ), ), - Id( - ( - "prop", - #0, - ), - ), - Id( - ( - "Prop", - #2, - ), - ), - Id( - ( - "method", - #0, - ), - ), - Id( - ( - "method", - #1, - ), - ), - Id( - ( - "Param", - #2, - ), - ), - Id( - ( - "Return", - #2, + }, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), - Id( - ( - "key", - #1, + deps: { + Id( + ( + "Prop", + #2, + ), + ), + }, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), - Id( - ( - "SignatureValueType", - #2, + deps: { + Id( + ( + "method", + #1, + ), + ), + Id( + ( + "Param", + #2, + ), + ), + Id( + ( + "Return", + #2, + ), + ), + }, + }, + 2: SymbolMember { + symbol_member_id: 2, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "key", + #1, + ), + ), + Id( + ( + "SignatureValueType", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -207,18 +218,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Extends", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -237,18 +245,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Prop", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -267,18 +272,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Param", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -297,18 +299,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Return", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 6: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 6, decls: [ SymbolDecl { @@ -327,30 +326,30 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "SignatureValueType", - #2, - ), - ), - Id( - ( - "other", - #0, - ), - ), - Id( - ( - "B", - #2, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 3: SymbolMember { + symbol_member_id: 3, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "B", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 7: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 7, decls: [ SymbolDecl { @@ -369,16 +368,10 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "B", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Interfaces02.txt b/tests/specs/symbols/Interfaces02.txt index 1a5667a8b..55a04ee50 100644 --- a/tests/specs/symbols/Interfaces02.txt +++ b/tests/specs/symbols/Interfaces02.txt @@ -32,7 +32,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -52,6 +52,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -107,36 +110,37 @@ file:///a.ts: EsmModuleSymbol { kind: TargetSelf, }, ], - deps: { - Id( - ( - "A1", - #2, - ), - ), - Id( - ( - "prop1", - #0, - ), - ), - Id( - ( - "prop2", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), - Id( - ( - "Prop2", - #2, + deps: {}, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "Prop2", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -155,16 +159,10 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Prop2", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -173,7 +171,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, 2, @@ -200,6 +198,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -255,42 +256,44 @@ file:///mod.ts: EsmModuleSymbol { kind: TargetSelf, }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - Id( - ( - "prop1", - #0, - ), - ), - Id( - ( - "Prop1", - #2, - ), - ), - Id( - ( - "prop2", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), - Id( - ( - "Prop2", - #2, + deps: { + Id( + ( + "Prop1", + #2, + ), + ), + }, + }, + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), + deps: { + Id( + ( + "Prop2", + #2, + ), + ), + }, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -309,18 +312,15 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Prop1", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -339,16 +339,10 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Prop2", - #2, - ), - ), - }, - child_decls: {}, + deps: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ModuleExportNameStr01.txt b/tests/specs/symbols/ModuleExportNameStr01.txt index f31162898..be8bca961 100644 --- a/tests/specs/symbols/ModuleExportNameStr01.txt +++ b/tests/specs/symbols/ModuleExportNameStr01.txt @@ -18,7 +18,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: {}, + child_ids: {}, exports: { "someName": 0, }, @@ -31,6 +31,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -64,8 +67,9 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -74,7 +78,7 @@ file:///b.ts: EsmModuleSymbol { 2, ), specifier: "file:///b.ts", - child_decls: {}, + child_ids: {}, exports: { "some-name": 0, }, @@ -82,6 +86,9 @@ file:///b.ts: EsmModuleSymbol { swc_id_to_symbol_id: {}, symbols: { 0: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -104,8 +111,9 @@ file:///b.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -114,7 +122,7 @@ file:///c.ts: EsmModuleSymbol { 3, ), specifier: "file:///c.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -129,6 +137,9 @@ file:///c.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 3, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -148,8 +159,9 @@ file:///c.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -158,7 +170,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "someOtherName": 0, }, @@ -166,6 +178,9 @@ file:///mod.ts: EsmModuleSymbol { swc_id_to_symbol_id: {}, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -188,8 +203,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Namespaces01.txt b/tests/specs/symbols/Namespaces01.txt index abbd282e2..2ac366036 100644 --- a/tests/specs/symbols/Namespaces01.txt +++ b/tests/specs/symbols/Namespaces01.txt @@ -19,7 +19,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -56,6 +56,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -103,15 +106,19 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, }, exports: { "test": 1, "Inner": 2, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -131,10 +138,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -167,14 +178,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 3, }, exports: { "test2": 3, }, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -194,10 +209,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -253,10 +272,14 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -314,8 +337,9 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/Namespaces02.txt b/tests/specs/symbols/Namespaces02.txt index a0022fd3a..3786dd0e8 100644 --- a/tests/specs/symbols/Namespaces02.txt +++ b/tests/specs/symbols/Namespaces02.txt @@ -15,7 +15,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -42,6 +42,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -74,7 +77,7 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, 3, }, @@ -82,8 +85,12 @@ file:///mod.ts: EsmModuleSymbol { "NestedNs": 1, "Foo": 3, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -110,14 +117,18 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 2, }, exports: { "Foo": 2, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -137,10 +148,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -160,8 +175,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/ReExportJson01.txt b/tests/specs/symbols/ReExportJson01.txt index 9cfc9bf82..027d17576 100644 --- a/tests/specs/symbols/ReExportJson01.txt +++ b/tests/specs/symbols/ReExportJson01.txt @@ -22,6 +22,9 @@ file:///bar.json: JsonModuleSymbol { "default": 0, }, default_symbol: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -41,8 +44,9 @@ file:///bar.json: JsonModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, } file:///mod.ts: EsmModuleSymbol { @@ -50,7 +54,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "configFile": 1, }, @@ -63,6 +67,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -85,10 +92,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -111,8 +122,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -125,6 +137,9 @@ file:///non_public.json: JsonModuleSymbol { "default": 0, }, default_symbol: Symbol { + module_id: ModuleId( + 2, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -144,8 +159,9 @@ file:///non_public.json: JsonModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, } == export definitions == diff --git a/tests/specs/symbols/ReexportExport.txt b/tests/specs/symbols/ReexportExport.txt index 511dae622..2a78bdc59 100644 --- a/tests/specs/symbols/ReexportExport.txt +++ b/tests/specs/symbols/ReexportExport.txt @@ -8,7 +8,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -24,6 +24,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -54,8 +57,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TsExternalModuleRef01.txt b/tests/specs/symbols/TsExternalModuleRef01.txt index 984ffea88..4ad1cbe01 100644 --- a/tests/specs/symbols/TsExternalModuleRef01.txt +++ b/tests/specs/symbols/TsExternalModuleRef01.txt @@ -16,7 +16,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -35,6 +35,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -77,14 +80,18 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, }, exports: { "B": 1, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -104,10 +111,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -135,8 +146,9 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -145,7 +157,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 1, }, exports: { @@ -164,6 +176,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -186,10 +201,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -209,12 +228,6 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "Test", - #2, - ), - ), QualifiedId( ( "A", @@ -225,8 +238,9 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TsExternalModuleRef02.txt b/tests/specs/symbols/TsExternalModuleRef02.txt index 6ef9f272f..7018b1b92 100644 --- a/tests/specs/symbols/TsExternalModuleRef02.txt +++ b/tests/specs/symbols/TsExternalModuleRef02.txt @@ -16,7 +16,7 @@ file:///a.ts: EsmModuleSymbol { 1, ), specifier: "file:///a.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -35,6 +35,9 @@ file:///a.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -77,14 +80,18 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 1, }, exports: { "B": 1, }, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -104,10 +111,14 @@ file:///a.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -135,8 +146,9 @@ file:///a.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -145,7 +157,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: {}, + child_ids: {}, exports: { "default": 1, }, @@ -158,6 +170,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -196,10 +211,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -227,8 +246,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TsNamespaceExport01.txt b/tests/specs/symbols/TsNamespaceExport01.txt index 214de7c99..92d9fe4ed 100644 --- a/tests/specs/symbols/TsNamespaceExport01.txt +++ b/tests/specs/symbols/TsNamespaceExport01.txt @@ -13,7 +13,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -28,6 +28,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -47,8 +50,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TsQualifiedName01.txt b/tests/specs/symbols/TsQualifiedName01.txt index bc2b687d0..0d7a4a15f 100644 --- a/tests/specs/symbols/TsQualifiedName01.txt +++ b/tests/specs/symbols/TsQualifiedName01.txt @@ -13,7 +13,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -41,6 +41,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -60,12 +63,6 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: { - Id( - ( - "Test", - #2, - ), - ), QualifiedId( ( "Other", @@ -76,10 +73,14 @@ file:///mod.ts: EsmModuleSymbol { ], ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -112,7 +113,7 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: { + child_ids: { 2, 4, }, @@ -120,8 +121,12 @@ file:///mod.ts: EsmModuleSymbol { "Test": 3, "other": 5, }, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -144,10 +149,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -167,10 +176,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 4: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 4, decls: [ SymbolDecl { @@ -193,10 +206,14 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 5: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 5, decls: [ SymbolDecl { @@ -216,8 +233,9 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TypeAlias01.txt b/tests/specs/symbols/TypeAlias01.txt new file mode 100644 index 000000000..d5fb6b5ec --- /dev/null +++ b/tests/specs/symbols/TypeAlias01.txt @@ -0,0 +1,135 @@ +# mod.ts +export type Test = Other2; + +interface Other {} +interface Other2 {} + +# output +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_ids: { + 0, + 1, + 2, + }, + exports: { + "Test": 0, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "Test", + #2, + ): 0, + ( + "Other", + #2, + ): 1, + ( + "Other2", + #2, + ): 2, + }, + symbols: { + 0: Symbol { + module_id: ModuleId( + 0, + ), + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 0, + ), + end: SourcePos( + 43, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: { + Id( + ( + "Other", + #2, + ), + ), + Id( + ( + "Other2", + #2, + ), + ), + }, + child_ids: {}, + exports: {}, + members: {}, + }, + 1: Symbol { + module_id: ModuleId( + 0, + ), + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 45, + ), + end: SourcePos( + 63, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_ids: {}, + exports: {}, + members: {}, + }, + 2: Symbol { + module_id: ModuleId( + 0, + ), + symbol_id: 2, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 64, + ), + end: SourcePos( + 83, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_ids: {}, + exports: {}, + members: {}, + }, + }, +} +== export definitions == +[Test]: file:///mod.ts:0..43 + export type Test = Other2; diff --git a/tests/specs/symbols/TypeScriptTypesHeader.txt b/tests/specs/symbols/TypeScriptTypesHeader.txt index 55b9f8ed6..1ac2e8d64 100644 --- a/tests/specs/symbols/TypeScriptTypesHeader.txt +++ b/tests/specs/symbols/TypeScriptTypesHeader.txt @@ -38,7 +38,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.ts", - child_decls: { + child_ids: { 3, }, exports: { @@ -65,6 +65,9 @@ file:///mod.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -87,10 +90,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 1: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -113,10 +120,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 2: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 2, decls: [ SymbolDecl { @@ -139,10 +150,14 @@ file:///mod.ts: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, 3: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 3, decls: [ SymbolDecl { @@ -181,8 +196,9 @@ file:///mod.ts: EsmModuleSymbol { ), ), }, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } @@ -191,7 +207,7 @@ file:///other.d.ts: EsmModuleSymbol { 1, ), specifier: "file:///other.d.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -206,6 +222,9 @@ file:///other.d.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -224,22 +243,18 @@ file:///other.d.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyInterface2", - #2, - ), - ), - Id( - ( - "b", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, }, } @@ -248,7 +263,7 @@ file:///other.js: EsmModuleSymbol { 2, ), specifier: "file:///other.js", - child_decls: {}, + child_ids: {}, exports: {}, re_exports: [], swc_id_to_symbol_id: {}, @@ -259,7 +274,7 @@ file:///typescript.ts: EsmModuleSymbol { 3, ), specifier: "file:///typescript.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -274,6 +289,9 @@ file:///typescript.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 3, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -292,22 +310,18 @@ file:///typescript.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyInterface3", - #2, - ), - ), - Id( - ( - "c", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, }, } @@ -316,7 +330,7 @@ https://localhost/mod.d.ts: EsmModuleSymbol { 4, ), specifier: "https://localhost/mod.d.ts", - child_decls: { + child_ids: { 0, 1, }, @@ -337,6 +351,9 @@ https://localhost/mod.d.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 4, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -355,24 +372,23 @@ https://localhost/mod.d.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyInterface", - #2, - ), - ), - Id( - ( - "a", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, 1: Symbol { + module_id: ModuleId( + 4, + ), symbol_id: 1, decls: [ SymbolDecl { @@ -391,22 +407,18 @@ https://localhost/mod.d.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyNonPublicInterface", - #2, - ), - ), - Id( - ( - "a1", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 1: SymbolMember { + symbol_member_id: 1, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, }, } @@ -415,7 +427,7 @@ https://localhost/mod.js: EsmModuleSymbol { 5, ), specifier: "https://localhost/mod.js", - child_decls: { + child_ids: { 0, }, exports: { @@ -430,6 +442,9 @@ https://localhost/mod.js: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 5, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -449,8 +464,9 @@ https://localhost/mod.js: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, } diff --git a/tests/specs/symbols/TypesEntrypoint.txt b/tests/specs/symbols/TypesEntrypoint.txt index a5ffe897e..9a5a486ba 100644 --- a/tests/specs/symbols/TypesEntrypoint.txt +++ b/tests/specs/symbols/TypesEntrypoint.txt @@ -13,7 +13,7 @@ file:///mod.d.ts: EsmModuleSymbol { 0, ), specifier: "file:///mod.d.ts", - child_decls: { + child_ids: { 0, }, exports: { @@ -28,6 +28,9 @@ file:///mod.d.ts: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 0, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -46,22 +49,18 @@ file:///mod.d.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyInterface", - #2, - ), - ), - Id( - ( - "a", - #0, + deps: {}, + child_ids: {}, + exports: {}, + members: { + 0: SymbolMember { + symbol_member_id: 0, + decl: SymbolMemberDecl( + "", ), - ), + deps: {}, + }, }, - child_decls: {}, - exports: {}, }, }, } @@ -70,7 +69,7 @@ file:///mod.js: EsmModuleSymbol { 1, ), specifier: "file:///mod.js", - child_decls: { + child_ids: { 0, }, exports: { @@ -85,6 +84,9 @@ file:///mod.js: EsmModuleSymbol { }, symbols: { 0: Symbol { + module_id: ModuleId( + 1, + ), symbol_id: 0, decls: [ SymbolDecl { @@ -104,8 +106,9 @@ file:///mod.js: EsmModuleSymbol { }, ], deps: {}, - child_decls: {}, + child_ids: {}, exports: {}, + members: {}, }, }, }