1
1
import * as vscode from 'vscode' ;
2
2
import * as path from 'path' ;
3
3
import { func } from 'vscode-languageclient/lib/utils/is' ;
4
+ import { strict } from 'assert' ;
5
+ import { Func } from 'mocha' ;
4
6
5
7
6
8
const iconsRootPath = path . join ( path . dirname ( __dirname ) , '..' , 'resources' , 'icons' ) ;
@@ -10,17 +12,20 @@ function getIconUri(iconName: string, theme: string): vscode.Uri {
10
12
}
11
13
12
14
interface Workspace {
15
+ id : string ,
13
16
crates : Crate [ ] ,
14
17
location : string ,
15
18
}
16
19
17
20
interface Crate {
21
+ id : string ,
18
22
name : string ,
19
23
modules : Module [ ] ,
20
24
location : string ,
21
25
}
22
26
23
27
interface Module {
28
+ id : string ,
24
29
name : string ,
25
30
modules ?: Module [ ] ,
26
31
targets ?: Function [ ] ,
@@ -33,17 +38,13 @@ enum TestKind {
33
38
}
34
39
35
40
interface Function {
41
+ id : string ,
36
42
name : string ,
37
43
location : string ,
38
44
kind : TestKind ,
39
45
}
40
46
41
- class Workspace extends vscode . TreeItem {
42
- get tooltip ( ) : string {
43
- // @ts -ignore
44
- return super . label ;
45
- }
46
-
47
+ class Workspace extends vscode . TreeItem {
47
48
get description ( ) : string {
48
49
return this . location ;
49
50
}
@@ -60,15 +61,14 @@ class Workspace extends vscode.TreeItem {
60
61
61
62
class Crate extends vscode . TreeItem {
62
63
constructor (
64
+ id : string ,
63
65
name : string ,
64
66
modules : Module [ ] ,
67
+ location : string ,
65
68
) {
66
69
super ( name , vscode . TreeItemCollapsibleState . Collapsed ) ;
67
- }
68
-
69
- get tooltip ( ) : string {
70
- // @ts -ignore
71
- return super . label ;
70
+ this . location = location ;
71
+ this . id = id ;
72
72
}
73
73
74
74
get description ( ) : string {
@@ -87,20 +87,17 @@ class Crate extends vscode.TreeItem {
87
87
88
88
class Module extends vscode . TreeItem {
89
89
constructor (
90
+ id : string ,
90
91
name : string ,
91
92
location : string ,
92
93
modules ?: Module [ ] ,
93
94
targets ?: Function [ ] ,
94
95
) {
95
96
super ( name , vscode . TreeItemCollapsibleState . Collapsed ) ;
96
97
this . location = location ;
98
+ this . id = id ;
97
99
}
98
100
99
- get tooltip ( ) : string {
100
- // @ts -ignore
101
- return super . label ;
102
- }
103
-
104
101
get description ( ) : string {
105
102
return this . location ;
106
103
}
@@ -124,12 +121,14 @@ class Module extends vscode.TreeItem {
124
121
125
122
class Function extends vscode . TreeItem {
126
123
constructor (
124
+ id : string ,
127
125
name : string ,
128
126
location : string ,
129
127
kind : TestKind ,
130
128
) {
131
129
super ( name , vscode . TreeItemCollapsibleState . None ) ;
132
130
this . location = location ;
131
+ this . id = id ;
133
132
134
133
switch ( kind ) {
135
134
case TestKind . Bench : {
@@ -148,12 +147,7 @@ class Function extends vscode.TreeItem {
148
147
}
149
148
}
150
149
}
151
-
152
- get tooltip ( ) : string {
153
- // @ts -ignore
154
- return super . label ;
155
- }
156
-
150
+
157
151
get description ( ) : string {
158
152
return this . location ;
159
153
}
@@ -163,35 +157,107 @@ class Function extends vscode.TreeItem {
163
157
}
164
158
}
165
159
166
- type Executable = Workspace | Crate | Module | Function ;
160
+ type Node = Workspace | Crate | Module | Function ;
161
+
162
+ function bfs ( root : Node , process : ( node : Node ) => void ) {
163
+ let queue : Array < Node > = [ root ] ;
164
+ while ( queue . length != 0 ) {
165
+ let current = queue . pop ( ) ;
166
+ //@ts -ignore
167
+ process ( current ) ;
168
+ //@ts -ignore
169
+ current . getChildren ( ) ;
170
+ }
171
+ }
167
172
168
- export class RunnableProvider implements vscode . TreeDataProvider < Executable > {
169
- // private changesEmitter : vscode.EventEmitter<Executable | undefined> = new vscode.EventEmitter<Executable | undefined>();
170
- // readonly onDidChangeTreeData: vscode.Event<Executable | undefined> = this.changesEmitter .event;
173
+ export class RunnableDataProvider implements vscode . TreeDataProvider < Node > {
174
+ private _onDidChangeTreeData : vscode . EventEmitter < Node | undefined > = new vscode . EventEmitter < Node | undefined > ( )
175
+ readonly onDidChangeTreeData : vscode . Event < Node | undefined > = this . _onDidChangeTreeData . event ;
171
176
172
- getChildren ( element ?: Executable ) : vscode . ProviderResult < Executable [ ] > {
177
+ getChildren ( element ?: Node ) : vscode . ProviderResult < Node [ ] > {
173
178
if ( element == undefined ) {
174
179
return Promise . resolve ( [ ] ) ;
175
180
}
176
181
177
182
return element . getChildren ( ) ;
178
183
}
179
184
180
- getTreeItem ( element : Executable ) : Executable {
185
+ getTreeItem ( element : Node ) : Node {
181
186
return element ;
182
187
}
183
188
}
184
189
185
- function runExecutable ( ) {
186
-
190
+ export class RunnableView {
191
+ private dataProvider : RunnableDataProvider ;
192
+ private data : Node ;
193
+
194
+ constructor ( context : vscode . ExtensionContext ) {
195
+ this . dataProvider = new RunnableDataProvider ( )
196
+ }
197
+
198
+ public applyUpdate ( deltaUpdate : Patch [ ] ) {
199
+ deltaUpdate . map ( ( patch ) => {
200
+ switch ( patch . kind ) {
201
+ case PatchKind . Create :
202
+ find ( patch . targetId ) ;
203
+ break ;
204
+ case PatchKind . Delete :
205
+ find ( ) ;
206
+ break ;
207
+ case PatchKind . Update :
208
+ find ( ) ;
209
+ break ;
210
+ }
211
+ } ) ;
212
+ }
187
213
}
188
214
189
- function goToDefinition ( ) {
190
- vscode . workspace . openTextDocument ( ) . then ( ( document ) => {
191
- vscode . window . activeTextEditor ?. revealRange ( ) ;
192
- } ) ;
215
+ /// The view synchronized with RA data by delta updates. The update is an array
216
+ /// of elementary actions called a `Patch`. After applying an update to the tree
217
+ /// it will become synchronized.
218
+
219
+ type Patch = Delete | Update | Create ;
220
+
221
+ enum PatchKind {
222
+ Delete = "DELETE" ,
223
+ Update = "UPDATE" ,
224
+ Create = "CREATE"
225
+ }
226
+
227
+ interface Delete {
228
+ kind : PatchKind . Delete ,
229
+ id : string ,
193
230
}
194
231
232
+ interface Update {
233
+ kind : PatchKind . Update ,
234
+ payload : {
235
+ name ?: string ,
236
+ location ?: string ,
237
+ kind ?: TestKind ,
238
+ } ,
239
+ }
240
+
241
+ interface Create {
242
+ kind : PatchKind . Create ,
243
+ targetId : string ,
244
+ payload : Node ,
245
+ }
246
+
247
+ // function runExecutable() {
248
+ // // TODO: implement
249
+ // }
250
+
251
+ // function goToDefinition() {
252
+ // vscode.workspace.openTextDocument().then((document)=>{
253
+ // vscode.window.activeTextEditor?.revealRange();
254
+ // });
255
+ // }
256
+ // Для Workspace и Crate show in explorer
257
+
258
+ // TODO: возможность создавать run lists
259
+ // TODO: Run History
260
+
195
261
196
262
197
263
0 commit comments