4
// Lazily construct the package hierarchy from class names.
5
root: function(classes) {
8
function find(name, data) {
9
var node = map[name], i;
11
node = map[name] = data || {name: name, children: []};
13
node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
14
node.parent.children.push(node);
15
node.key = name.substring(i + 1);
21
classes.forEach(function(d) {
28
// Return a list of imports for the given array of nodes.
29
imports: function(nodes) {
33
// Compute a map from name to node.
34
nodes.forEach(function(d) {
38
// For each import, construct a link from the source to target node.
39
nodes.forEach(function(d) {
40
if (d.imports) d.imports.forEach(function(i) {
41
imports.push({source: map[d.name], target: map[i]});