Skip to content

Commit

Permalink
Rename to just Collect
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Nov 5, 2021
1 parent 3e6025b commit 1c6de95
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Expand Up @@ -32,7 +32,7 @@ pub struct Export {
pub loc: SourceLocation,
}

pub struct HoistCollect {
pub struct Collect {
pub source_map: Lrc<swc_common::SourceMap>,
pub decls: HashSet<IdentId>,
pub ignore_mark: Mark,
Expand Down Expand Up @@ -84,21 +84,21 @@ struct ExportedAll {
}

#[derive(Serialize, Debug)]
pub struct HoistCollectResult {
pub struct CollectResult {
imports: Vec<ImportedSymbol>,
exports: Vec<ExportedSymbol>,
exports_all: Vec<ExportedAll>,
}

impl HoistCollect {
impl Collect {
pub fn new(
source_map: Lrc<swc_common::SourceMap>,
decls: HashSet<IdentId>,
ignore_mark: Mark,
global_mark: Mark,
trace_bailouts: bool,
) -> Self {
HoistCollect {
Collect {
source_map,
decls,
ignore_mark,
Expand All @@ -125,9 +125,9 @@ impl HoistCollect {
}
}

impl From<HoistCollect> for HoistCollectResult {
fn from(collect: HoistCollect) -> HoistCollectResult {
HoistCollectResult {
impl From<Collect> for CollectResult {
fn from(collect: Collect) -> CollectResult {
CollectResult {
imports: collect
.imports
.into_iter()
Expand Down Expand Up @@ -191,7 +191,7 @@ macro_rules! collect_visit_fn {
};
}

impl Visit for HoistCollect {
impl Visit for Collect {
fn visit_module(&mut self, node: &Module, _parent: &dyn Node) {
self.in_module_this = true;
self.in_top_level = true;
Expand Down Expand Up @@ -822,7 +822,7 @@ impl Visit for HoistCollect {
}
}

impl HoistCollect {
impl Collect {
pub fn match_require(&self, node: &Expr) -> Option<JsWord> {
match_require(node, &self.decls, self.ignore_mark)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/transformers/js/core/src/fs.rs
@@ -1,5 +1,5 @@
use crate::collect::{Collect, Import};
use crate::dependency_collector::{DependencyDescriptor, DependencyKind};
use crate::hoist_collect::{HoistCollect, Import};
use crate::utils::SourceLocation;
use data_encoding::{BASE64, HEXLOWER};
use std::collections::HashSet;
Expand All @@ -26,7 +26,7 @@ pub fn inline_fs<'a>(
) -> impl Fold + 'a {
InlineFS {
filename: Path::new(filename).to_path_buf(),
collect: HoistCollect::new(
collect: Collect::new(
source_map,
decls,
Mark::fresh(Mark::root()),
Expand All @@ -41,7 +41,7 @@ pub fn inline_fs<'a>(

struct InlineFS<'a> {
filename: PathBuf,
collect: HoistCollect,
collect: Collect,
global_mark: Mark,
project_root: &'a str,
deps: &'a mut Vec<DependencyDescriptor>,
Expand Down
12 changes: 6 additions & 6 deletions packages/transformers/js/core/src/hoist.rs
Expand Up @@ -7,7 +7,7 @@ use swc_common::{sync::Lrc, Mark, Span, SyntaxContext, DUMMY_SP};
use swc_ecmascript::ast::*;
use swc_ecmascript::visit::{Fold, FoldWith, VisitWith};

use crate::hoist_collect::{HoistCollect, Import, ImportKind};
use crate::collect::{Collect, Import, ImportKind};
use crate::id;
use crate::utils::{
match_import, match_member_expr, match_require, CodeHighlight, Diagnostic, DiagnosticSeverity,
Expand All @@ -31,7 +31,7 @@ pub fn hoist(
global_mark: Mark,
trace_bailouts: bool,
) -> Result<(Module, HoistResult, Vec<Diagnostic>), Vec<Diagnostic>> {
let mut collect = HoistCollect::new(source_map, decls, ignore_mark, global_mark, trace_bailouts);
let mut collect = Collect::new(source_map, decls, ignore_mark, global_mark, trace_bailouts);
module.visit_with(&Invalid { span: DUMMY_SP } as _, &mut collect);

let mut hoist = Hoist::new(module_id, &collect);
Expand Down Expand Up @@ -67,7 +67,7 @@ struct ImportedSymbol {

struct Hoist<'a> {
module_id: &'a str,
collect: &'a HoistCollect,
collect: &'a Collect,
module_items: Vec<ModuleItem>,
export_decls: HashSet<JsWord>,
hoisted_imports: Vec<ModuleItem>,
Expand Down Expand Up @@ -95,7 +95,7 @@ pub struct HoistResult {
}

impl<'a> Hoist<'a> {
fn new(module_id: &'a str, collect: &'a HoistCollect) -> Self {
fn new(module_id: &'a str, collect: &'a Collect) -> Self {
Hoist {
module_id,
collect,
Expand Down Expand Up @@ -1124,7 +1124,7 @@ mod tests {
extern crate indoc;
use self::indoc::indoc;

fn parse(code: &str) -> (HoistCollect, String, HoistResult) {
fn parse(code: &str) -> (Collect, String, HoistResult) {
let source_map = Lrc::new(SourceMap::default());
let source_file = source_map.new_source_file(FileName::Anon, code.into());

Expand All @@ -1148,7 +1148,7 @@ mod tests {
let global_mark = Mark::fresh(Mark::root());
let module = module.fold_with(&mut resolver_with_mark(global_mark));

let mut collect = HoistCollect::new(
let mut collect = Collect::new(
source_map.clone(),
collect_decls(&module),
Mark::fresh(Mark::root()),
Expand Down
8 changes: 4 additions & 4 deletions packages/transformers/js/core/src/lib.rs
Expand Up @@ -12,13 +12,13 @@ extern crate serde;
extern crate serde_bytes;
extern crate sha1;

mod collect;
mod decl_collector;
mod dependency_collector;
mod env_replacer;
mod fs;
mod global_replacer;
mod hoist;
mod hoist_collect;
mod modules;
mod utils;

Expand All @@ -45,13 +45,13 @@ use swc_ecmascript::transforms::{
};
use swc_ecmascript::visit::{FoldWith, VisitWith};

use collect::{Collect, CollectResult};
use decl_collector::*;
use dependency_collector::*;
use env_replacer::*;
use fs::inline_fs;
use global_replacer::GlobalReplacer;
use hoist::{hoist, HoistResult};
use hoist_collect::{HoistCollect, HoistCollectResult};
use modules::esm2cjs;
use utils::{CodeHighlight, Diagnostic, DiagnosticSeverity, SourceLocation, SourceType};

Expand Down Expand Up @@ -97,7 +97,7 @@ pub struct TransformResult {
shebang: Option<String>,
dependencies: Vec<DependencyDescriptor>,
hoist_result: Option<HoistResult>,
symbol_result: Option<HoistCollectResult>,
symbol_result: Option<CollectResult>,
diagnostics: Option<Vec<Diagnostic>>,
needs_esm_helpers: bool,
used_env: HashSet<swc_atoms::JsWord>,
Expand Down Expand Up @@ -418,7 +418,7 @@ pub fn transform(config: Config) -> Result<TransformResult, std::io::Error> {
}
}
} else {
let mut symbols_collect = HoistCollect::new(
let mut symbols_collect = Collect::new(
source_map.clone(),
decls,
Mark::fresh(Mark::root()),
Expand Down

0 comments on commit 1c6de95

Please sign in to comment.