Skip to content

Commit 7b78996

Browse files
committed
Node positions are now persisted correctly when re-generating the grpahs.
1 parent 23b73b8 commit 7b78996

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/commands/generateDependencyInjectionGraph.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ export class GenerateDependencyInjectionGraph extends ShowHierarchyBase {
9999
project.components.forEach(component => {
100100
let componentFilename = component.filename.replace(this.workspaceDirectory, '.');
101101
componentFilename = componentFilename.split('\\').join('/');
102-
const position = this.graphState.nodePositions[component.name];
103-
appendNodes([new Node(component.name, this.generatedComponentNode(component), componentFilename, false, NodeType.component, position)]);
102+
const componentPosition = this.graphState.nodePositions[component.name];
103+
appendNodes([new Node(component.name, this.generatedComponentNode(component), componentFilename, false, NodeType.component, componentPosition)]);
104104
component.dependencyInjections.forEach(injectable => {
105-
appendNodes([new Node(injectable.name, injectable.name, injectable.filename.replace(this.workspaceDirectory, ''), false, NodeType.injectable)]);
105+
const injectablePosition = this.graphState.nodePositions[injectable.name];
106+
appendNodes([new Node(injectable.name, injectable.name, injectable.filename.replace(this.workspaceDirectory, ''), false, NodeType.injectable, injectablePosition)]);
106107
appendEdges([new Edge((this.edges.length + 1).toString(), injectable.name, component.name, ArrowType.injectable)]);
107108
});
108109
});

src/commands/showComponentHierarchy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export class ShowComponentHierarchy extends ShowHierarchyBase {
8383
private generateDirectedGraphNodes(components: Component[], component: Component, isRoot: boolean, parentSelector: string, appendNodes: (nodeList: Node[]) => void) {
8484
let componentFilename = component.tsFilename.replace(this.directoryPath, '.');
8585
componentFilename = componentFilename.split('\\').join('/');
86-
appendNodes([new Node(component.selector, component.selector, componentFilename, isRoot, isRoot ? NodeType.rootNode : NodeType.component)]);
86+
const componentPosition = this.graphState.nodePositions[component.selector];
87+
appendNodes([new Node(component.selector, component.selector, componentFilename, isRoot, isRoot ? NodeType.rootNode : NodeType.component, componentPosition)]);
8788
if (components.length > 0) {
8889
components.forEach((subComponent) => {
8990
if (parentSelector !== subComponent.selector) {

src/commands/showHierarchyBase.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ export class ShowHierarchyBase extends CommandBase {
129129

130130
protected setGraphState(jsContent: string): string {
131131
if (this.graphState.networkSeed !== undefined) {
132-
// console.log(this.graphState.networkSeed);
133-
// const seedParts = this.graphState.networkSeed.indexOf(':') > 0 ? this.graphState.networkSeed.split(':') : [this.graphState.networkSeed, ''];
134-
// console.log(seedParts);
135-
// jsContent = jsContent.replace('var seed = network.getSeed();', `var seed = ${seedParts[0]};`);
132+
jsContent = jsContent.replace('var seed = network.getSeed();', `var seed = '${this.graphState.networkSeed}';`);
136133
}
137134
return jsContent;
138135
}

src/commands/showModuleHierarchy.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,18 @@ export class ShowModuleHierarchy extends ShowHierarchyBase {
7070
project.modules.forEach(module => {
7171
let moduleFilename = module.filename.replace(this.workspaceDirectory, '.');
7272
moduleFilename = moduleFilename.split('\\').join('/');
73-
appendNodes([new Node(module.moduleName, module.moduleName, moduleFilename, false, NodeType.module)]);
73+
const modulePosition = this.graphState.nodePositions[module.moduleName];
74+
appendNodes([new Node(module.moduleName, module.moduleName, moduleFilename, false, NodeType.module, modulePosition)]);
7475
module.imports.forEach(_import => {
7576
const nodeType = Node.getNodeType(project, _import);
76-
appendNodes([new Node(_import, _import, this.getNodeFilename(_import, nodeType, project), false, nodeType)]);
77+
const importPosition = this.graphState.nodePositions[_import];
78+
appendNodes([new Node(_import, _import, this.getNodeFilename(_import, nodeType, project), false, nodeType, importPosition)]);
7779
appendEdges([new Edge((this.edges.length + 1).toString(), _import, module.moduleName, ArrowType.import)]);
7880
});
7981
module.exports.forEach(_export => {
8082
const nodeType = Node.getNodeType(project, _export);
81-
appendNodes([new Node(_export, _export, this.getNodeFilename(_export, nodeType, project), false, nodeType)]);
83+
const exportPosition = this.graphState.nodePositions[_export];
84+
appendNodes([new Node(_export, _export, this.getNodeFilename(_export, nodeType, project), false, nodeType, exportPosition)]);
8285
appendEdges([new Edge((this.edges.length + 1).toString(), module.moduleName, _export, ArrowType.export)]);
8386
});
8487
});

0 commit comments

Comments
 (0)