Skip to content

Commit

Permalink
import graph nodes link to module source files
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Jun 17, 2024
1 parent eec686f commit eac11d5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/org/rascalmpl/library/lang/rascal/vis/ImportGraph.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,26 @@ void importGraph(PathConfig pcfg, bool hideExternals=true) {
+ { <"_", "_", to> | to <- top(m.imports + m.extends) } // pull up the top modules
+ { <from, "x", "x"> | from <- bottom(m.imports + m.extends), hideExternals ==> from notin m.external} // pull the bottom modules down.
;

showInteractiveContent(graph(g, \layout=defaultDagreLayout()), title="Rascal Import/Extend Graph");

loc modLinker(str name) {
if (loc x <- m.files[name])
return x;
else
return |nothing:///|;
}

default loc modLinker(value _) = |nothing:///|;

showInteractiveContent(graph(g, \layout=defaultDagreLayout(), nodeLinker=modLinker), title="Rascal Import/Extend Graph");
}

@synopsis{Container for everything we need to know about the modules in a project to visualize it.}
data ProjectModel = projectModel(
set[str] modules = {},
set[str] external = {},
rel[str, str] imports = {},
rel[str, str] extends = {}
rel[str, str] extends = {},
rel[str, loc] files = {}
);

@synopsis{Collects name, imports and extends for all modules reachable from the `srcs` root folders.}
Expand All @@ -70,7 +80,8 @@ ProjectModel getProjectModel(list[loc] srcs) {
wholeWorld = projectModel(
modules = {*m.modules | m <- models},
imports = {*m.imports | m <- models},
extends = {*m.extends | m <- models}
extends = {*m.extends | m <- models},
files = {*m.files | m <- models}
);

wholeWorld.external = wholeWorld.imports<1> + wholeWorld.extends<1> - wholeWorld.modules;
Expand All @@ -88,7 +99,8 @@ ProjectModel getProjectModel(loc file) {
return projectModel(
modules = {name},
imports = {name} * imps,
extends = {name} * exts
extends = {name} * exts,
files = {<name, file>}
);
}
catch ParseError(_) :
Expand Down

0 comments on commit eac11d5

Please sign in to comment.