@@ -16,23 +16,25 @@ import { Settings } from "../settings";
1616import { DataNode } from "./dataNode" ;
1717import { ExplorerNode } from "./explorerNode" ;
1818import { LightWeightNode } from "./lightWeightNode" ;
19+ import { explorerNodeCache } from "./nodeCache/explorerNodeCache" ;
1920import { ProjectNode } from "./projectNode" ;
2021import { WorkspaceNode } from "./workspaceNode" ;
2122
2223export class DependencyDataProvider implements TreeDataProvider < ExplorerNode > {
2324
24- private _onDidChangeTreeData : EventEmitter < null > = new EventEmitter < null > ( ) ;
25+ private _onDidChangeTreeData : EventEmitter < ExplorerNode | null | undefined > = new EventEmitter < ExplorerNode | null | undefined > ( ) ;
2526
2627 // tslint:disable-next-line:member-ordering
27- public onDidChangeTreeData : Event < null > = this . _onDidChangeTreeData . event ;
28+ public onDidChangeTreeData : Event < ExplorerNode | null | undefined > = this . _onDidChangeTreeData . event ;
2829
2930 private _rootItems : ExplorerNode [ ] = null ;
30- private _refreshDelayTrigger : ( ( ) => void ) & _ . Cancelable ;
31+ private _refreshDelayTrigger : ( ( element ?: ExplorerNode ) => void ) & _ . Cancelable ;
3132
3233 constructor ( public readonly context : ExtensionContext ) {
33- context . subscriptions . push ( commands . registerCommand ( Commands . VIEW_PACKAGE_REFRESH , ( debounce ?: boolean ) => this . refreshWithLog ( debounce ) ) ) ;
34+ context . subscriptions . push ( commands . registerCommand ( Commands . VIEW_PACKAGE_REFRESH , ( debounce ?: boolean , element ?: ExplorerNode ) =>
35+ this . refreshWithLog ( debounce , element ) ) ) ;
3436 context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_EXPORT_JAR , ( node : INodeData ) => createJarFile ( node ) ) ) ;
35- context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_REVEAL_FILE_OS , ( node ? : INodeData ) =>
37+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_REVEAL_FILE_OS , ( node : INodeData ) =>
3638 commands . executeCommand ( "revealFileInOS" , Uri . parse ( node . uri ) ) ) ) ;
3739 context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_COPY_FILE_PATH , ( node : INodeData ) =>
3840 commands . executeCommand ( "copyFilePath" , Uri . parse ( node . uri ) ) ) ) ;
@@ -48,16 +50,16 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
4850 this . setRefreshDelay ( ) ;
4951 }
5052
51- public refreshWithLog ( debounce ?: boolean ) {
53+ public refreshWithLog ( debounce ?: boolean , element ?: ExplorerNode ) {
5254 if ( Settings . autoRefresh ( ) ) {
53- this . refresh ( debounce ) ;
55+ this . refresh ( debounce , element ) ;
5456 } else {
55- instrumentOperation ( Commands . VIEW_PACKAGE_REFRESH , ( ) => this . refresh ( debounce ) ) ( ) ;
57+ instrumentOperation ( Commands . VIEW_PACKAGE_REFRESH , ( ) => this . refresh ( debounce , element ) ) ( ) ;
5658 }
5759 }
5860
59- public refresh ( debounce = false ) {
60- this . _refreshDelayTrigger ( ) ;
61+ public refresh ( debounce = false , element ?: ExplorerNode ) {
62+ this . _refreshDelayTrigger ( element ) ;
6163 if ( ! debounce ) { // Immediately refresh
6264 this . _refreshDelayTrigger . flush ( ) ;
6365 }
@@ -70,7 +72,7 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
7072 if ( this . _refreshDelayTrigger ) {
7173 this . _refreshDelayTrigger . cancel ( ) ;
7274 }
73- this . _refreshDelayTrigger = _ . debounce ( ( ) => this . doRefresh ( ) , wait ) ;
75+ this . _refreshDelayTrigger = _ . debounce ( this . doRefresh , wait ) ;
7476 }
7577
7678 public openFile ( uri : string ) {
@@ -107,7 +109,9 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
107109 if ( ! this . _rootItems || ! element ) {
108110 return this . getRootNodes ( ) ;
109111 } else {
110- return element . getChildren ( ) ;
112+ const children : ExplorerNode [ ] = await element . getChildren ( ) ;
113+ explorerNodeCache . saveNodes ( children ) ;
114+ return children ;
111115 }
112116 }
113117
@@ -123,9 +127,9 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
123127 return project ? project . revealPaths ( paths ) : null ;
124128 }
125129
126- private doRefresh ( ) : void {
127- this . _rootItems = null ;
128- this . _onDidChangeTreeData . fire ( ) ;
130+ private doRefresh ( element ?: ExplorerNode ) : void {
131+ explorerNodeCache . removeNodeChildren ( element ) ;
132+ this . _onDidChangeTreeData . fire ( element ) ;
129133 }
130134
131135 private async getRootProjects ( ) : Promise < ExplorerNode [ ] > {
0 commit comments