@@ -25,6 +25,11 @@ export class ShowModuleHierarchy extends ShowHierarchyBase {
25
25
const newGraphState : GraphState = JSON . parse ( message . text ) ;
26
26
this . graphState = newGraphState ;
27
27
this . setNewState ( this . graphState ) ;
28
+ this . nodes . forEach ( node => {
29
+ node . position = this . graphState . nodePositions [ node . id ] ;
30
+ } ) ;
31
+ this . addNodesAndEdges ( project , this . appendNodes , this . appendEdges ) ;
32
+ this . generateAndSaveJavascriptContent ( ( ) => { } ) ;
28
33
return ;
29
34
}
30
35
} ,
@@ -38,6 +43,15 @@ export class ShowModuleHierarchy extends ShowHierarchyBase {
38
43
this . nodes = [ ] ;
39
44
this . edges = [ ] ;
40
45
this . addNodesAndEdges ( project , this . appendNodes , this . appendEdges ) ;
46
+ let htmlContent = this . generateHtmlContent ( webview , this . showModuleHierarchyJsFilename ) ;
47
+ //this.fsUtils.writeFile(this.extensionContext?.asAbsolutePath(path.join('out', ShowComponentHierarchy.Name + '.html')), htmlContent, () => { }); // For debugging
48
+ this . generateAndSaveJavascriptContent ( ( ) => { webview . html = htmlContent ; } ) ;
49
+ if ( errors . length > 0 ) {
50
+ this . showErrors ( errors , `Parsing of ${ errors . length > 1 ? 'some' : 'one' } of the modules failed.\n` ) ;
51
+ }
52
+ }
53
+
54
+ private generateAndSaveJavascriptContent ( callback : ( ) => any ) {
41
55
const nodesJson = this . nodes
42
56
. map ( ( node , index , arr ) => { return node . toJsonString ( ) ; } )
43
57
. join ( ',\n' ) ;
@@ -47,23 +61,15 @@ export class ShowModuleHierarchy extends ShowHierarchyBase {
47
61
48
62
try {
49
63
const jsContent = this . generateJavascriptContent ( nodesJson , edgesJson ) ;
50
- const outputJsFilename = this . showModuleHierarchyJsFilename ;
51
- let htmlContent = this . generateHtmlContent ( webview , this . showModuleHierarchyJsFilename ) ;
52
- //this.fsUtils.writeFile(this.extensionContext?.asAbsolutePath(path.join('out', ShowComponentHierarchy.Name + '.html')), htmlContent, () => { }); // For debugging
53
64
this . fsUtils . writeFile (
54
- this . extensionContext ?. asAbsolutePath ( path . join ( '.' , outputJsFilename ) ) ,
65
+ this . extensionContext ?. asAbsolutePath ( path . join ( '.' , this . showModuleHierarchyJsFilename ) ) ,
55
66
jsContent ,
56
- ( ) => {
57
- webview . html = htmlContent ;
58
- }
67
+ callback
59
68
) ;
60
69
}
61
70
catch ( ex ) {
62
71
console . log ( 'Angular Tools Exception:' + ex ) ;
63
72
}
64
- if ( errors . length > 0 ) {
65
- this . showErrors ( errors , `Parsing of ${ errors . length > 1 ? 'some' : 'one' } of the modules failed.\n` ) ;
66
- }
67
73
}
68
74
69
75
private addNodesAndEdges ( project : Project , appendNodes : ( nodeList : Node [ ] ) => void , appendEdges : ( edgeList : Edge [ ] ) => void ) {
0 commit comments