@@ -105,7 +105,7 @@ export abstract class Node {
105
105
* @protected _parent
106
106
* `undefined` only if it has no parent (tree root)
107
107
*/
108
- protected _parent : Node | undefined ;
108
+ public _parent : Node | undefined ;
109
109
uri : vscode . Uri ;
110
110
111
111
abstract icon : vscode . ThemeIcon ;
@@ -124,25 +124,48 @@ export abstract class Node {
124
124
*/
125
125
abstract _buildChildren : ( ) => void ;
126
126
127
+ getVisibleChildren ( ) : Node [ ] {
128
+ return OneTreeDataProvider . didHideExtra
129
+ ? this . getChildren ( ) . filter ( ( node ) => ! node . canHide )
130
+ : this . getChildren ( ) ;
131
+ }
132
+
127
133
getChildren ( ) : Node [ ] {
128
134
if ( this . _childNodes ) {
129
135
return this . _childNodes ;
130
136
}
131
137
132
138
this . _buildChildren ( ) ;
139
+
133
140
return this . _childNodes ! ;
134
141
}
135
142
136
143
resetChildren ( ) : void {
137
144
this . _childNodes = undefined ;
138
145
}
139
146
140
- get path ( ) : string {
141
- return this . uri . fsPath ;
147
+ dropChild ( child : Node ) : void {
148
+ this . _childNodes = this . _childNodes ?. filter ( node => node . path !== child . path ) ;
142
149
}
143
150
144
- get parent ( ) : Node | undefined {
145
- return this . _parent ;
151
+ adoptChild ( child :Node ) : void {
152
+ if ( ! this . _childNodes ) {
153
+ this . _childNodes = [ child ] ;
154
+ }
155
+ else {
156
+ this . _childNodes . push ( child ) ;
157
+ }
158
+ }
159
+
160
+ set parent ( adopter : Node ) {
161
+ const dropper = this . _parent ;
162
+ dropper ! . dropChild ( this ) ;
163
+ adopter . adoptChild ( this ) ;
164
+ this . _parent = adopter ;
165
+ }
166
+
167
+ get path ( ) : string {
168
+ return this . uri . fsPath ;
146
169
}
147
170
148
171
get name ( ) : string {
@@ -798,6 +821,17 @@ export class OneTreeDataProvider implements vscode.TreeDataProvider<Node> {
798
821
this . refresh ( undefined , false ) ;
799
822
}
800
823
824
+ init ( ) : void {
825
+ this . _tree = this . _workspaceRoots . map (
826
+ ( root ) =>
827
+ NodeFactory . create (
828
+ NodeType . directory ,
829
+ root . fsPath ,
830
+ undefined
831
+ ) as DirectoryNode
832
+ ) ;
833
+ }
834
+
801
835
/**
802
836
* Refresh the tree under the given Node
803
837
* @command one.explorer.refresh
@@ -1140,7 +1174,7 @@ input_path=${modelName}.${extName}
1140
1174
case NodeType . baseModel :
1141
1175
case NodeType . config :
1142
1176
return new OneNode (
1143
- node . getChildren ( ) . length > 0
1177
+ node . getVisibleChildren ( ) . length > 0
1144
1178
? vscode . TreeItemCollapsibleState . Collapsed
1145
1179
: vscode . TreeItemCollapsibleState . None ,
1146
1180
node
@@ -1161,9 +1195,7 @@ input_path=${modelName}.${extName}
1161
1195
return this . getTree ( ) ;
1162
1196
}
1163
1197
1164
- return OneTreeDataProvider . didHideExtra
1165
- ? element . getChildren ( ) . filter ( ( node ) => ! node . canHide )
1166
- : element . getChildren ( ) ;
1198
+ return element . getVisibleChildren ( ) ;
1167
1199
}
1168
1200
1169
1201
/**
0 commit comments