From 16d3341092bcafc6f3622468114487a17556dbab Mon Sep 17 00:00:00 2001 From: Yacine Hmito <6893840+yacinehmito@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:06:38 +0100 Subject: [PATCH 1/3] refactor: rename types.d.ts to type.ts (#319) --- js/loader.ts | 2 +- js/mod.ts | 4 ++-- js/test.ts | 2 +- js/{types.d.ts => types.ts} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename js/{types.d.ts => types.ts} (100%) diff --git a/js/loader.ts b/js/loader.ts index 261791f70..b230ed86f 100644 --- a/js/loader.ts +++ b/js/loader.ts @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import type { LoadResponse } from "./types.d.ts"; +import type { LoadResponse } from "./types.ts"; const hasPermissions = "permissions" in Deno; let readRequested = false; diff --git a/js/mod.ts b/js/mod.ts index f1c4c9abb..4378157a6 100644 --- a/js/mod.ts +++ b/js/mod.ts @@ -26,7 +26,7 @@ import type { ModuleGraphJson, ModuleJson, TypesDependency, -} from "./types.d.ts"; +} from "./types.ts"; export { load } from "./loader.ts"; export { MediaType } from "./media_type.ts"; @@ -38,7 +38,7 @@ export type { ModuleJson, ModuleKind, TypesDependency, -} from "./types.d.ts"; +} from "./types.ts"; // note: keep this in line with deno_cache export type CacheSetting = "only" | "use" | "reload"; diff --git a/js/test.ts b/js/test.ts index a3f53e20c..572bed519 100644 --- a/js/test.ts +++ b/js/test.ts @@ -6,7 +6,7 @@ import { assertRejects, assertThrows, } from "https://deno.land/std@0.181.0/testing/asserts.ts"; -import { LoadResponseModule } from "./types.d.ts"; +import { LoadResponseModule } from "./types.ts"; import { createGraph, init, diff --git a/js/types.d.ts b/js/types.ts similarity index 100% rename from js/types.d.ts rename to js/types.ts From 1525108e4b21c2617e839306d9ef6f15db18b9a6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 5 Nov 2023 16:31:01 -0500 Subject: [PATCH 2/3] feat: ability to easily get types module from graph (#321) --- src/graph.rs | 22 ++++++++++++++++++++++ src/lib.rs | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/graph.rs b/src/graph.rs index 104eed6ab..dfed80955 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1559,6 +1559,28 @@ impl ModuleGraph { } } + /// Similar to `try_get`, but will prefer resolving to the types dependency if + /// the module has one. + pub fn try_get_prefer_types( + &self, + specifier: &ModuleSpecifier, + ) -> Result, &ModuleError> { + let Some(module) = self.try_get(specifier)? else { + return Ok(None); + }; + + if let Some(specifier) = module.esm().and_then(|m| { + m.maybe_types_dependency + .as_ref() + .and_then(|d| d.dependency.ok()) + .map(|r| &r.specifier) + }) { + self.try_get(specifier) + } else { + Ok(Some(module)) + } + } + /// Walk the graph from the root, checking to see if there are any module /// graph errors on non-type only, non-dynamic imports. The first error is /// returned as as error result, otherwise ok if there are no errors. diff --git a/src/lib.rs b/src/lib.rs index 4627ac6df..e20cd5f82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -921,6 +921,29 @@ console.log(a); ModuleSpecifier::parse("https://example.com/jsx-runtime.d.ts").unwrap() ) ); + assert_eq!( + graph + .try_get( + &ModuleSpecifier::parse("https://example.com/jsx-runtime").unwrap() + ) + .unwrap() + .unwrap() + .specifier() + .as_str(), + "https://example.com/jsx-runtime" + ); + assert_eq!( + graph + .try_get_prefer_types( + &ModuleSpecifier::parse("https://example.com/jsx-runtime").unwrap() + ) + .unwrap() + .unwrap() + .specifier() + .as_str(), + // should end up at the declaration file + "https://example.com/jsx-runtime.d.ts" + ); } #[tokio::test] From 099c0a35d1b9a0329e3c5c813436ec81a52bb49b Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 6 Nov 2023 09:25:08 -0500 Subject: [PATCH 3/3] refactor: generic symbol graph (#317) --- Cargo.toml | 2 +- src/lib.rs | 4 +- src/{type_tracer => symbols}/analyzer.rs | 452 +++++--------- src/{type_tracer => symbols}/collections.rs | 59 +- src/{type_tracer => symbols}/cross_module.rs | 0 src/symbols/mod.rs | 25 + src/type_tracer/mod.rs | 420 ------------- tests/helpers/test_builder.rs | 79 +-- tests/integration_test.rs | 8 +- .../specs/{type_tracing => symbols}/Basic.txt | 369 +++++------ .../{type_tracing => symbols}/Classes01.txt | 17 - .../DeclarationMerging01.txt | 8 - .../ExportAssignment01.txt | 4 - .../ExportDefault01.txt | 588 ++++++++---------- .../ExportDefault02.txt | 4 - .../ExportDefault03.txt | 153 ++--- .../ExportDefault04.txt | 2 - .../ExportDefaultLiteral01.txt | 3 - .../ExportDefaultLiteral02.txt | 3 - .../ExportDestructured.txt | 7 - .../ExportStar01.txt | 123 ++-- .../ExportedDeclare01.txt | 8 - .../ExportedDeclare02.txt | 4 - .../FunctionOverloads01.txt | 6 - .../{type_tracing => symbols}/Functions01.txt | 14 - .../ImportEquals01.txt | 5 - .../ImportEquals02.txt | 354 +++++------ .../ImportType01.txt | 129 ++-- .../ImportType02.txt | 99 ++- .../Interfaces01.txt | 10 - .../Interfaces02.txt | 174 +++--- .../ModuleExportNameStr01.txt | 114 ++-- .../Namespaces01.txt | 8 - .../Namespaces02.txt | 6 - .../ReExportJson01.txt | 45 +- .../ReexportExport.txt | 3 - .../TsExternalModuleRef01.txt | 189 +++--- .../TsExternalModuleRef02.txt | 183 +++--- .../TsNamespaceExport01.txt | 3 - .../TsQualifiedName01.txt | 8 - .../TypeScriptTypesHeader.txt | 187 +++--- .../TypesEntrypoint.txt | 47 +- 42 files changed, 1520 insertions(+), 2406 deletions(-) rename src/{type_tracer => symbols}/analyzer.rs (92%) rename src/{type_tracer => symbols}/collections.rs (61%) rename src/{type_tracer => symbols}/cross_module.rs (100%) create mode 100644 src/symbols/mod.rs delete mode 100644 src/type_tracer/mod.rs rename tests/specs/{type_tracing => symbols}/Basic.txt (95%) rename tests/specs/{type_tracing => symbols}/Classes01.txt (96%) rename tests/specs/{type_tracing => symbols}/DeclarationMerging01.txt (97%) rename tests/specs/{type_tracing => symbols}/ExportAssignment01.txt (95%) rename tests/specs/{type_tracing => symbols}/ExportDefault01.txt (93%) rename tests/specs/{type_tracing => symbols}/ExportDefault02.txt (95%) rename tests/specs/{type_tracing => symbols}/ExportDefault03.txt (90%) rename tests/specs/{type_tracing => symbols}/ExportDefault04.txt (89%) rename tests/specs/{type_tracing => symbols}/ExportDefaultLiteral01.txt (92%) rename tests/specs/{type_tracing => symbols}/ExportDefaultLiteral02.txt (92%) rename tests/specs/{type_tracing => symbols}/ExportDestructured.txt (96%) rename tests/specs/{type_tracing => symbols}/ExportStar01.txt (91%) rename tests/specs/{type_tracing => symbols}/ExportedDeclare01.txt (97%) rename tests/specs/{type_tracing => symbols}/ExportedDeclare02.txt (94%) rename tests/specs/{type_tracing => symbols}/FunctionOverloads01.txt (97%) rename tests/specs/{type_tracing => symbols}/Functions01.txt (96%) rename tests/specs/{type_tracing => symbols}/ImportEquals01.txt (95%) rename tests/specs/{type_tracing => symbols}/ImportEquals02.txt (96%) rename tests/specs/{type_tracing => symbols}/ImportType01.txt (95%) rename tests/specs/{type_tracing => symbols}/ImportType02.txt (93%) rename tests/specs/{type_tracing => symbols}/Interfaces01.txt (97%) rename tests/specs/{type_tracing => symbols}/Interfaces02.txt (95%) rename tests/specs/{type_tracing => symbols}/ModuleExportNameStr01.txt (87%) rename tests/specs/{type_tracing => symbols}/Namespaces01.txt (97%) rename tests/specs/{type_tracing => symbols}/Namespaces02.txt (95%) rename tests/specs/{type_tracing => symbols}/ReExportJson01.txt (79%) rename tests/specs/{type_tracing => symbols}/ReexportExport.txt (94%) rename tests/specs/{type_tracing => symbols}/TsExternalModuleRef01.txt (95%) rename tests/specs/{type_tracing => symbols}/TsExternalModuleRef02.txt (94%) rename tests/specs/{type_tracing => symbols}/TsNamespaceExport01.txt (94%) rename tests/specs/{type_tracing => symbols}/TsQualifiedName01.txt (95%) rename tests/specs/{type_tracing => symbols}/TypeScriptTypesHeader.txt (89%) rename tests/specs/{type_tracing => symbols}/TypesEntrypoint.txt (60%) diff --git a/Cargo.toml b/Cargo.toml index f4b048440..0d4308fb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ name = "deno_graph" all-features = true [features] -type_tracing = ["deno_ast/transforms", "deno_ast/visit", "deno_ast/utils"] +symbols = ["deno_ast/transforms", "deno_ast/visit", "deno_ast/utils"] [dependencies] anyhow = "1.0.43" diff --git a/src/lib.rs b/src/lib.rs index e20cd5f82..a1d9bbdeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,8 +5,8 @@ mod ast; mod graph; mod module_specifier; -#[cfg(feature = "type_tracing")] -pub mod type_tracer; +#[cfg(feature = "symbols")] +pub mod symbols; pub mod packages; pub mod source; diff --git a/src/type_tracer/analyzer.rs b/src/symbols/analyzer.rs similarity index 92% rename from src/type_tracer/analyzer.rs rename to src/symbols/analyzer.rs index e3e4d11a4..b87e01f06 100644 --- a/src/type_tracer/analyzer.rs +++ b/src/symbols/analyzer.rs @@ -2,8 +2,6 @@ use std::borrow::Cow; use std::cell::RefCell; -use std::collections::HashMap; -use std::collections::HashSet; use std::hash::Hash; use std::hash::Hasher; @@ -12,6 +10,7 @@ use deno_ast::swc::ast::*; use deno_ast::swc::common::comments::CommentKind; use deno_ast::swc::utils::find_pat_ids; use deno_ast::swc::visit::*; +use deno_ast::LineAndColumnDisplay; use deno_ast::ModuleSpecifier; use deno_ast::ParsedSource; use deno_ast::SourcePos; @@ -20,6 +19,8 @@ use deno_ast::SourceRangedForSpanned; use deno_ast::SourceTextInfo; use indexmap::IndexMap; use indexmap::IndexSet; +use serde::Deserialize; +use serde::Serialize; use crate::CapturingModuleParser; use crate::EsmModule; @@ -28,28 +29,54 @@ use crate::ModuleGraph; use crate::ModuleParser; use super::collections::AdditiveOnlyMap; -use super::collections::LockableRefCell; use super::cross_module; use super::cross_module::Definition; -use super::ImportedExports; use super::ResolvedSymbolDepEntry; -use super::TypeTraceDiagnostic; -use super::TypeTraceDiagnosticKind; -use super::TypeTraceHandler; -#[derive(Clone)] -pub struct RootSymbol { - specifiers_to_ids: HashMap, - ids_to_symbols: HashMap, +pub struct RootSymbol<'a> { + module_graph: &'a ModuleGraph, + parser: &'a CapturingModuleParser<'a>, + specifiers_to_ids: AdditiveOnlyMap, + ids_to_symbols: AdditiveOnlyMap, + diagnostics: RefCell>, } -impl RootSymbol { +impl<'a> RootSymbol<'a> { + pub fn new( + module_graph: &'a ModuleGraph, + parser: &'a CapturingModuleParser<'a>, + ) -> Self { + Self { + module_graph, + parser, + specifiers_to_ids: Default::default(), + ids_to_symbols: Default::default(), + diagnostics: Default::default(), + } + } + pub fn get_module_from_specifier( &self, specifier: &ModuleSpecifier, ) -> Option { - let id = self.specifiers_to_ids.get(specifier)?; - self.ids_to_symbols.get(id).map(|m| m.as_ref()) + if let Some(module_id) = self.specifiers_to_ids.get(specifier) { + let module_symbol = self.ids_to_symbols.get(module_id).unwrap(); + return Some(module_symbol.as_ref()); + } + + let Some(graph_module) = self.module_graph.get(specifier) else { + return None; + }; + + match graph_module { + crate::Module::Esm(esm_module) => self.analyze_esm_module(esm_module), + crate::Module::Json(json_module) => { + Some(self.analyze_json_module(json_module)) + } + crate::Module::Npm(_) + | crate::Module::Node(_) + | crate::Module::External(_) => None, + } } pub fn get_module_from_id( @@ -59,56 +86,129 @@ impl RootSymbol { self.ids_to_symbols.get(&module_id).map(|s| s.as_ref()) } - pub fn into_specifier_map(self) -> IndexMap { - use std::collections::BTreeMap; - - let ids_to_symbols = - self.ids_to_symbols.into_iter().collect::>(); - let mut result = IndexMap::default(); - for (id, symbol) in ids_to_symbols { - // todo(dsherret): improve - result.insert( - self - .specifiers_to_ids - .iter() - .find(|(_, v)| **v == id) - .unwrap() - .0 - .clone(), - symbol, - ); - } - - result - } - - pub fn go_to_definitions<'a>( - &'a self, - module_graph: &ModuleGraph, - module: ModuleSymbolRef<'a>, - symbol: &'a Symbol, - ) -> Vec> { + pub fn go_to_definitions<'b>( + &'b self, + module: ModuleSymbolRef<'b>, + symbol: &'b Symbol, + ) -> Vec> { super::cross_module::go_to_definitions( - module_graph, + self.module_graph, module, symbol, &|specifier| self.get_module_from_specifier(specifier), ) } - pub fn resolve_symbol_dep<'a>( - &'a self, - module_graph: &ModuleGraph, - module: ModuleSymbolRef<'a>, - dep: &'a SymbolDep, - ) -> Vec> { + pub fn resolve_symbol_dep<'b>( + &'b self, + module: ModuleSymbolRef<'b>, + dep: &'b SymbolDep, + ) -> Vec> { super::cross_module::resolve_symbol_dep( - module_graph, + self.module_graph, module, dep, &|specifier| self.get_module_from_specifier(specifier), ) } + + fn analyze_esm_module( + &self, + esm_module: &EsmModule, + ) -> Option { + let Ok(source) = self.parsed_source(esm_module) else { + return None; + }; + let specifier = &esm_module.specifier; + let module = source.module(); + let mut module_symbol = EsmModuleSymbol { + specifier: specifier.clone(), + module_id: ModuleId(self.ids_to_symbols.len() as u32), + source: source.clone(), + next_symbol_id: Default::default(), + child_decls: Default::default(), + exports: Default::default(), + re_exports: Default::default(), + swc_id_to_symbol_id: Default::default(), + symbols: Default::default(), + }; + + let mut filler = SymbolFiller { + source: &source, + specifier, + diagnostics: Vec::new(), + }; + filler.fill_module(&mut module_symbol, module); + if !filler.diagnostics.is_empty() { + self.diagnostics.borrow_mut().extend(filler.diagnostics); + } + Some(self.finalize_insert(ModuleSymbol::Esm(module_symbol))) + } + + fn analyze_json_module(&self, json_module: &JsonModule) -> ModuleSymbolRef { + let specifier = &json_module.specifier; + // it's not ideal having to use SourceTextInfo here, but it makes + // it easier to interop with ParsedSource + let source_text_info = SourceTextInfo::new(json_module.source.clone()); + let range = source_text_info.range(); + let module_symbol = JsonModuleSymbol { + specifier: specifier.clone(), + module_id: ModuleId(self.ids_to_symbols.len() as u32), + exports: IndexMap::from([("default".to_string(), SymbolId(0))]), + default_symbol: Symbol { + symbol_id: SymbolId(0), + decls: { + let range = { + let source = source_text_info.text_str(); + let start_whitespace_len = source.len() - source.trim_start().len(); + let end_whitespace_len = source.len() - source.trim_end().len(); + SourceRange::new( + range.start + start_whitespace_len, + range.end - end_whitespace_len, + ) + }; + IndexMap::from([( + range, + SymbolDecl { + range, + kind: SymbolDeclKind::Definition(SymbolNode( + SymbolNodeInner::Json, + )), + }, + )]) + }, + deps: Default::default(), + child_decls: Default::default(), + exports: Default::default(), + }, + source_text_info, + }; + self.finalize_insert(ModuleSymbol::Json(Box::new(module_symbol))) + } + + fn finalize_insert(&self, module_symbol: ModuleSymbol) -> ModuleSymbolRef { + self + .specifiers_to_ids + .insert(module_symbol.specifier().clone(), module_symbol.module_id()); + let module_id = module_symbol.module_id(); + self.ids_to_symbols.insert(module_id, module_symbol); + self.ids_to_symbols.get(&module_id).unwrap().as_ref() + } + + fn parsed_source( + &self, + graph_module: &EsmModule, + ) -> Result { + self.parser.parse_module( + &graph_module.specifier, + graph_module.source.clone(), + graph_module.media_type, + ) + } + + pub fn take_diagnostics(&self) -> Vec { + std::mem::take(&mut *self.diagnostics.borrow_mut()) + } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -369,7 +469,6 @@ impl From for SymbolDep { #[derive(Clone)] pub struct Symbol { symbol_id: SymbolId, - is_public: RefCell, // todo(dsherret): the IndexMap is just to prevent duplicates // a better solution should be thought out decls: IndexMap, @@ -383,7 +482,6 @@ impl std::fmt::Debug for Symbol { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Symbol") .field("symbol_id", &self.symbol_id) - .field("is_public", &*self.is_public.borrow()) .field("decls", &self.decls.values().collect::>()) .field("deps", &self.deps) .field("child_decls", &self.child_decls) @@ -396,7 +494,6 @@ impl Symbol { pub fn new(symbol_id: SymbolId) -> Self { Symbol { symbol_id, - is_public: Default::default(), decls: Default::default(), deps: Default::default(), child_decls: Default::default(), @@ -408,19 +505,6 @@ impl Symbol { self.symbol_id } - pub fn is_public(&self) -> bool { - *self.is_public.borrow() - } - - pub(crate) fn mark_public(&self) -> bool { - if self.is_public() { - false - } else { - *self.is_public.borrow_mut() = true; - true - } - } - pub fn export(&self, name: &str) -> Option { self.exports.get(name).copied() } @@ -662,8 +746,6 @@ pub struct EsmModuleSymbol { // note: not all symbol ids have an swc id. For example, default exports swc_id_to_symbol_id: IndexMap, symbols: IndexMap, - traced_re_exports: LockableRefCell>, - traced_referrers: LockableRefCell>, } impl std::fmt::Debug for EsmModuleSymbol { @@ -676,8 +758,6 @@ impl std::fmt::Debug for EsmModuleSymbol { .field("re_exports", &self.re_exports) .field("swc_id_to_symbol_id", &self.swc_id_to_symbol_id) .field("symbols", &self.symbols) - .field("traced_re_exports", &self.traced_re_exports.borrow()) - .field("traced_referrers", &self.traced_referrers.borrow()) .finish() } } @@ -699,55 +779,6 @@ impl EsmModuleSymbol { &self.source } - pub fn public_source_ranges(&self) -> HashSet { - self - .symbols - .values() - .filter(|symbol| symbol.is_public()) - .flat_map(|symbol| { - symbol - .decls() - .filter(|d| { - !matches!(d.kind, SymbolDeclKind::DefinitionPrivateFnImpl(_)) - }) - .map(|d| d.range) - }) - .collect() - } - - /// Re-exports from this module that were found during tracing. - pub fn traced_re_exports(&self) -> &IndexMap { - self.traced_re_exports.lock_and_get_ref() - } - - pub(crate) fn add_traced_re_export( - &self, - name: String, - symbol: UniqueSymbolId, - ) { - self.traced_re_exports.borrow_mut().insert(name, symbol); - } - - /// Referrers and their imported exports. This only includes referrers that - /// were found during tracing and not all referrers. - pub fn traced_referrers(&self) -> &IndexMap { - self.traced_referrers.lock_and_get_ref() - } - - pub(crate) fn add_traced_referrer( - &self, - module_id: ModuleId, - imported_exports: ImportedExports, - ) { - let mut traced_referrers = self.traced_referrers.borrow_mut(); - if let Some(current_imported_exports) = traced_referrers.get_mut(&module_id) - { - current_imported_exports.add(imported_exports); - } else { - traced_referrers.insert(module_id, imported_exports); - } - } - pub fn exports<'a>( &'a self, module_graph: &ModuleGraph, @@ -845,169 +876,30 @@ impl EsmModuleSymbol { } } -pub struct TypeTraceModuleAnalyzer<'a, THandler: TypeTraceHandler> { - graph: &'a ModuleGraph, - parser: &'a CapturingModuleParser<'a>, - handler: &'a THandler, - modules: AdditiveOnlyMap, +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub enum SymbolFillDiagnosticKind { + UnsupportedDefaultExpr, } -impl<'a, THandler: TypeTraceHandler> TypeTraceModuleAnalyzer<'a, THandler> { - pub fn new( - graph: &'a ModuleGraph, - parser: &'a CapturingModuleParser<'a>, - handler: &'a THandler, - ) -> Self { - Self { - handler, - parser, - graph, - modules: AdditiveOnlyMap::new(), - } - } - - pub fn into_roots_graph_symbol(self) -> RootSymbol { - let modules = self.modules.take(); - let mut specifiers_to_ids = HashMap::with_capacity(modules.len()); - let mut ids_to_symbols = HashMap::with_capacity(modules.len()); - for (specifier, symbol) in modules { - specifiers_to_ids.insert(specifier, symbol.module_id()); - ids_to_symbols.insert(symbol.module_id(), *symbol); - } - RootSymbol { - specifiers_to_ids, - ids_to_symbols, - } - } - - pub fn get_or_analyze<'b>( - &'b self, - specifier: &ModuleSpecifier, - ) -> Result>> { - if let Some(module_symbol) = self.modules.get(specifier) { - return Ok(Some(module_symbol.as_ref())); - } - - let Some(graph_module) = self.graph.get(specifier) else { - return Ok(None); - }; - - match graph_module { - crate::Module::Esm(esm_module) => self.analyze_esm_module(esm_module), - crate::Module::Json(json_module) => self.analyze_json_module(json_module), - crate::Module::Npm(_) - | crate::Module::Node(_) - | crate::Module::External(_) => Ok(None), - } - } - - fn analyze_esm_module( - &self, - esm_module: &EsmModule, - ) -> Result, anyhow::Error> { - let Some(source) = self.parsed_source(esm_module)? else { - return Ok(None); - }; - let specifier = &esm_module.specifier; - let module = source.module(); - let mut module_symbol = EsmModuleSymbol { - specifier: specifier.clone(), - module_id: ModuleId(self.modules.len() as u32), - source: source.clone(), - next_symbol_id: Default::default(), - child_decls: Default::default(), - exports: Default::default(), - re_exports: Default::default(), - traced_re_exports: Default::default(), - traced_referrers: Default::default(), - swc_id_to_symbol_id: Default::default(), - symbols: Default::default(), - }; - - let filler = SymbolFiller { - source: &source, - specifier, - handler: self.handler, - }; - filler.fill_module(&mut module_symbol, module); - self - .modules - .insert(specifier.clone(), ModuleSymbol::Esm(module_symbol)); - Ok(Some(self.modules.get(specifier).unwrap().as_ref())) - } - - fn analyze_json_module( - &self, - json_module: &JsonModule, - ) -> Result, anyhow::Error> { - let specifier = &json_module.specifier; - // it's not ideal having to use SourceTextInfo here, but it makes - // it easier to interop with ParsedSource - let source_text_info = SourceTextInfo::new(json_module.source.clone()); - let range = source_text_info.range(); - let module_symbol = JsonModuleSymbol { - specifier: specifier.clone(), - module_id: ModuleId(self.modules.len() as u32), - exports: IndexMap::from([("default".to_string(), SymbolId(0))]), - default_symbol: Symbol { - symbol_id: SymbolId(0), - is_public: RefCell::new(false), - decls: { - let range = { - let source = source_text_info.text_str(); - let start_whitespace_len = source.len() - source.trim_start().len(); - let end_whitespace_len = source.len() - source.trim_end().len(); - SourceRange::new( - range.start + start_whitespace_len, - range.end - end_whitespace_len, - ) - }; - IndexMap::from([( - range, - SymbolDecl { - range, - kind: SymbolDeclKind::Definition(SymbolNode( - SymbolNodeInner::Json, - )), - }, - )]) - }, - deps: Default::default(), - child_decls: Default::default(), - exports: Default::default(), - }, - source_text_info, - }; - self.modules.insert( - specifier.clone(), - ModuleSymbol::Json(Box::new(module_symbol)), - ); - Ok(Some(self.modules.get(specifier).unwrap().as_ref())) - } - - fn parsed_source( - &self, - graph_module: &EsmModule, - ) -> Result, deno_ast::Diagnostic> { - self - .parser - .parse_module( - &graph_module.specifier, - graph_module.source.clone(), - graph_module.media_type, - ) - .map(Some) - } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct SymbolFillDiagnostic { + pub kind: SymbolFillDiagnosticKind, + pub specifier: ModuleSpecifier, + pub line_and_column: Option, } -struct SymbolFiller<'a, THandler: TypeTraceHandler> { - handler: &'a THandler, +struct SymbolFiller<'a> { specifier: &'a ModuleSpecifier, source: &'a ParsedSource, + diagnostics: Vec, } -impl<'a, THandler: TypeTraceHandler> SymbolFiller<'a, THandler> { - fn fill_module(&self, file_module: &mut EsmModuleSymbol, module: &Module) { +impl<'a> SymbolFiller<'a> { + fn fill_module( + &mut self, + file_module: &mut EsmModuleSymbol, + module: &Module, + ) { let mut last_was_overload = false; let mut last_override_key = 0; for module_item in &module.body { @@ -1039,7 +931,7 @@ impl<'a, THandler: TypeTraceHandler> SymbolFiller<'a, THandler> { } fn fill_module_item( - &self, + &mut self, file_module: &mut EsmModuleSymbol, module_item: &ModuleItem, add_export: &impl Fn(&mut EsmModuleSymbol, String, SymbolId), @@ -1650,7 +1542,7 @@ impl<'a, THandler: TypeTraceHandler> SymbolFiller<'a, THandler> { } fn handle_export_default_expr( - &self, + &mut self, default_export_range: SourceRange, expr: &Expr, maybe_parent: Option<&ExportDefaultExpr>, @@ -1696,8 +1588,8 @@ impl<'a, THandler: TypeTraceHandler> SymbolFiller<'a, THandler> { .source .text_info() .line_and_column_display(default_export_range.start); - self.handler.diagnostic(TypeTraceDiagnostic { - kind: TypeTraceDiagnosticKind::UnsupportedDefaultExpr, + self.diagnostics.push(SymbolFillDiagnostic { + kind: SymbolFillDiagnosticKind::UnsupportedDefaultExpr, specifier: self.specifier.clone(), line_and_column: Some(line_and_column), }); @@ -1798,7 +1690,7 @@ impl<'a, THandler: TypeTraceHandler> SymbolFiller<'a, THandler> { } fn fill_ts_module( - &self, + &mut self, file_module: &mut EsmModuleSymbol, symbol_decl: SymbolDecl, n: &TsModuleDecl, diff --git a/src/type_tracer/collections.rs b/src/symbols/collections.rs similarity index 61% rename from src/type_tracer/collections.rs rename to src/symbols/collections.rs index 5c029f7d2..67c042c94 100644 --- a/src/type_tracer/collections.rs +++ b/src/symbols/collections.rs @@ -13,13 +13,15 @@ pub struct AdditiveOnlyMap { data: RefCell>>, } -impl AdditiveOnlyMap { - pub fn new() -> Self { +impl Default for AdditiveOnlyMap { + fn default() -> Self { Self { data: Default::default(), } } +} +impl AdditiveOnlyMap { #[cfg(test)] pub fn with_capacity(capacity: usize) -> Self { Self { @@ -30,10 +32,6 @@ impl AdditiveOnlyMap { pub fn len(&self) -> usize { self.data.borrow().len() } - - pub fn take(self) -> HashMap> { - self.data.into_inner() - } } impl AdditiveOnlyMap { @@ -58,55 +56,6 @@ impl AdditiveOnlyMap { } } -struct LockableCellInner { - locked: bool, - data: T, -} - -/// A refcell that can be "locked" to then be readonly. -pub struct LockableRefCell(RefCell>); - -impl LockableRefCell { - pub fn new(data: T) -> Self { - Self(RefCell::new(LockableCellInner { - locked: false, - data, - })) - } - - pub fn lock_and_get_ref(&self) -> &T { - self.0.borrow_mut().locked = true; - // SAFETY: This is made safe by the assertion that the - // cell cannot be borrowed mutably after it is locked. - unsafe { - let data = self.0.try_borrow_unguarded().unwrap(); - &data.data - } - } - - pub fn borrow(&self) -> std::cell::Ref { - std::cell::Ref::map(self.0.borrow(), |inner| &inner.data) - } - - pub fn borrow_mut(&self) -> std::cell::RefMut { - let inner = self.0.borrow_mut(); - assert!(!inner.locked, "Cannot mutate after the cell is locked."); - std::cell::RefMut::map(inner, |inner| &mut inner.data) - } -} - -impl Default for LockableRefCell { - fn default() -> Self { - Self::new(Default::default()) - } -} - -impl Clone for LockableRefCell { - fn clone(&self) -> Self { - Self::new(self.0.borrow().data.clone()) - } -} - #[cfg(test)] mod test { use super::*; diff --git a/src/type_tracer/cross_module.rs b/src/symbols/cross_module.rs similarity index 100% rename from src/type_tracer/cross_module.rs rename to src/symbols/cross_module.rs diff --git a/src/symbols/mod.rs b/src/symbols/mod.rs new file mode 100644 index 000000000..d40ed618c --- /dev/null +++ b/src/symbols/mod.rs @@ -0,0 +1,25 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +pub use self::analyzer::EsmModuleSymbol; +pub use self::analyzer::ExportDeclRef; +pub use self::analyzer::FileDep; +pub use self::analyzer::FileDepName; +pub use self::analyzer::JsonModuleSymbol; +pub use self::analyzer::ModuleId; +pub use self::analyzer::ModuleSymbol; +pub use self::analyzer::ModuleSymbolRef; +pub use self::analyzer::RootSymbol; +pub use self::analyzer::Symbol; +pub use self::analyzer::SymbolDecl; +pub use self::analyzer::SymbolFillDiagnostic; +pub use self::analyzer::SymbolFillDiagnosticKind; +pub use self::analyzer::SymbolId; +pub use self::analyzer::SymbolNodeRef; +pub use self::analyzer::UniqueSymbolId; +pub use self::cross_module::Definition; +pub use self::cross_module::DefinitionKind; +pub use self::cross_module::ResolvedSymbolDepEntry; + +mod analyzer; +mod collections; +mod cross_module; diff --git a/src/type_tracer/mod.rs b/src/type_tracer/mod.rs deleted file mode 100644 index c93ecf65f..000000000 --- a/src/type_tracer/mod.rs +++ /dev/null @@ -1,420 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -use std::collections::HashSet; - -use anyhow::Result; -use deno_ast::LineAndColumnDisplay; -use deno_ast::ModuleSpecifier; -use indexmap::IndexMap; -use indexmap::IndexSet; -use serde::Deserialize; -use serde::Serialize; - -use crate::type_tracer::cross_module::resolve_qualified_export_name; -use crate::CapturingModuleParser; -use crate::ModuleGraph; - -use self::analyzer::SymbolDep; -use self::analyzer::TypeTraceModuleAnalyzer; -use self::cross_module::resolve_qualified_name; - -pub use self::analyzer::EsmModuleSymbol; -pub use self::analyzer::ExportDeclRef; -pub use self::analyzer::FileDep; -pub use self::analyzer::FileDepName; -pub use self::analyzer::JsonModuleSymbol; -pub use self::analyzer::ModuleId; -pub use self::analyzer::ModuleSymbol; -pub use self::analyzer::ModuleSymbolRef; -pub use self::analyzer::RootSymbol; -pub use self::analyzer::Symbol; -pub use self::analyzer::SymbolDecl; -pub use self::analyzer::SymbolId; -pub use self::analyzer::SymbolNodeRef; -pub use self::analyzer::UniqueSymbolId; -pub use self::cross_module::Definition; -pub use self::cross_module::DefinitionKind; -pub use self::cross_module::ResolvedSymbolDepEntry; - -mod analyzer; -mod collections; -mod cross_module; - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] -pub enum TypeTraceDiagnosticKind { - UnsupportedDefaultExpr, -} - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] -pub struct TypeTraceDiagnostic { - pub kind: TypeTraceDiagnosticKind, - pub specifier: ModuleSpecifier, - pub line_and_column: Option, -} - -pub trait TypeTraceHandler { - fn diagnostic(&self, diagnostic: TypeTraceDiagnostic); -} - -/// Analyzes the public types and all the private dependent types of -/// the specified modules throughout the entire graph. -pub fn trace_public_types<'a, THandler: TypeTraceHandler>( - graph: &'a ModuleGraph, - roots: &[ModuleSpecifier], - parser: &'a CapturingModuleParser<'a>, - handler: &'a THandler, -) -> Result { - let mut context = Context { - graph, - analyzer: TypeTraceModuleAnalyzer::new(graph, parser, handler), - pending_traces: PendingTraces( - roots - .iter() - .map(|r| { - ( - graph.resolve_types_dependency(r).unwrap_or(r).clone(), - (ImportedExports::AllWithDefault, Default::default()), - ) - }) - .collect(), - ), - }; - while let Some(pending_trace) = context.pending_traces.pop() { - trace_module(pending_trace, &mut context)?; - } - - Ok(context.analyzer.into_roots_graph_symbol()) -} - -#[derive(Debug, Clone)] -pub enum ImportedExports { - AllWithDefault, - Star, - Named(IndexSet), -} - -impl ImportedExports { - pub(crate) fn from_file_dep_name(dep_name: &FileDepName) -> Self { - match dep_name { - FileDepName::Star => Self::Star, - FileDepName::Name(value) => Self::Named(IndexSet::from([value.clone()])), - } - } - - pub(crate) fn add(&mut self, exports_to_trace: ImportedExports) { - match exports_to_trace { - ImportedExports::AllWithDefault => { - *self = Self::AllWithDefault; - } - ImportedExports::Star => { - if !matches!(self, Self::Star | Self::AllWithDefault) { - *self = Self::Star; - } - } - ImportedExports::Named(new_names) => { - if let Self::Named(names) = self { - names.extend(new_names); - } - } - } - } -} - -type ReferrerTracesMap = IndexMap; - -#[derive(Default)] -struct PendingTraces( - IndexMap, -); - -impl PendingTraces { - pub fn add( - &mut self, - dep_specifier: ModuleSpecifier, - exports_to_trace: ImportedExports, - referrer_module_id: ModuleId, - ) { - if let Some((current_exports_to_trace, referrer_traces)) = - self.0.get_mut(&dep_specifier) - { - current_exports_to_trace.add(exports_to_trace.clone()); - if let Some(referrer_traces) = - referrer_traces.get_mut(&referrer_module_id) - { - referrer_traces.add(exports_to_trace); - } else { - referrer_traces.insert(referrer_module_id, exports_to_trace); - } - } else { - self.0.insert( - dep_specifier, - ( - exports_to_trace.clone(), - IndexMap::from([(referrer_module_id, exports_to_trace)]), - ), - ); - } - } - - pub fn pop(&mut self) -> Option { - self - .0 - .pop() - .map( - |(specifier, (exports_to_trace, referrer_traces))| PendingTrace { - specifier, - exports_to_trace, - referrer_traces, - }, - ) - } -} - -struct PendingTrace { - pub specifier: ModuleSpecifier, - pub exports_to_trace: ImportedExports, - pub referrer_traces: ReferrerTracesMap, -} - -struct Context<'a, TReporter: TypeTraceHandler> { - graph: &'a ModuleGraph, - analyzer: TypeTraceModuleAnalyzer<'a, TReporter>, - pending_traces: PendingTraces, -} - -impl<'a, TReporter: TypeTraceHandler> Context<'a, TReporter> { - pub fn trace_exports( - &mut self, - pending_trace: PendingTrace, - ) -> Result> { - let specifier = &pending_trace.specifier; - let exports = self.trace_exports_inner( - specifier, - &pending_trace.exports_to_trace, - HashSet::new(), - )?; - if let Some(module_symbol) = self - .analyzer - .get_or_analyze(specifier)? - .and_then(|m| m.esm()) - { - for (export_specifier, module_id, name, symbol_id) in &exports { - if specifier != export_specifier { - module_symbol.add_traced_re_export( - name.clone(), - UniqueSymbolId { - module_id: *module_id, - symbol_id: *symbol_id, - }, - ); - } - } - - // add the traced referrers - for (module_id, imported_exports) in pending_trace.referrer_traces { - module_symbol.add_traced_referrer(module_id, imported_exports); - } - } - Ok( - exports - .into_iter() - .map(|(specifier, _module_id, _name, symbol_id)| (specifier, symbol_id)) - .collect(), - ) - } - - fn trace_exports_inner( - &mut self, - specifier: &ModuleSpecifier, - exports_to_trace: &ImportedExports, - visited: HashSet, - ) -> Result> { - let mut result = Vec::new(); - let Some(module_symbol) = self.analyzer.get_or_analyze(specifier)? else { - return Ok(Vec::new()); - }; - if matches!(exports_to_trace, ImportedExports::AllWithDefault) { - let maybe_symbol_id = module_symbol.exports_map().get("default").copied(); - if let Some(symbol_id) = maybe_symbol_id { - result.push(( - specifier.clone(), - module_symbol.module_id(), - "default".to_string(), - symbol_id, - )); - } - } - match exports_to_trace { - ImportedExports::Star | ImportedExports::AllWithDefault => { - let mut found_names = HashSet::new(); - for (name, symbol_id) in module_symbol.exports_map() { - if name != "default" { - result.push(( - specifier.clone(), - module_symbol.module_id(), - name.clone(), - *symbol_id, - )); - found_names.insert(name.clone()); - } - } - let re_exports = module_symbol.re_export_all_specifiers().to_vec(); - for re_export_specifier in re_exports.iter() { - let maybe_specifier = self.graph.resolve_dependency( - re_export_specifier, - specifier, - /* prefer_types */ true, - ); - if let Some(specifier) = maybe_specifier { - let inner = self.trace_exports_inner( - &specifier, - &ImportedExports::Star, - { - let mut visited = visited.clone(); - visited.insert(specifier.clone()); - visited - }, - )?; - for (specifier, module_id, name, symbol_id) in inner { - if name != "default" && found_names.insert(name.clone()) { - result.push((specifier, module_id, name, symbol_id)); - } - } - } - } - } - ImportedExports::Named(names) => { - let module_id = module_symbol.module_id(); - let exports = module_symbol.exports_map().clone(); - let re_exports = module_symbol.re_export_all_specifiers().to_vec(); - for name in names { - if let Some(symbol_id) = exports.get(name) { - result.push(( - specifier.clone(), - module_id, - name.clone(), - *symbol_id, - )); - } else if name != "default" { - for re_export_specifier in re_exports.iter() { - let maybe_specifier = self.graph.resolve_dependency( - re_export_specifier, - specifier, - /* prefer_types */ true, - ); - if let Some(specifier) = maybe_specifier { - let mut found = self.trace_exports_inner( - &specifier, - &ImportedExports::Named(IndexSet::from([name.clone()])), - { - let mut visited = visited.clone(); - visited.insert(specifier.clone()); - visited - }, - )?; - if !found.is_empty() { - assert_eq!(found.len(), 1); - result.push(found.remove(0)); - break; - } - } - } - } - } - } - } - Ok(result) - } -} - -fn trace_module( - pending_trace: PendingTrace, - context: &mut Context, -) -> Result<()> { - let mut pending = context.trace_exports(pending_trace)?; - - while let Some((specifier, symbol_id)) = pending.pop() { - let Some(module_symbol) = context.analyzer.get_or_analyze(&specifier)? - else { - continue; - }; - let symbol = module_symbol.symbol(symbol_id).unwrap(); - if symbol.mark_public() { - if let Some(file_dep) = symbol.file_dep() { - let maybe_dep_specifier = context.graph.resolve_dependency( - &file_dep.specifier, - &specifier, - /* prefer types */ true, - ); - if let Some(dep_specifier) = maybe_dep_specifier { - context.pending_traces.add( - dep_specifier, - ImportedExports::from_file_dep_name(&file_dep.name), - /* referrer */ module_symbol.module_id(), - ); - } - } - let symbol_deps = - symbol.deps().map(ToOwned::to_owned).collect::>(); - for dep in symbol_deps { - match &dep { - SymbolDep::Id(id) => { - if let Some(id) = - module_symbol.esm().unwrap().symbol_id_from_swc(id) - { - pending.push((module_symbol.specifier().clone(), id)) - } - } - SymbolDep::QualifiedId(id, parts) => { - if let Some(symbol_id) = - module_symbol.esm().unwrap().symbol_id_from_swc(id) - { - pending.extend(resolve_qualified_name( - context.graph, - module_symbol, - symbol_id, - parts, - &|specifier| { - context.analyzer.get_or_analyze(specifier).ok().flatten() - }, - )); - } - } - SymbolDep::ImportType(import_specifier, parts) => { - let maybe_dep_specifier = context.graph.resolve_dependency( - import_specifier, - &specifier, - /* prefer types */ true, - ); - if let Some(dep_specifier) = maybe_dep_specifier { - if let Some(module_symbol) = - context.analyzer.get_or_analyze(&dep_specifier)? - { - if parts.is_empty() { - // an ImportType includes default exports - context.pending_traces.add( - dep_specifier, - ImportedExports::AllWithDefault, - /* referrer */ module_symbol.module_id(), - ); - } else { - pending.extend(resolve_qualified_export_name( - context.graph, - module_symbol, - &parts[0], - &parts[1..], - &|specifier| { - context.analyzer.get_or_analyze(specifier).ok().flatten() - }, - )); - } - } - } - } - } - } - } - } - - Ok(()) -} diff --git a/tests/helpers/test_builder.rs b/tests/helpers/test_builder.rs index 115c73510..6b10f319a 100644 --- a/tests/helpers/test_builder.rs +++ b/tests/helpers/test_builder.rs @@ -44,37 +44,13 @@ impl Loader for TestLoader { } } -#[cfg(feature = "type_tracing")] -pub mod tracing { - use std::cell::RefCell; - - use deno_graph::type_tracer::RootSymbol; - use deno_graph::type_tracer::TypeTraceDiagnostic; - use deno_graph::type_tracer::TypeTraceHandler; - use deno_graph::ModuleGraph; - - #[derive(Default)] - pub struct TestTypeTraceHandler { - diagnostics: RefCell>, - } - - impl TestTypeTraceHandler { - pub fn diagnostics(self) -> Vec { - self.diagnostics.take() - } - } +#[cfg(feature = "symbols")] +pub mod symbols { + use deno_graph::symbols::SymbolFillDiagnostic; - impl TypeTraceHandler for TestTypeTraceHandler { - fn diagnostic(&self, diagnostic: TypeTraceDiagnostic) { - self.diagnostics.borrow_mut().push(diagnostic); - } - } - - pub struct TypeTraceResult { - pub graph: ModuleGraph, - pub root_symbol: RootSymbol, + pub struct SymbolsResult { pub output: String, - pub diagnostics: Vec, + pub diagnostics: Vec, } } @@ -143,11 +119,10 @@ impl TestBuilder { BuildResult { graph, diagnostics } } - #[cfg(feature = "type_tracing")] - pub async fn trace(&mut self) -> anyhow::Result { - use deno_graph::type_tracer::ModuleSymbol; + #[cfg(feature = "symbols")] + pub async fn symbols(&mut self) -> anyhow::Result { + use deno_graph::symbols::ModuleSymbolRef; - let handler = tracing::TestTypeTraceHandler::default(); let mut graph = deno_graph::ModuleGraph::new(GraphKind::All); let entry_point_url = ModuleSpecifier::parse(&self.entry_point).unwrap(); let entry_point_types_url = @@ -166,36 +141,38 @@ impl TestBuilder { Some(Box::new(source_parser)), None, ); - let root_symbol = deno_graph::type_tracer::trace_public_types( - &graph, - &roots, - &capturing_analyzer.as_capturing_parser(), - &handler, - )?; - Ok(tracing::TypeTraceResult { - graph: graph.clone(), - root_symbol: root_symbol.clone(), + let capturing_parser = capturing_analyzer.as_capturing_parser(); + let root_symbol = + deno_graph::symbols::RootSymbol::new(&graph, &capturing_parser); + Ok(symbols::SymbolsResult { output: { let entrypoint_symbol = root_symbol .get_module_from_specifier(&entry_point_types_url) .unwrap(); let mut output_text = String::new(); - for (k, m) in root_symbol.clone().into_specifier_map() { + let mut specifiers = + graph.specifiers().map(|(s, _)| s).collect::>(); + specifiers.sort_unstable(); + for specifier in specifiers { + let Some(module) = root_symbol.get_module_from_specifier(specifier) + else { + continue; + }; output_text.push_str(&format!( "{}: {}\n", - k.as_str(), - match m { - ModuleSymbol::Esm(m) => format!("{:#?}", m), - ModuleSymbol::Json(m) => format!("{:#?}", m), + specifier.as_str(), + match module { + ModuleSymbolRef::Esm(m) => format!("{:#?}", m), + ModuleSymbolRef::Json(m) => format!("{:#?}", m), } )); } let get_symbol_text = - |module_symbol: deno_graph::type_tracer::ModuleSymbolRef, - symbol_id: deno_graph::type_tracer::SymbolId| { + |module_symbol: deno_graph::symbols::ModuleSymbolRef, + symbol_id: deno_graph::symbols::SymbolId| { let symbol = module_symbol.symbol(symbol_id).unwrap(); let definitions = - root_symbol.go_to_definitions(&graph, module_symbol, symbol); + root_symbol.go_to_definitions(module_symbol, symbol); if definitions.is_empty() { "NONE".to_string() } else { @@ -244,7 +221,7 @@ impl TestBuilder { } output_text }, - diagnostics: handler.diagnostics(), + diagnostics: root_symbol.take_diagnostics(), }) } } diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 176929ebe..dc091e5b0 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -90,11 +90,11 @@ async fn test_graph_specs() { } } -#[cfg(feature = "type_tracing")] +#[cfg(feature = "symbols")] #[tokio::test] -async fn test_type_tracing_specs() { +async fn test_symbols_specs() { for (test_file_path, spec) in - get_specs_in_dir(&PathBuf::from("./tests/specs/type_tracing")) + get_specs_in_dir(&PathBuf::from("./tests/specs/symbols")) { eprintln!("Running {}", test_file_path.display()); let mut builder = TestBuilder::new(); @@ -120,7 +120,7 @@ async fn test_type_tracing_specs() { } }); - let result = builder.trace().await.unwrap(); + let result = builder.symbols().await.unwrap(); let update_var = std::env::var("UPDATE"); let diagnostics = result .diagnostics diff --git a/tests/specs/type_tracing/Basic.txt b/tests/specs/symbols/Basic.txt similarity index 95% rename from tests/specs/type_tracing/Basic.txt rename to tests/specs/symbols/Basic.txt index de5b59f73..4352f3624 100644 --- a/tests/specs/type_tracing/Basic.txt +++ b/tests/specs/symbols/Basic.txt @@ -27,166 +27,177 @@ export default class C { export type D = typeof C; # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, + 1, ), - specifier: "file:///mod.ts", + specifier: "file:///a.ts", child_decls: { + 0, + 1, + 2, 3, 5, }, exports: { - "ExportA": 4, - "D": 2, + "A": 2, + "B": 3, + "default": 4, + "D": 5, }, re_exports: [], swc_id_to_symbol_id: { ( - "A", + "AInner", #2, ): 0, ( - "B", + "AInnerUnused", #2, ): 1, ( - "D", + "A", #2, ): 2, ( - "ExportA", + "B", + #2, + ): 3, + ( + "C", #2, ): 4, ( - "test", + "D", #2, ): 5, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 9, + 0, ), end: SourcePos( - 10, + 36, ), }, - kind: FileRef( - FileDep { - name: Name( - "A", - ), - specifier: "./a.ts", - }, + kind: Definition( + SymbolNode( + "", + ), ), }, ], - deps: {}, + deps: { + Id( + ( + "AInner", + #2, + ), + ), + Id( + ( + "prop", + #0, + ), + ), + }, child_decls: {}, exports: {}, }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 12, + 38, ), end: SourcePos( - 13, + 81, ), }, - kind: FileRef( - FileDep { - name: Name( - "B", - ), - specifier: "./a.ts", - }, + kind: Definition( + SymbolNode( + "", + ), ), }, ], - deps: {}, + deps: { + Id( + ( + "AInnerUnused", + #2, + ), + ), + Id( + ( + "prop2", + #0, + ), + ), + }, child_decls: {}, exports: {}, }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 15, - ), - end: SourcePos( - 16, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "D", - ), - specifier: "./a.ts", - }, - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 87, + 83, ), end: SourcePos( - 100, + 117, ), }, - kind: TargetSelf, - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 96, - ), - end: SourcePos( - 97, + kind: Definition( + SymbolNode( + "", ), - }, - kind: TargetSelf, + ), }, ], - deps: {}, + deps: { + Id( + ( + "AInner", + #2, + ), + ), + }, child_decls: {}, exports: {}, }, 3: Symbol { symbol_id: 3, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 35, + 119, ), end: SourcePos( - 70, + 142, ), }, - kind: TargetSelf, + kind: Definition( + SymbolNode( + "", + ), + ), }, ], deps: { Id( ( - "ExportA", + "B", #2, ), ), @@ -196,15 +207,14 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 48, + 144, ), end: SourcePos( - 69, + 170, ), }, kind: Definition( @@ -214,28 +224,20 @@ file:///mod.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "A", - #2, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, 5: Symbol { symbol_id: 5, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 78, + 173, ), end: SourcePos( - 85, + 198, ), }, kind: Definition( @@ -248,7 +250,13 @@ file:///mod.ts: EsmModuleSymbol { deps: { Id( ( - "B", + "D", + #2, + ), + ), + Id( + ( + "C", #2, ), ), @@ -257,184 +265,163 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 1, + 0, ), - specifier: "file:///a.ts", + specifier: "file:///mod.ts", child_decls: { - 0, - 1, - 2, 3, 5, }, exports: { - "A": 2, - "B": 3, - "default": 4, - "D": 5, + "ExportA": 4, + "D": 2, }, re_exports: [], swc_id_to_symbol_id: { ( - "AInner", + "A", #2, ): 0, ( - "AInnerUnused", + "B", #2, ): 1, ( - "A", + "D", #2, ): 2, ( - "B", - #2, - ): 3, - ( - "C", + "ExportA", #2, ): 4, ( - "D", + "test", #2, ): 5, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 0, + 9, ), end: SourcePos( - 36, + 10, ), }, - kind: Definition( - SymbolNode( - "", - ), + kind: FileRef( + FileDep { + name: Name( + "A", + ), + specifier: "./a.ts", + }, ), }, ], - deps: { - Id( - ( - "AInner", - #2, - ), - ), - Id( - ( - "prop", - #0, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 38, + 12, ), end: SourcePos( - 81, + 13, ), }, - kind: Definition( - SymbolNode( - "", - ), + kind: FileRef( + FileDep { + name: Name( + "B", + ), + specifier: "./a.ts", + }, ), }, ], - deps: { - Id( - ( - "AInnerUnused", - #2, - ), - ), - Id( - ( - "prop2", - #0, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 83, + 15, ), end: SourcePos( - 117, + 16, ), }, - kind: Definition( - SymbolNode( - "", - ), + kind: FileRef( + FileDep { + name: Name( + "D", + ), + specifier: "./a.ts", + }, ), }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 87, + ), + end: SourcePos( + 100, + ), + }, + kind: TargetSelf, + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 96, + ), + end: SourcePos( + 97, + ), + }, + kind: TargetSelf, + }, ], - deps: { - Id( - ( - "AInner", - #2, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, 3: Symbol { symbol_id: 3, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 119, + 35, ), end: SourcePos( - 142, + 70, ), }, - kind: Definition( - SymbolNode( - "", - ), - ), + kind: TargetSelf, }, ], deps: { Id( ( - "B", + "ExportA", #2, ), ), @@ -444,15 +431,14 @@ file:///a.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 144, + 48, ), end: SourcePos( - 170, + 69, ), }, kind: Definition( @@ -462,21 +448,27 @@ file:///a.ts: EsmModuleSymbol { ), }, ], - deps: {}, + deps: { + Id( + ( + "A", + #2, + ), + ), + }, child_decls: {}, exports: {}, }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 173, + 78, ), end: SourcePos( - 198, + 85, ), }, kind: Definition( @@ -489,13 +481,7 @@ file:///a.ts: EsmModuleSymbol { deps: { Id( ( - "D", - #2, - ), - ), - Id( - ( - "C", + "B", #2, ), ), @@ -504,17 +490,6 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "D", - "A", - }, - ), - }, } == export definitions == [D]: file:///a.ts:173..198 diff --git a/tests/specs/type_tracing/Classes01.txt b/tests/specs/symbols/Classes01.txt similarity index 96% rename from tests/specs/type_tracing/Classes01.txt rename to tests/specs/symbols/Classes01.txt index 8f4ad6afa..252f74121 100644 --- a/tests/specs/type_tracing/Classes01.txt +++ b/tests/specs/symbols/Classes01.txt @@ -137,7 +137,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -168,7 +167,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -192,7 +190,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -223,7 +220,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -302,7 +298,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -326,7 +321,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -350,7 +344,6 @@ file:///mod.ts: EsmModuleSymbol { }, 6: Symbol { symbol_id: 6, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -374,7 +367,6 @@ file:///mod.ts: EsmModuleSymbol { }, 7: Symbol { symbol_id: 7, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -398,7 +390,6 @@ file:///mod.ts: EsmModuleSymbol { }, 8: Symbol { symbol_id: 8, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -422,7 +413,6 @@ file:///mod.ts: EsmModuleSymbol { }, 9: Symbol { symbol_id: 9, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -446,7 +436,6 @@ file:///mod.ts: EsmModuleSymbol { }, 10: Symbol { symbol_id: 10, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -470,7 +459,6 @@ file:///mod.ts: EsmModuleSymbol { }, 11: Symbol { symbol_id: 11, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -494,7 +482,6 @@ file:///mod.ts: EsmModuleSymbol { }, 12: Symbol { symbol_id: 12, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -518,7 +505,6 @@ file:///mod.ts: EsmModuleSymbol { }, 13: Symbol { symbol_id: 13, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -542,7 +528,6 @@ file:///mod.ts: EsmModuleSymbol { }, 14: Symbol { symbol_id: 14, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -565,8 +550,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [A]: file:///mod.ts:0..26 diff --git a/tests/specs/type_tracing/DeclarationMerging01.txt b/tests/specs/symbols/DeclarationMerging01.txt similarity index 97% rename from tests/specs/type_tracing/DeclarationMerging01.txt rename to tests/specs/symbols/DeclarationMerging01.txt index feff704a9..f4f7ccf78 100644 --- a/tests/specs/type_tracing/DeclarationMerging01.txt +++ b/tests/specs/symbols/DeclarationMerging01.txt @@ -70,7 +70,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -142,7 +141,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -166,7 +164,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -238,7 +235,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -262,7 +258,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -334,7 +329,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -357,8 +351,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [Album]: file:///mod.ts:0..15 diff --git a/tests/specs/type_tracing/ExportAssignment01.txt b/tests/specs/symbols/ExportAssignment01.txt similarity index 95% rename from tests/specs/type_tracing/ExportAssignment01.txt rename to tests/specs/symbols/ExportAssignment01.txt index 5e190c68a..5a991a38b 100644 --- a/tests/specs/type_tracing/ExportAssignment01.txt +++ b/tests/specs/symbols/ExportAssignment01.txt @@ -27,7 +27,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -67,7 +66,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -98,8 +96,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [default]: file:///mod.ts:0..19 diff --git a/tests/specs/type_tracing/ExportDefault01.txt b/tests/specs/symbols/ExportDefault01.txt similarity index 93% rename from tests/specs/type_tracing/ExportDefault01.txt rename to tests/specs/symbols/ExportDefault01.txt index 1cc3a5dfd..9aecf989d 100644 --- a/tests/specs/type_tracing/ExportDefault01.txt +++ b/tests/specs/symbols/ExportDefault01.txt @@ -41,264 +41,6 @@ export default function Test() { } # output -file:///mod.ts: EsmModuleSymbol { - module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: {}, - exports: { - "default": 4, - "C1": 1, - "C2": 2, - "CInterface": 3, - }, - re_exports: [], - swc_id_to_symbol_id: { - ( - "Test", - #2, - ): 0, - ( - "C1", - #2, - ): 1, - ( - "C2", - #2, - ): 2, - ( - "CInterface", - #2, - ): 3, - }, - symbols: { - 0: Symbol { - symbol_id: 0, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 7, - ), - end: SourcePos( - 11, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "default", - ), - specifier: "./a.ts", - }, - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 94, - ), - end: SourcePos( - 98, - ), - }, - kind: Target( - ( - "Test", - #2, - ), - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 36, - ), - end: SourcePos( - 38, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "C1", - ), - specifier: "./a.ts", - }, - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 101, - ), - end: SourcePos( - 131, - ), - }, - kind: TargetSelf, - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 110, - ), - end: SourcePos( - 112, - ), - }, - kind: TargetSelf, - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 2: Symbol { - symbol_id: 2, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 40, - ), - end: SourcePos( - 42, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "C2", - ), - specifier: "./a.ts", - }, - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 101, - ), - end: SourcePos( - 131, - ), - }, - kind: TargetSelf, - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 114, - ), - end: SourcePos( - 116, - ), - }, - kind: TargetSelf, - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 3: Symbol { - symbol_id: 3, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 44, - ), - end: SourcePos( - 60, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "C3", - ), - specifier: "./a.ts", - }, - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 101, - ), - end: SourcePos( - 131, - ), - }, - kind: TargetSelf, - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 118, - ), - end: SourcePos( - 128, - ), - }, - kind: TargetSelf, - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 4: Symbol { - symbol_id: 4, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 79, - ), - end: SourcePos( - 99, - ), - }, - kind: Target( - ( - "Test", - #2, - ), - ), - }, - ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - }, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: {}, -} file:///a.ts: EsmModuleSymbol { module_id: ModuleId( 1, @@ -337,7 +79,6 @@ file:///a.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -364,7 +105,6 @@ file:///a.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -391,7 +131,6 @@ file:///a.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -418,7 +157,6 @@ file:///a.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -449,7 +187,6 @@ file:///a.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -480,7 +217,6 @@ file:///a.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -504,7 +240,6 @@ file:///a.ts: EsmModuleSymbol { }, 6: Symbol { symbol_id: 6, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -527,25 +262,12 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "C3", - "C2", - "C1", - "default", - }, - ), - }, } -file:///interface.ts: EsmModuleSymbol { +file:///class.ts: EsmModuleSymbol { module_id: ModuleId( 2, ), - specifier: "file:///interface.ts", + specifier: "file:///class.ts", child_decls: {}, exports: { "default": 0, @@ -560,7 +282,6 @@ file:///interface.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -568,7 +289,7 @@ file:///interface.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 33, + 29, ), }, kind: Definition( @@ -578,28 +299,11 @@ file:///interface.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", - }, - ), - }, } file:///function.ts: EsmModuleSymbol { module_id: ModuleId( @@ -620,7 +324,6 @@ file:///function.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -643,22 +346,12 @@ file:///function.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", - }, - ), - }, } -file:///class.ts: EsmModuleSymbol { +file:///interface.ts: EsmModuleSymbol { module_id: ModuleId( 4, ), - specifier: "file:///class.ts", + specifier: "file:///interface.ts", child_decls: {}, exports: { "default": 0, @@ -673,7 +366,6 @@ file:///class.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -681,7 +373,7 @@ file:///class.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 29, + 33, ), }, kind: Definition( @@ -691,20 +383,268 @@ file:///class.ts: EsmModuleSymbol { ), }, ], - deps: {}, + deps: { + Id( + ( + "Test", + #2, + ), + ), + }, child_decls: {}, exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", +} +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_decls: {}, + exports: { + "default": 4, + "C1": 1, + "C2": 2, + "CInterface": 3, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "Test", + #2, + ): 0, + ( + "C1", + #2, + ): 1, + ( + "C2", + #2, + ): 2, + ( + "CInterface", + #2, + ): 3, + }, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 7, + ), + end: SourcePos( + 11, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "default", + ), + specifier: "./a.ts", + }, + ), + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 94, + ), + end: SourcePos( + 98, + ), + }, + kind: Target( + ( + "Test", + #2, + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 36, + ), + end: SourcePos( + 38, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "C1", + ), + specifier: "./a.ts", + }, + ), + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 101, + ), + end: SourcePos( + 131, + ), + }, + kind: TargetSelf, + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 110, + ), + end: SourcePos( + 112, + ), + }, + kind: TargetSelf, + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 2: Symbol { + symbol_id: 2, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 40, + ), + end: SourcePos( + 42, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "C2", + ), + specifier: "./a.ts", + }, + ), + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 101, + ), + end: SourcePos( + 131, + ), + }, + kind: TargetSelf, + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 114, + ), + end: SourcePos( + 116, + ), + }, + kind: TargetSelf, + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 3: Symbol { + symbol_id: 3, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 44, + ), + end: SourcePos( + 60, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "C3", + ), + specifier: "./a.ts", + }, + ), + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 101, + ), + end: SourcePos( + 131, + ), + }, + kind: TargetSelf, + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 118, + ), + end: SourcePos( + 128, + ), + }, + kind: TargetSelf, + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 4: Symbol { + symbol_id: 4, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 79, + ), + end: SourcePos( + 99, + ), + }, + kind: Target( + ( + "Test", + #2, + ), + ), + }, + ], + deps: { + Id( + ( + "Test", + #2, + ), + ), }, - ), + child_decls: {}, + exports: {}, + }, }, } == export definitions == diff --git a/tests/specs/type_tracing/ExportDefault02.txt b/tests/specs/symbols/ExportDefault02.txt similarity index 95% rename from tests/specs/type_tracing/ExportDefault02.txt rename to tests/specs/symbols/ExportDefault02.txt index a88effaf7..f428faeed 100644 --- a/tests/specs/type_tracing/ExportDefault02.txt +++ b/tests/specs/symbols/ExportDefault02.txt @@ -23,7 +23,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -55,7 +54,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -94,8 +92,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [default]: file:///mod.ts:21..34 diff --git a/tests/specs/type_tracing/ExportDefault03.txt b/tests/specs/symbols/ExportDefault03.txt similarity index 90% rename from tests/specs/type_tracing/ExportDefault03.txt rename to tests/specs/symbols/ExportDefault03.txt index 1cad4bcad..b5da48be0 100644 --- a/tests/specs/type_tracing/ExportDefault03.txt +++ b/tests/specs/symbols/ExportDefault03.txt @@ -13,29 +13,25 @@ export class B {} export class B1 {} # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: { 1, - }, + ), + specifier: "file:///a.ts", + child_decls: {}, exports: { - "Test2": 0, - "Test": 1, + "default": 0, }, re_exports: [], swc_id_to_symbol_id: { ( "Test", #2, - ): 1, + ): 0, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -43,41 +39,28 @@ file:///mod.ts: EsmModuleSymbol { 9, ), end: SourcePos( - 25, + 18, ), }, kind: FileRef( FileDep { name: Name( - "default", + "B", ), - specifier: "./a.ts", + specifier: "./b.ts", }, ), }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 44, + 37, ), end: SourcePos( 64, ), }, - kind: Definition( - SymbolNode( - "", - ), - ), + kind: TargetSelf, }, ], deps: {}, @@ -85,58 +68,72 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///b.ts: EsmModuleSymbol { module_id: ModuleId( - 1, + 2, ), - specifier: "file:///a.ts", - child_decls: {}, + specifier: "file:///b.ts", + child_decls: { + 0, + 1, + }, exports: { - "default": 0, + "B": 0, + "B1": 1, }, re_exports: [], swc_id_to_symbol_id: { ( - "Test", + "B", #2, ): 0, + ( + "B1", + #2, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 9, + 0, ), end: SourcePos( - 18, + 17, ), }, - kind: FileRef( - FileDep { - name: Name( - "B", - ), - specifier: "./b.ts", - }, + kind: Definition( + SymbolNode( + "", + ), ), }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 1: Symbol { + symbol_id: 1, + decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 37, + 18, ), end: SourcePos( - 64, + 36, ), }, - kind: TargetSelf, + kind: Definition( + SymbolNode( + "", + ), + ), }, ], deps: {}, @@ -144,59 +141,46 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "default", - }, - ), - }, } -file:///b.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 2, + 0, ), - specifier: "file:///b.ts", + specifier: "file:///mod.ts", child_decls: { - 0, 1, }, exports: { - "B": 0, - "B1": 1, + "Test2": 0, + "Test": 1, }, re_exports: [], swc_id_to_symbol_id: { ( - "B", - #2, - ): 0, - ( - "B1", + "Test", #2, ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 0, + 9, ), end: SourcePos( - 17, + 25, ), }, - kind: Definition( - SymbolNode( - "", - ), + kind: FileRef( + FileDep { + name: Name( + "default", + ), + specifier: "./a.ts", + }, ), }, ], @@ -206,15 +190,14 @@ file:///b.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 18, + 44, ), end: SourcePos( - 36, + 64, ), }, kind: Definition( @@ -229,16 +212,6 @@ file:///b.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "B", - }, - ), - }, } == export definitions == [Test]: file:///mod.ts:44..64 diff --git a/tests/specs/type_tracing/ExportDefault04.txt b/tests/specs/symbols/ExportDefault04.txt similarity index 89% rename from tests/specs/type_tracing/ExportDefault04.txt rename to tests/specs/symbols/ExportDefault04.txt index b2a17b60f..959ad8a47 100644 --- a/tests/specs/type_tracing/ExportDefault04.txt +++ b/tests/specs/symbols/ExportDefault04.txt @@ -12,8 +12,6 @@ file:///mod.ts: EsmModuleSymbol { re_exports: [], swc_id_to_symbol_id: {}, symbols: {}, - traced_re_exports: {}, - traced_referrers: {}, } # diagnostics diff --git a/tests/specs/type_tracing/ExportDefaultLiteral01.txt b/tests/specs/symbols/ExportDefaultLiteral01.txt similarity index 92% rename from tests/specs/type_tracing/ExportDefaultLiteral01.txt rename to tests/specs/symbols/ExportDefaultLiteral01.txt index a82d9c9e0..be41b9676 100644 --- a/tests/specs/type_tracing/ExportDefaultLiteral01.txt +++ b/tests/specs/symbols/ExportDefaultLiteral01.txt @@ -16,7 +16,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -39,8 +38,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [default]: file:///mod.ts:0..17 diff --git a/tests/specs/type_tracing/ExportDefaultLiteral02.txt b/tests/specs/symbols/ExportDefaultLiteral02.txt similarity index 92% rename from tests/specs/type_tracing/ExportDefaultLiteral02.txt rename to tests/specs/symbols/ExportDefaultLiteral02.txt index 2d84e9f29..9987c1a4b 100644 --- a/tests/specs/type_tracing/ExportDefaultLiteral02.txt +++ b/tests/specs/symbols/ExportDefaultLiteral02.txt @@ -16,7 +16,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -39,8 +38,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [default]: file:///mod.ts:0..22 diff --git a/tests/specs/type_tracing/ExportDestructured.txt b/tests/specs/symbols/ExportDestructured.txt similarity index 96% rename from tests/specs/type_tracing/ExportDestructured.txt rename to tests/specs/symbols/ExportDestructured.txt index 1c9db859f..968bd9f48 100644 --- a/tests/specs/type_tracing/ExportDestructured.txt +++ b/tests/specs/symbols/ExportDestructured.txt @@ -51,7 +51,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -75,7 +74,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -112,7 +110,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -145,7 +142,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -182,7 +178,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -218,8 +213,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [a]: file:///mod.ts:97..232 diff --git a/tests/specs/type_tracing/ExportStar01.txt b/tests/specs/symbols/ExportStar01.txt similarity index 91% rename from tests/specs/type_tracing/ExportStar01.txt rename to tests/specs/symbols/ExportStar01.txt index 967017ca7..d9fe8c476 100644 --- a/tests/specs/type_tracing/ExportStar01.txt +++ b/tests/specs/symbols/ExportStar01.txt @@ -36,47 +36,6 @@ export default function Test() { } # output -file:///mod.ts: EsmModuleSymbol { - module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: {}, - exports: { - "namespace": 0, - }, - re_exports: [], - swc_id_to_symbol_id: {}, - symbols: { - 0: Symbol { - symbol_id: 0, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 7, - ), - end: SourcePos( - 21, - ), - }, - kind: FileRef( - FileDep { - name: Star, - specifier: "./a.ts", - }, - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: {}, -} file:///a.ts: EsmModuleSymbol { module_id: ModuleId( 1, @@ -115,7 +74,6 @@ file:///a.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -142,7 +100,6 @@ file:///a.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -169,7 +126,6 @@ file:///a.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -196,7 +152,6 @@ file:///a.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -227,7 +182,6 @@ file:///a.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -258,7 +212,6 @@ file:///a.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -282,7 +235,6 @@ file:///a.ts: EsmModuleSymbol { }, 6: Symbol { symbol_id: 6, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -305,12 +257,6 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Star, - }, } file:///class.ts: EsmModuleSymbol { module_id: ModuleId( @@ -331,7 +277,6 @@ file:///class.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -354,16 +299,6 @@ file:///class.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", - }, - ), - }, } file:///function.ts: EsmModuleSymbol { module_id: ModuleId( @@ -384,7 +319,6 @@ file:///function.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -407,16 +341,6 @@ file:///function.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", - }, - ), - }, } file:///interface.ts: EsmModuleSymbol { module_id: ModuleId( @@ -437,7 +361,6 @@ file:///interface.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -467,15 +390,43 @@ file:///interface.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "default", - }, - ), +} +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_decls: {}, + exports: { + "namespace": 0, + }, + re_exports: [], + swc_id_to_symbol_id: {}, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 7, + ), + end: SourcePos( + 21, + ), + }, + kind: FileRef( + FileDep { + name: Star, + specifier: "./a.ts", + }, + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, }, } == export definitions == diff --git a/tests/specs/type_tracing/ExportedDeclare01.txt b/tests/specs/symbols/ExportedDeclare01.txt similarity index 97% rename from tests/specs/type_tracing/ExportedDeclare01.txt rename to tests/specs/symbols/ExportedDeclare01.txt index a2845df92..e90ff0c48 100644 --- a/tests/specs/type_tracing/ExportedDeclare01.txt +++ b/tests/specs/symbols/ExportedDeclare01.txt @@ -59,7 +59,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -94,7 +93,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -122,7 +120,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -168,7 +165,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -192,7 +188,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -245,7 +240,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -293,8 +287,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [MyClass]: file:///mod.ts:116..174 diff --git a/tests/specs/type_tracing/ExportedDeclare02.txt b/tests/specs/symbols/ExportedDeclare02.txt similarity index 94% rename from tests/specs/type_tracing/ExportedDeclare02.txt rename to tests/specs/symbols/ExportedDeclare02.txt index 9938a08cb..73622f1ce 100644 --- a/tests/specs/type_tracing/ExportedDeclare02.txt +++ b/tests/specs/symbols/ExportedDeclare02.txt @@ -29,7 +29,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -53,7 +52,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -76,8 +74,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [bar]: file:///mod.ts:32..56 diff --git a/tests/specs/type_tracing/FunctionOverloads01.txt b/tests/specs/symbols/FunctionOverloads01.txt similarity index 97% rename from tests/specs/type_tracing/FunctionOverloads01.txt rename to tests/specs/symbols/FunctionOverloads01.txt index f385a07b9..1a51bf061 100644 --- a/tests/specs/type_tracing/FunctionOverloads01.txt +++ b/tests/specs/symbols/FunctionOverloads01.txt @@ -50,7 +50,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -104,7 +103,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -139,7 +137,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -193,7 +190,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -252,8 +248,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [InnerInner]: file:///mod.ts:144..181 diff --git a/tests/specs/type_tracing/Functions01.txt b/tests/specs/symbols/Functions01.txt similarity index 96% rename from tests/specs/type_tracing/Functions01.txt rename to tests/specs/symbols/Functions01.txt index add66dcbe..57cebb76d 100644 --- a/tests/specs/type_tracing/Functions01.txt +++ b/tests/specs/symbols/Functions01.txt @@ -99,7 +99,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -148,7 +147,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -172,7 +170,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -196,7 +193,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -220,7 +216,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -244,7 +239,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -317,7 +311,6 @@ file:///mod.ts: EsmModuleSymbol { }, 6: Symbol { symbol_id: 6, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -341,7 +334,6 @@ file:///mod.ts: EsmModuleSymbol { }, 7: Symbol { symbol_id: 7, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -365,7 +357,6 @@ file:///mod.ts: EsmModuleSymbol { }, 8: Symbol { symbol_id: 8, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -389,7 +380,6 @@ file:///mod.ts: EsmModuleSymbol { }, 9: Symbol { symbol_id: 9, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -413,7 +403,6 @@ file:///mod.ts: EsmModuleSymbol { }, 10: Symbol { symbol_id: 10, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -437,7 +426,6 @@ file:///mod.ts: EsmModuleSymbol { }, 11: Symbol { symbol_id: 11, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -460,8 +448,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [overloaded]: file:///mod.ts:201..295 diff --git a/tests/specs/type_tracing/ImportEquals01.txt b/tests/specs/symbols/ImportEquals01.txt similarity index 95% rename from tests/specs/type_tracing/ImportEquals01.txt rename to tests/specs/symbols/ImportEquals01.txt index b7278ae4d..22b3c559f 100644 --- a/tests/specs/type_tracing/ImportEquals01.txt +++ b/tests/specs/symbols/ImportEquals01.txt @@ -36,7 +36,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -74,7 +73,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -109,7 +107,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -132,8 +129,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [MyExport]: file:///mod.ts:57..81 diff --git a/tests/specs/type_tracing/ImportEquals02.txt b/tests/specs/symbols/ImportEquals02.txt similarity index 96% rename from tests/specs/type_tracing/ImportEquals02.txt rename to tests/specs/symbols/ImportEquals02.txt index 5003baa33..517efe7a7 100644 --- a/tests/specs/type_tracing/ImportEquals02.txt +++ b/tests/specs/symbols/ImportEquals02.txt @@ -25,183 +25,6 @@ namespace A.B { export { A }; # output -file:///mod.ts: EsmModuleSymbol { - module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: { - 2, - }, - exports: { - "MyExport": 1, - }, - re_exports: [], - swc_id_to_symbol_id: { - ( - "A", - #2, - ): 0, - ( - "MyExport", - #2, - ): 1, - ( - "Test", - #2, - ): 2, - ( - "OtherInner", - #3, - ): 3, - }, - symbols: { - 0: Symbol { - symbol_id: 0, - is_public: false, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 9, - ), - end: SourcePos( - 10, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "A", - ), - specifier: "./a.ts", - }, - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 29, - ), - end: SourcePos( - 65, - ), - }, - kind: QualifiedTarget( - ( - "Test", - #2, - ), - [ - "Inner", - ], - ), - }, - ], - deps: { - QualifiedId( - ( - "Test", - #2, - ), - [ - "Inner", - ], - ), - }, - child_decls: {}, - exports: {}, - }, - 2: Symbol { - symbol_id: 2, - is_public: false, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 67, - ), - end: SourcePos( - 152, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], - deps: {}, - child_decls: {}, - exports: { - "Inner": 3, - }, - }, - 3: Symbol { - symbol_id: 3, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 86, - ), - end: SourcePos( - 116, - ), - }, - kind: QualifiedTarget( - ( - "A", - #2, - ), - [ - "B", - "Other", - ], - ), - }, - SymbolDecl { - range: SourceRange { - start: SourcePos( - 119, - ), - end: SourcePos( - 150, - ), - }, - kind: TargetSelf, - }, - ], - deps: { - QualifiedId( - ( - "A", - #2, - ), - [ - "B", - "Other", - ], - ), - }, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: {}, -} file:///a.ts: EsmModuleSymbol { module_id: ModuleId( 1, @@ -235,7 +58,6 @@ file:///a.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -290,7 +112,6 @@ file:///a.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -331,7 +152,6 @@ file:///a.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -414,7 +234,6 @@ file:///a.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -437,8 +256,177 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, +} +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_decls: { + 2, + }, + exports: { + "MyExport": 1, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "A", + #2, + ): 0, + ( + "MyExport", + #2, + ): 1, + ( + "Test", + #2, + ): 2, + ( + "OtherInner", + #3, + ): 3, + }, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 9, + ), + end: SourcePos( + 10, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "A", + ), + specifier: "./a.ts", + }, + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 29, + ), + end: SourcePos( + 65, + ), + }, + kind: QualifiedTarget( + ( + "Test", + #2, + ), + [ + "Inner", + ], + ), + }, + ], + deps: { + QualifiedId( + ( + "Test", + #2, + ), + [ + "Inner", + ], + ), + }, + child_decls: {}, + exports: {}, + }, + 2: Symbol { + symbol_id: 2, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 67, + ), + end: SourcePos( + 152, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: { + "Inner": 3, + }, + }, + 3: Symbol { + symbol_id: 3, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 86, + ), + end: SourcePos( + 116, + ), + }, + kind: QualifiedTarget( + ( + "A", + #2, + ), + [ + "B", + "Other", + ], + ), + }, + SymbolDecl { + range: SourceRange { + start: SourcePos( + 119, + ), + end: SourcePos( + 150, + ), + }, + kind: TargetSelf, + }, + ], + deps: { + QualifiedId( + ( + "A", + #2, + ), + [ + "B", + "Other", + ], + ), + }, + child_decls: {}, + exports: {}, + }, + }, } == export definitions == [MyExport]: file:///a.ts:18..65 diff --git a/tests/specs/type_tracing/ImportType01.txt b/tests/specs/symbols/ImportType01.txt similarity index 95% rename from tests/specs/type_tracing/ImportType01.txt rename to tests/specs/symbols/ImportType01.txt index 531a57572..5ac1c0d7d 100644 --- a/tests/specs/type_tracing/ImportType01.txt +++ b/tests/specs/symbols/ImportType01.txt @@ -11,28 +11,31 @@ export namespace A { } # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, + 1, ), - specifier: "file:///mod.ts", + specifier: "file:///a.ts", child_decls: { 0, }, exports: { - "Test": 0, + "A": 0, }, re_exports: [], swc_id_to_symbol_id: { ( - "Test", + "A", #2, ): 0, + ( + "B", + #3, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -40,7 +43,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 55, + 67, ), }, kind: Definition( @@ -53,8 +56,42 @@ file:///mod.ts: EsmModuleSymbol { deps: { Id( ( - "Test", - #2, + "B", + #3, + ), + ), + }, + child_decls: { + 1, + }, + exports: { + "B": 1, + }, + }, + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 23, + ), + end: SourcePos( + 65, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: { + Id( + ( + "B", + #3, ), ), Id( @@ -63,47 +100,33 @@ file:///mod.ts: EsmModuleSymbol { #0, ), ), - ImportType( - "./a.ts", - [ - "A", - "B", - ], - ), }, child_decls: {}, exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 1, + 0, ), - specifier: "file:///a.ts", + specifier: "file:///mod.ts", child_decls: { 0, }, exports: { - "A": 0, + "Test": 0, }, re_exports: [], swc_id_to_symbol_id: { ( - "A", + "Test", #2, ): 0, - ( - "B", - #3, - ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -111,42 +134,7 @@ file:///a.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 67, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], - deps: { - Id( - ( - "B", - #3, - ), - ), - }, - child_decls: { - 1, - }, - exports: { - "B": 1, - }, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 23, - ), - end: SourcePos( - 65, + 55, ), }, kind: Definition( @@ -159,8 +147,8 @@ file:///a.ts: EsmModuleSymbol { deps: { Id( ( - "B", - #3, + "Test", + #2, ), ), Id( @@ -169,13 +157,18 @@ file:///a.ts: EsmModuleSymbol { #0, ), ), + ImportType( + "./a.ts", + [ + "A", + "B", + ], + ), }, child_decls: {}, exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [Test]: file:///mod.ts:0..55 diff --git a/tests/specs/type_tracing/ImportType02.txt b/tests/specs/symbols/ImportType02.txt similarity index 93% rename from tests/specs/type_tracing/ImportType02.txt rename to tests/specs/symbols/ImportType02.txt index 0563b13b8..e5e07b336 100644 --- a/tests/specs/type_tracing/ImportType02.txt +++ b/tests/specs/symbols/ImportType02.txt @@ -11,16 +11,17 @@ export default function test() { } # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, + 1, ), - specifier: "file:///mod.ts", + specifier: "file:///a.ts", child_decls: { 0, }, exports: { "Test": 0, + "default": 1, }, re_exports: [], swc_id_to_symbol_id: { @@ -28,11 +29,14 @@ file:///mod.ts: EsmModuleSymbol { "Test", #2, ): 0, + ( + "test", + #2, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -40,7 +44,7 @@ file:///mod.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 43, + 41, ), }, kind: Definition( @@ -57,29 +61,51 @@ file:///mod.ts: EsmModuleSymbol { #2, ), ), - ImportType( - "./a.ts", - [], + Id( + ( + "prop", + #0, + ), ), }, child_decls: {}, exports: {}, }, + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 117, + ), + end: SourcePos( + 151, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 1, + 0, ), - specifier: "file:///a.ts", + specifier: "file:///mod.ts", child_decls: { 0, }, exports: { "Test": 0, - "default": 1, }, re_exports: [], swc_id_to_symbol_id: { @@ -87,15 +113,10 @@ file:///a.ts: EsmModuleSymbol { "Test", #2, ): 0, - ( - "test", - #2, - ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -103,7 +124,7 @@ file:///a.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 41, + 43, ), }, kind: Definition( @@ -120,46 +141,14 @@ file:///a.ts: EsmModuleSymbol { #2, ), ), - Id( - ( - "prop", - #0, - ), + ImportType( + "./a.ts", + [], ), }, child_decls: {}, exports: {}, }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 117, - ), - end: SourcePos( - 151, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): AllWithDefault, }, } == export definitions == diff --git a/tests/specs/type_tracing/Interfaces01.txt b/tests/specs/symbols/Interfaces01.txt similarity index 97% rename from tests/specs/type_tracing/Interfaces01.txt rename to tests/specs/symbols/Interfaces01.txt index fd2ce4aa8..1cfa8e3e1 100644 --- a/tests/specs/type_tracing/Interfaces01.txt +++ b/tests/specs/symbols/Interfaces01.txt @@ -76,7 +76,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -107,7 +106,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -192,7 +190,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -223,7 +220,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -254,7 +250,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -285,7 +280,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -316,7 +310,6 @@ file:///mod.ts: EsmModuleSymbol { }, 6: Symbol { symbol_id: 6, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -359,7 +352,6 @@ file:///mod.ts: EsmModuleSymbol { }, 7: Symbol { symbol_id: 7, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -389,8 +381,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [Main]: file:///mod.ts:17..142 diff --git a/tests/specs/type_tracing/Interfaces02.txt b/tests/specs/symbols/Interfaces02.txt similarity index 95% rename from tests/specs/type_tracing/Interfaces02.txt rename to tests/specs/symbols/Interfaces02.txt index a94f0e725..1a5667a8b 100644 --- a/tests/specs/type_tracing/Interfaces02.txt +++ b/tests/specs/symbols/Interfaces02.txt @@ -27,48 +27,40 @@ interface Prop2 {} export { A1 }; # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, + 1, ), - specifier: "file:///mod.ts", + specifier: "file:///a.ts", child_decls: { 0, 1, - 2, }, exports: { - "Test": 0, + "A1": 0, }, - re_exports: [ - "./a.ts", - ], + re_exports: [], swc_id_to_symbol_id: { ( - "Test", + "A1", #2, ): 0, - ( - "Prop1", - #2, - ): 1, ( "Prop2", #2, - ): 2, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 23, + 0, ), end: SourcePos( - 57, + 33, ), }, kind: Definition( @@ -80,10 +72,10 @@ file:///mod.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 58, + 34, ), end: SourcePos( - 92, + 66, ), }, kind: Definition( @@ -95,10 +87,10 @@ file:///mod.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 133, + 88, ), end: SourcePos( - 149, + 102, ), }, kind: TargetSelf, @@ -106,10 +98,10 @@ file:///mod.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 142, + 97, ), end: SourcePos( - 146, + 99, ), }, kind: TargetSelf, @@ -118,7 +110,7 @@ file:///mod.ts: EsmModuleSymbol { deps: { Id( ( - "Test", + "A1", #2, ), ), @@ -128,12 +120,6 @@ file:///mod.ts: EsmModuleSymbol { #0, ), ), - Id( - ( - "Prop1", - #2, - ), - ), Id( ( "prop2", @@ -152,46 +138,14 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 94, - ), - end: SourcePos( - 112, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], - deps: { - Id( - ( - "Prop1", - #2, - ), - ), - }, - child_decls: {}, - exports: {}, - }, - 2: Symbol { - symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 113, + 68, ), end: SourcePos( - 131, + 86, ), }, kind: Definition( @@ -213,51 +167,48 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: { - "A1": UniqueSymbolId { - module_id: ModuleId( - 1, - ), - symbol_id: 0, - }, - }, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 1, + 0, ), - specifier: "file:///a.ts", + specifier: "file:///mod.ts", child_decls: { 0, 1, + 2, }, exports: { - "A1": 0, + "Test": 0, }, - re_exports: [], + re_exports: [ + "./a.ts", + ], swc_id_to_symbol_id: { ( - "A1", + "Test", #2, ): 0, ( - "Prop2", + "Prop1", #2, ): 1, + ( + "Prop2", + #2, + ): 2, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 0, + 23, ), end: SourcePos( - 33, + 57, ), }, kind: Definition( @@ -269,10 +220,10 @@ file:///a.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 34, + 58, ), end: SourcePos( - 66, + 92, ), }, kind: Definition( @@ -284,10 +235,10 @@ file:///a.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 88, + 133, ), end: SourcePos( - 102, + 149, ), }, kind: TargetSelf, @@ -295,10 +246,10 @@ file:///a.ts: EsmModuleSymbol { SymbolDecl { range: SourceRange { start: SourcePos( - 97, + 142, ), end: SourcePos( - 99, + 146, ), }, kind: TargetSelf, @@ -307,7 +258,7 @@ file:///a.ts: EsmModuleSymbol { deps: { Id( ( - "A1", + "Test", #2, ), ), @@ -317,6 +268,12 @@ file:///a.ts: EsmModuleSymbol { #0, ), ), + Id( + ( + "Prop1", + #2, + ), + ), Id( ( "prop2", @@ -335,15 +292,44 @@ file:///a.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 68, + 94, ), end: SourcePos( - 86, + 112, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: { + Id( + ( + "Prop1", + #2, + ), + ), + }, + child_decls: {}, + exports: {}, + }, + 2: Symbol { + symbol_id: 2, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 113, + ), + end: SourcePos( + 131, ), }, kind: Definition( @@ -365,8 +351,6 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [A1]: file:///a.ts:0..33 diff --git a/tests/specs/type_tracing/ModuleExportNameStr01.txt b/tests/specs/symbols/ModuleExportNameStr01.txt similarity index 87% rename from tests/specs/type_tracing/ModuleExportNameStr01.txt rename to tests/specs/symbols/ModuleExportNameStr01.txt index f289afd46..f31162898 100644 --- a/tests/specs/type_tracing/ModuleExportNameStr01.txt +++ b/tests/specs/symbols/ModuleExportNameStr01.txt @@ -13,49 +13,6 @@ export { MyClass as "some-name" } from "./c.ts"; export class MyClass {} # output -file:///mod.ts: EsmModuleSymbol { - module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: {}, - exports: { - "someOtherName": 0, - }, - re_exports: [], - swc_id_to_symbol_id: {}, - symbols: { - 0: Symbol { - symbol_id: 0, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 9, - ), - end: SourcePos( - 38, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "someName", - ), - specifier: "./a.ts", - }, - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: {}, -} file:///a.ts: EsmModuleSymbol { module_id: ModuleId( 1, @@ -75,7 +32,6 @@ file:///a.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -112,16 +68,6 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "someName", - }, - ), - }, } file:///b.ts: EsmModuleSymbol { module_id: ModuleId( @@ -137,7 +83,6 @@ file:///b.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -163,16 +108,6 @@ file:///b.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 1, - ): Named( - { - "some-name", - }, - ), - }, } file:///c.ts: EsmModuleSymbol { module_id: ModuleId( @@ -195,7 +130,6 @@ file:///c.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -218,15 +152,45 @@ file:///c.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 2, - ): Named( - { - "MyClass", - }, - ), +} +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_decls: {}, + exports: { + "someOtherName": 0, + }, + re_exports: [], + swc_id_to_symbol_id: {}, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 9, + ), + end: SourcePos( + 38, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "someName", + ), + specifier: "./a.ts", + }, + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, }, } == export definitions == diff --git a/tests/specs/type_tracing/Namespaces01.txt b/tests/specs/symbols/Namespaces01.txt similarity index 97% rename from tests/specs/type_tracing/Namespaces01.txt rename to tests/specs/symbols/Namespaces01.txt index 277ee6c26..abbd282e2 100644 --- a/tests/specs/type_tracing/Namespaces01.txt +++ b/tests/specs/symbols/Namespaces01.txt @@ -57,7 +57,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -114,7 +113,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -138,7 +136,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -179,7 +176,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -203,7 +199,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -263,7 +258,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -324,8 +318,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [Namespace1]: file:///mod.ts:0..62 diff --git a/tests/specs/type_tracing/Namespaces02.txt b/tests/specs/symbols/Namespaces02.txt similarity index 95% rename from tests/specs/type_tracing/Namespaces02.txt rename to tests/specs/symbols/Namespaces02.txt index 5e465f663..a0022fd3a 100644 --- a/tests/specs/type_tracing/Namespaces02.txt +++ b/tests/specs/symbols/Namespaces02.txt @@ -43,7 +43,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -86,7 +85,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -121,7 +119,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -145,7 +142,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -168,8 +164,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [RootNs]: file:///mod.ts:0..114 diff --git a/tests/specs/type_tracing/ReExportJson01.txt b/tests/specs/symbols/ReExportJson01.txt similarity index 79% rename from tests/specs/type_tracing/ReExportJson01.txt rename to tests/specs/symbols/ReExportJson01.txt index 0026ef6c3..9cfc9bf82 100644 --- a/tests/specs/type_tracing/ReExportJson01.txt +++ b/tests/specs/symbols/ReExportJson01.txt @@ -13,6 +13,38 @@ console.log(other); {} # output +file:///bar.json: JsonModuleSymbol { + module_id: ModuleId( + 1, + ), + specifier: "file:///bar.json", + exports: { + "default": 0, + }, + default_symbol: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 0, + ), + end: SourcePos( + 15, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, +} file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( 0, @@ -32,7 +64,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -59,7 +90,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -85,20 +115,17 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///bar.json: JsonModuleSymbol { +file:///non_public.json: JsonModuleSymbol { module_id: ModuleId( - 1, + 2, ), - specifier: "file:///bar.json", + specifier: "file:///non_public.json", exports: { "default": 0, }, default_symbol: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -106,7 +133,7 @@ file:///bar.json: JsonModuleSymbol { 0, ), end: SourcePos( - 15, + 2, ), }, kind: Definition( diff --git a/tests/specs/type_tracing/ReexportExport.txt b/tests/specs/symbols/ReexportExport.txt similarity index 94% rename from tests/specs/type_tracing/ReexportExport.txt rename to tests/specs/symbols/ReexportExport.txt index c5ea5f7aa..511dae622 100644 --- a/tests/specs/type_tracing/ReexportExport.txt +++ b/tests/specs/symbols/ReexportExport.txt @@ -25,7 +25,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -59,8 +58,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [bar]: file:///mod.ts:0..30 diff --git a/tests/specs/type_tracing/TsExternalModuleRef01.txt b/tests/specs/symbols/TsExternalModuleRef01.txt similarity index 95% rename from tests/specs/type_tracing/TsExternalModuleRef01.txt rename to tests/specs/symbols/TsExternalModuleRef01.txt index 894935d58..984ffea88 100644 --- a/tests/specs/type_tracing/TsExternalModuleRef01.txt +++ b/tests/specs/symbols/TsExternalModuleRef01.txt @@ -11,100 +11,6 @@ namespace MyNamespace { export = MyNamespace; # output -file:///mod.ts: EsmModuleSymbol { - module_id: ModuleId( - 0, - ), - specifier: "file:///mod.ts", - child_decls: { - 1, - }, - exports: { - "Test": 1, - }, - re_exports: [], - swc_id_to_symbol_id: { - ( - "A", - #2, - ): 0, - ( - "Test", - #2, - ): 1, - }, - symbols: { - 0: Symbol { - symbol_id: 0, - is_public: false, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 0, - ), - end: SourcePos( - 29, - ), - }, - kind: FileRef( - FileDep { - name: Name( - "default", - ), - specifier: "./a.ts", - }, - ), - }, - ], - deps: {}, - child_decls: {}, - exports: {}, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 31, - ), - end: SourcePos( - 61, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], - deps: { - Id( - ( - "Test", - #2, - ), - ), - QualifiedId( - ( - "A", - #2, - ), - [ - "B", - ], - ), - }, - child_decls: {}, - exports: {}, - }, - }, - traced_re_exports: {}, - traced_referrers: {}, -} file:///a.ts: EsmModuleSymbol { module_id: ModuleId( 1, @@ -130,7 +36,6 @@ file:///a.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -181,7 +86,6 @@ file:///a.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -205,7 +109,6 @@ file:///a.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -236,8 +139,96 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, +} +file:///mod.ts: EsmModuleSymbol { + module_id: ModuleId( + 0, + ), + specifier: "file:///mod.ts", + child_decls: { + 1, + }, + exports: { + "Test": 1, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "A", + #2, + ): 0, + ( + "Test", + #2, + ): 1, + }, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 0, + ), + end: SourcePos( + 29, + ), + }, + kind: FileRef( + FileDep { + name: Name( + "default", + ), + specifier: "./a.ts", + }, + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 31, + ), + end: SourcePos( + 61, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: { + Id( + ( + "Test", + #2, + ), + ), + QualifiedId( + ( + "A", + #2, + ), + [ + "B", + ], + ), + }, + child_decls: {}, + exports: {}, + }, + }, } == export definitions == [Test]: file:///mod.ts:31..61 diff --git a/tests/specs/type_tracing/TsExternalModuleRef02.txt b/tests/specs/symbols/TsExternalModuleRef02.txt similarity index 94% rename from tests/specs/type_tracing/TsExternalModuleRef02.txt rename to tests/specs/symbols/TsExternalModuleRef02.txt index caa35873e..6ef9f272f 100644 --- a/tests/specs/type_tracing/TsExternalModuleRef02.txt +++ b/tests/specs/symbols/TsExternalModuleRef02.txt @@ -11,26 +11,31 @@ namespace MyNamespace { export = MyNamespace; # output -file:///mod.ts: EsmModuleSymbol { +file:///a.ts: EsmModuleSymbol { module_id: ModuleId( - 0, + 1, ), - specifier: "file:///mod.ts", - child_decls: {}, + specifier: "file:///a.ts", + child_decls: { + 0, + }, exports: { - "default": 1, + "default": 2, }, re_exports: [], swc_id_to_symbol_id: { ( - "A", + "MyNamespace", #2, ): 0, + ( + "B", + #3, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -38,55 +43,85 @@ file:///mod.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 29, + 50, ), }, - kind: FileRef( - FileDep { - name: Name( - "default", - ), - specifier: "./a.ts", - }, + kind: Definition( + SymbolNode( + "", + ), ), }, SymbolDecl { range: SourceRange { start: SourcePos( - 46, + 61, ), end: SourcePos( - 47, + 72, ), }, kind: Target( ( - "A", + "MyNamespace", #2, ), ), }, ], - deps: {}, - child_decls: {}, - exports: {}, + deps: { + Id( + ( + "B", + #3, + ), + ), + }, + child_decls: { + 1, + }, + exports: { + "B": 1, + }, }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 31, + 26, ), end: SourcePos( 48, ), }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + 2: Symbol { + symbol_id: 2, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 52, + ), + end: SourcePos( + 73, + ), + }, kind: Target( ( - "A", + "MyNamespace", #2, ), ), @@ -95,7 +130,7 @@ file:///mod.ts: EsmModuleSymbol { deps: { Id( ( - "A", + "MyNamespace", #2, ), ), @@ -104,35 +139,26 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -file:///a.ts: EsmModuleSymbol { +file:///mod.ts: EsmModuleSymbol { module_id: ModuleId( - 1, - ), - specifier: "file:///a.ts", - child_decls: { 0, - }, + ), + specifier: "file:///mod.ts", + child_decls: {}, exports: { - "default": 2, + "default": 1, }, re_exports: [], swc_id_to_symbol_id: { ( - "MyNamespace", + "A", #2, ): 0, - ( - "B", - #3, - ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -140,87 +166,54 @@ file:///a.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 50, + 29, ), }, - kind: Definition( - SymbolNode( - "", - ), + kind: FileRef( + FileDep { + name: Name( + "default", + ), + specifier: "./a.ts", + }, ), }, SymbolDecl { range: SourceRange { start: SourcePos( - 61, + 46, ), end: SourcePos( - 72, + 47, ), }, kind: Target( ( - "MyNamespace", + "A", #2, ), ), }, ], - deps: { - Id( - ( - "B", - #3, - ), - ), - }, - child_decls: { - 1, - }, - exports: { - "B": 1, - }, - }, - 1: Symbol { - symbol_id: 1, - is_public: true, - decls: [ - SymbolDecl { - range: SourceRange { - start: SourcePos( - 26, - ), - end: SourcePos( - 48, - ), - }, - kind: Definition( - SymbolNode( - "", - ), - ), - }, - ], deps: {}, child_decls: {}, exports: {}, }, - 2: Symbol { - symbol_id: 2, - is_public: true, + 1: Symbol { + symbol_id: 1, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 52, + 31, ), end: SourcePos( - 73, + 48, ), }, kind: Target( ( - "MyNamespace", + "A", #2, ), ), @@ -229,7 +222,7 @@ file:///a.ts: EsmModuleSymbol { deps: { Id( ( - "MyNamespace", + "A", #2, ), ), @@ -238,16 +231,6 @@ file:///a.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "default", - }, - ), - }, } == export definitions == [default]: file:///a.ts:0..50 diff --git a/tests/specs/type_tracing/TsNamespaceExport01.txt b/tests/specs/symbols/TsNamespaceExport01.txt similarity index 94% rename from tests/specs/type_tracing/TsNamespaceExport01.txt rename to tests/specs/symbols/TsNamespaceExport01.txt index 572db5a63..214de7c99 100644 --- a/tests/specs/type_tracing/TsNamespaceExport01.txt +++ b/tests/specs/symbols/TsNamespaceExport01.txt @@ -29,7 +29,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -52,8 +51,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [isPrime]: file:///mod.ts:0..56 diff --git a/tests/specs/type_tracing/TsQualifiedName01.txt b/tests/specs/symbols/TsQualifiedName01.txt similarity index 95% rename from tests/specs/type_tracing/TsQualifiedName01.txt rename to tests/specs/symbols/TsQualifiedName01.txt index 63525c2ee..bc2b687d0 100644 --- a/tests/specs/type_tracing/TsQualifiedName01.txt +++ b/tests/specs/symbols/TsQualifiedName01.txt @@ -42,7 +42,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -82,7 +81,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -125,7 +123,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -152,7 +149,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -176,7 +172,6 @@ file:///mod.ts: EsmModuleSymbol { }, 4: Symbol { symbol_id: 4, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -203,7 +198,6 @@ file:///mod.ts: EsmModuleSymbol { }, 5: Symbol { symbol_id: 5, - is_public: false, decls: [ SymbolDecl { range: SourceRange { @@ -226,8 +220,6 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } == export definitions == [Test]: file:///mod.ts:0..37 diff --git a/tests/specs/type_tracing/TypeScriptTypesHeader.txt b/tests/specs/symbols/TypeScriptTypesHeader.txt similarity index 89% rename from tests/specs/type_tracing/TypeScriptTypesHeader.txt rename to tests/specs/symbols/TypeScriptTypesHeader.txt index a8862528a..55b9f8ed6 100644 --- a/tests/specs/type_tracing/TypeScriptTypesHeader.txt +++ b/tests/specs/symbols/TypeScriptTypesHeader.txt @@ -66,7 +66,6 @@ file:///mod.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -93,7 +92,6 @@ file:///mod.ts: EsmModuleSymbol { }, 1: Symbol { symbol_id: 1, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -120,7 +118,6 @@ file:///mod.ts: EsmModuleSymbol { }, 2: Symbol { symbol_id: 2, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -147,7 +144,6 @@ file:///mod.ts: EsmModuleSymbol { }, 3: Symbol { symbol_id: 3, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -189,37 +185,28 @@ file:///mod.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, } -https://localhost/mod.d.ts: EsmModuleSymbol { +file:///other.d.ts: EsmModuleSymbol { module_id: ModuleId( 1, ), - specifier: "https://localhost/mod.d.ts", + specifier: "file:///other.d.ts", child_decls: { 0, - 1, }, exports: { - "MyInterface": 0, - "MyNonPublicInterface": 1, + "MyInterface2": 0, }, re_exports: [], swc_id_to_symbol_id: { ( - "MyInterface", + "MyInterface2", #2, ): 0, - ( - "MyNonPublicInterface", - #2, - ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -227,7 +214,7 @@ https://localhost/mod.d.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 45, + 46, ), }, kind: Definition( @@ -240,13 +227,13 @@ https://localhost/mod.d.ts: EsmModuleSymbol { deps: { Id( ( - "MyInterface", + "MyInterface2", #2, ), ), Id( ( - "a", + "b", #0, ), ), @@ -254,17 +241,48 @@ https://localhost/mod.d.ts: EsmModuleSymbol { child_decls: {}, exports: {}, }, - 1: Symbol { - symbol_id: 1, - is_public: false, + }, +} +file:///other.js: EsmModuleSymbol { + module_id: ModuleId( + 2, + ), + specifier: "file:///other.js", + child_decls: {}, + exports: {}, + re_exports: [], + swc_id_to_symbol_id: {}, + symbols: {}, +} +file:///typescript.ts: EsmModuleSymbol { + module_id: ModuleId( + 3, + ), + specifier: "file:///typescript.ts", + child_decls: { + 0, + }, + exports: { + "MyInterface3": 0, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "MyInterface3", + #2, + ): 0, + }, + symbols: { + 0: Symbol { + symbol_id: 0, decls: [ SymbolDecl { range: SourceRange { start: SourcePos( - 47, + 0, ), end: SourcePos( - 102, + 46, ), }, kind: Definition( @@ -277,13 +295,13 @@ https://localhost/mod.d.ts: EsmModuleSymbol { deps: { Id( ( - "MyNonPublicInterface", + "MyInterface3", #2, ), ), Id( ( - "a1", + "c", #0, ), ), @@ -292,39 +310,34 @@ https://localhost/mod.d.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "MyInterface", - }, - ), - }, } -file:///other.d.ts: EsmModuleSymbol { +https://localhost/mod.d.ts: EsmModuleSymbol { module_id: ModuleId( - 2, + 4, ), - specifier: "file:///other.d.ts", + specifier: "https://localhost/mod.d.ts", child_decls: { 0, + 1, }, exports: { - "MyInterface2": 0, + "MyInterface": 0, + "MyNonPublicInterface": 1, }, re_exports: [], swc_id_to_symbol_id: { ( - "MyInterface2", + "MyInterface", #2, ): 0, + ( + "MyNonPublicInterface", + #2, + ): 1, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -332,7 +345,7 @@ file:///other.d.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 46, + 45, ), }, kind: Definition( @@ -345,13 +358,13 @@ file:///other.d.ts: EsmModuleSymbol { deps: { Id( ( - "MyInterface2", + "MyInterface", #2, ), ), Id( ( - "b", + "a", #0, ), ), @@ -359,40 +372,65 @@ file:///other.d.ts: EsmModuleSymbol { child_decls: {}, exports: {}, }, - }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "MyInterface2", + 1: Symbol { + symbol_id: 1, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 47, + ), + end: SourcePos( + 102, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: { + Id( + ( + "MyNonPublicInterface", + #2, + ), + ), + Id( + ( + "a1", + #0, + ), + ), }, - ), + child_decls: {}, + exports: {}, + }, }, } -file:///typescript.ts: EsmModuleSymbol { +https://localhost/mod.js: EsmModuleSymbol { module_id: ModuleId( - 3, + 5, ), - specifier: "file:///typescript.ts", + specifier: "https://localhost/mod.js", child_decls: { 0, }, exports: { - "MyInterface3": 0, + "Dummy": 0, }, re_exports: [], swc_id_to_symbol_id: { ( - "MyInterface3", + "Dummy", #2, ): 0, }, symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -400,7 +438,7 @@ file:///typescript.ts: EsmModuleSymbol { 0, ), end: SourcePos( - 46, + 21, ), }, kind: Definition( @@ -410,34 +448,11 @@ file:///typescript.ts: EsmModuleSymbol { ), }, ], - deps: { - Id( - ( - "MyInterface3", - #2, - ), - ), - Id( - ( - "c", - #0, - ), - ), - }, + deps: {}, child_decls: {}, exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: { - ModuleId( - 0, - ): Named( - { - "MyInterface3", - }, - ), - }, } == export definitions == [MyClass]: file:///mod.ts:148..223 diff --git a/tests/specs/type_tracing/TypesEntrypoint.txt b/tests/specs/symbols/TypesEntrypoint.txt similarity index 60% rename from tests/specs/type_tracing/TypesEntrypoint.txt rename to tests/specs/symbols/TypesEntrypoint.txt index 6b5081e84..a5ffe897e 100644 --- a/tests/specs/type_tracing/TypesEntrypoint.txt +++ b/tests/specs/symbols/TypesEntrypoint.txt @@ -29,7 +29,6 @@ file:///mod.d.ts: EsmModuleSymbol { symbols: { 0: Symbol { symbol_id: 0, - is_public: true, decls: [ SymbolDecl { range: SourceRange { @@ -65,8 +64,50 @@ file:///mod.d.ts: EsmModuleSymbol { exports: {}, }, }, - traced_re_exports: {}, - traced_referrers: {}, +} +file:///mod.js: EsmModuleSymbol { + module_id: ModuleId( + 1, + ), + specifier: "file:///mod.js", + child_decls: { + 0, + }, + exports: { + "ShouldNotHaveThisInOutput": 0, + }, + re_exports: [], + swc_id_to_symbol_id: { + ( + "ShouldNotHaveThisInOutput", + #2, + ): 0, + }, + symbols: { + 0: Symbol { + symbol_id: 0, + decls: [ + SymbolDecl { + range: SourceRange { + start: SourcePos( + 37, + ), + end: SourcePos( + 78, + ), + }, + kind: Definition( + SymbolNode( + "", + ), + ), + }, + ], + deps: {}, + child_decls: {}, + exports: {}, + }, + }, } == export definitions == [MyInterface]: file:///mod.d.ts:0..45