Skip to content

Commit a3b6f09

Browse files
committed
Enhance dependency graph and utils with additional arithmetic functions
- Updated `create_focused_graph` and `count_value_usage_in_dependents` to include the center module in the list of dependents, ensuring unique entries. - Added `divide`, `sutract`, and `triple` functions to `utils.res` and `utils.bs.js` for improved arithmetic operations. - Exported new functions in `utils.bs.js` to make them available for use.
1 parent d9be09d commit a3b6f09

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

lib/dependency_graph.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ let create_focused_graph graph center_module =
287287
let center_deps = get_dependencies graph center_module in
288288

289289
(* 2. Get modules that depend on the center module (its dependents) *)
290-
let dependents = find_dependents graph center_module in
290+
let dependents =
291+
List.sort_uniq String.compare
292+
(center_module :: find_dependents graph center_module)
293+
in
291294

292295
(* 3. Start building a new graph with just the center module *)
293296
(* Preserve metadata - add center module *)
@@ -340,7 +343,10 @@ let find_modules_with_no_dependents graph =
340343
let count_value_usage_in_dependents graph ~module_name ~value_name =
341344
let open Stdlib in
342345
let open Cmt_format in
343-
let dependents = find_dependents graph module_name in
346+
let dependents =
347+
List.sort_uniq String.compare
348+
(module_name :: find_dependents graph module_name)
349+
in
344350
let find_cmt_path file_path =
345351
let cmt_path =
346352
Parser.DependencyExtractor.get_cmt_path_for_source file_path

test/rescript/src/utils.bs.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/rescript/src/utils.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ let add = (a, b) => a + b
22
let multiply = (a, b) => a * b
33
let divide = (a, b) => a / b
44
let sutract = (a, b) => a - b
5+
let triple = x => multiply(x, 3)

0 commit comments

Comments
 (0)