Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vea problem 3 core implementation #350

Merged
merged 16 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,21 @@ impl FileAnalyzer for NpmPackageAnalyzer {
);
add_edge(graph, pkg_name_pop, module_guard, 0);

// reach main exports directly via package name (with precedence)
//
// [pop pkg_name] -1-> [pop "GUARD:EXPORTS"] -> [push "GUARD:EXPORTS"] -> [push main]* -> [push "GUARD:MODULE"] -> [push pkg_internal_name]
//
let exports_guard_pop = add_pop(
graph,
file,
pkg_name_pop,
EXPORTS_GUARD,
"exports_guard_pop",
);
// Common main
let main = Some(npm_pkg.main)
.filter(|main| !main.is_empty())
.and_then(|main| NormalizedRelativePath::from_str(&main))
.map(|p| p.into_path_buf())
.unwrap_or(PathBuf::from("index"))
.with_extension("");

let main_push = add_module_pushes(graph, file, &main, module_guard, "main_push");
let exports_guard_push =
add_push(graph, file, main_push, EXPORTS_GUARD, "exports_guard_push");
add_edge(graph, exports_guard_pop, exports_guard_push, 0);

// reach main directly via package name (with precedence)
//
// [pop pkg_name] -1-> [push main]* -> [push pkg_internal_name]
//
add_edge(graph, pkg_name_pop, main_push, 0);
}

// reach dependencies via package internal name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use stack_graphs::arena::Handle;
use stack_graphs::graph::File;
use stack_graphs::graph::StackGraph;

pub const EXPORTS_GUARD: &str = "GUARD:EXPORTS";
pub const MODULE_GUARD: &str = "GUARD:MODULE";
pub const PKG_GUARD: &str = "GUARD:PKG";
pub const PKG_INTERNAL_GUARD: &str = "GUARD:PKG_INTERNAL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ inherit .return_or_yield
"([^/]+)$" {
attr (module_pop_end) symbol_definition = $1, source_node = @prog
attr (module_pop_end) empty_source_span
attr (module_pop_end) definiens_node = @prog
}
}

Expand Down