Skip to content

Commit

Permalink
Merge pull request #350 from github/vea_problem_3_core_implementation
Browse files Browse the repository at this point in the history
Vea problem 3 core implementation
  • Loading branch information
BekaValentine authored Nov 17, 2023
2 parents 728cc58 + 117c202 commit 5d49f9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions languages/tree-sitter-stack-graphs-javascript/rust/npm_package.rs
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
1 change: 0 additions & 1 deletion languages/tree-sitter-stack-graphs-javascript/rust/util.rs
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

0 comments on commit 5d49f9b

Please sign in to comment.