Skip to content

Commit 5d49f9b

Browse files
Merge pull request #350 from github/vea_problem_3_core_implementation
Vea problem 3 core implementation
2 parents 728cc58 + 117c202 commit 5d49f9b

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

languages/tree-sitter-stack-graphs-javascript/rust/npm_package.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,21 @@ impl FileAnalyzer for NpmPackageAnalyzer {
111111
);
112112
add_edge(graph, pkg_name_pop, module_guard, 0);
113113

114-
// reach main exports directly via package name (with precedence)
115-
//
116-
// [pop pkg_name] -1-> [pop "GUARD:EXPORTS"] -> [push "GUARD:EXPORTS"] -> [push main]* -> [push "GUARD:MODULE"] -> [push pkg_internal_name]
117-
//
118-
let exports_guard_pop = add_pop(
119-
graph,
120-
file,
121-
pkg_name_pop,
122-
EXPORTS_GUARD,
123-
"exports_guard_pop",
124-
);
114+
// Common main
125115
let main = Some(npm_pkg.main)
126116
.filter(|main| !main.is_empty())
127117
.and_then(|main| NormalizedRelativePath::from_str(&main))
128118
.map(|p| p.into_path_buf())
129119
.unwrap_or(PathBuf::from("index"))
130120
.with_extension("");
121+
131122
let main_push = add_module_pushes(graph, file, &main, module_guard, "main_push");
132-
let exports_guard_push =
133-
add_push(graph, file, main_push, EXPORTS_GUARD, "exports_guard_push");
134-
add_edge(graph, exports_guard_pop, exports_guard_push, 0);
123+
124+
// reach main directly via package name (with precedence)
125+
//
126+
// [pop pkg_name] -1-> [push main]* -> [push pkg_internal_name]
127+
//
128+
add_edge(graph, pkg_name_pop, main_push, 0);
135129
}
136130

137131
// reach dependencies via package internal name

languages/tree-sitter-stack-graphs-javascript/rust/util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use stack_graphs::arena::Handle;
1414
use stack_graphs::graph::File;
1515
use stack_graphs::graph::StackGraph;
1616

17-
pub const EXPORTS_GUARD: &str = "GUARD:EXPORTS";
1817
pub const MODULE_GUARD: &str = "GUARD:MODULE";
1918
pub const PKG_GUARD: &str = "GUARD:PKG";
2019
pub const PKG_INTERNAL_GUARD: &str = "GUARD:PKG_INTERNAL";

languages/tree-sitter-stack-graphs-javascript/src/stack-graphs.tsg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ inherit .return_or_yield
326326
"([^/]+)$" {
327327
attr (module_pop_end) symbol_definition = $1, source_node = @prog
328328
attr (module_pop_end) empty_source_span
329+
attr (module_pop_end) definiens_node = @prog
329330
}
330331
}
331332

0 commit comments

Comments
 (0)