@@ -7,42 +7,55 @@ import {
7
7
ScopeTypeInfo ,
8
8
} from "@cursorless/cursorless-engine" ;
9
9
import { VscodeApi } from "@cursorless/vscode-common" ;
10
+ import { CURSORLESS_SCOPE_TREE_VIEW_ID } from "@cursorless/vscode-common" ;
10
11
import { isEqual } from "lodash" ;
11
- import * as vscode from "vscode" ;
12
+ import type {
13
+ Event ,
14
+ ExtensionContext ,
15
+ TreeDataProvider ,
16
+ TreeItemLabel ,
17
+ TreeView ,
18
+ TreeViewVisibilityChangeEvent ,
19
+ } from "vscode" ;
20
+ import {
21
+ EventEmitter ,
22
+ ThemeIcon ,
23
+ TreeItem ,
24
+ TreeItemCollapsibleState ,
25
+ } from "vscode" ;
12
26
import { URI } from "vscode-uri" ;
13
27
import {
14
28
ScopeVisualizer ,
15
29
VisualizationType ,
16
30
} from "./ScopeVisualizerCommandApi" ;
17
31
18
32
export const DONT_SHOW_TALON_UPDATE_MESSAGE_KEY = "dontShowUpdateTalonMessage" ;
19
-
20
- export class ScopeSupportTreeProvider
21
- implements vscode . TreeDataProvider < MyTreeItem >
22
- {
33
+ export class ScopeTreeProvider implements TreeDataProvider < MyTreeItem > {
23
34
private visibleDisposable : Disposer | undefined ;
24
- private treeView : vscode . TreeView < MyTreeItem > ;
35
+ private treeView : TreeView < MyTreeItem > ;
25
36
private supportLevels : ScopeSupportLevels = [ ] ;
26
37
private shownUpdateTalonMessage = false ;
27
38
28
- private _onDidChangeTreeData : vscode . EventEmitter <
39
+ private _onDidChangeTreeData : EventEmitter <
29
40
MyTreeItem | undefined | null | void
30
- > = new vscode . EventEmitter < MyTreeItem | undefined | null | void > ( ) ;
31
- readonly onDidChangeTreeData : vscode . Event <
32
- MyTreeItem | undefined | null | void
33
- > = this . _onDidChangeTreeData . event ;
41
+ > = new EventEmitter < MyTreeItem | undefined | null | void > ( ) ;
42
+ readonly onDidChangeTreeData : Event < MyTreeItem | undefined | null | void > =
43
+ this . _onDidChangeTreeData . event ;
34
44
35
45
constructor (
36
46
private vscodeApi : VscodeApi ,
37
- private context : vscode . ExtensionContext ,
47
+ private context : ExtensionContext ,
38
48
private scopeProvider : ScopeProvider ,
39
49
private scopeVisualizer : ScopeVisualizer ,
40
50
private customSpokenFormGenerator : CustomSpokenFormGenerator ,
41
51
private hasCommandServer : boolean ,
42
52
) {
43
- this . treeView = vscodeApi . window . createTreeView ( "cursorless.scopeSupport" , {
44
- treeDataProvider : this ,
45
- } ) ;
53
+ this . treeView = vscodeApi . window . createTreeView (
54
+ CURSORLESS_SCOPE_TREE_VIEW_ID ,
55
+ {
56
+ treeDataProvider : this ,
57
+ } ,
58
+ ) ;
46
59
47
60
this . context . subscriptions . push (
48
61
this . treeView ,
@@ -53,13 +66,13 @@ export class ScopeSupportTreeProvider
53
66
54
67
static create (
55
68
vscodeApi : VscodeApi ,
56
- context : vscode . ExtensionContext ,
69
+ context : ExtensionContext ,
57
70
scopeProvider : ScopeProvider ,
58
71
scopeVisualizer : ScopeVisualizer ,
59
72
customSpokenFormGenerator : CustomSpokenFormGenerator ,
60
73
hasCommandServer : boolean ,
61
- ) : ScopeSupportTreeProvider {
62
- const treeProvider = new ScopeSupportTreeProvider (
74
+ ) : ScopeTreeProvider {
75
+ const treeProvider = new ScopeTreeProvider (
63
76
vscodeApi ,
64
77
context ,
65
78
scopeProvider ,
@@ -77,7 +90,7 @@ export class ScopeSupportTreeProvider
77
90
}
78
91
}
79
92
80
- onDidChangeVisible ( e : vscode . TreeViewVisibilityChangeEvent ) {
93
+ onDidChangeVisible ( e : TreeViewVisibilityChangeEvent ) {
81
94
if ( e . visible ) {
82
95
if ( this . visibleDisposable != null ) {
83
96
return ;
@@ -197,30 +210,30 @@ export class ScopeSupportTreeProvider
197
210
function getSupportCategories ( ) : SupportCategoryTreeItem [ ] {
198
211
return [
199
212
new SupportCategoryTreeItem (
200
- "Supported and present in editor " ,
213
+ "Present " ,
201
214
ScopeSupport . supportedAndPresentInEditor ,
202
- vscode . TreeItemCollapsibleState . Expanded ,
215
+ TreeItemCollapsibleState . Expanded ,
203
216
) ,
204
217
new SupportCategoryTreeItem (
205
- "Supported but not present in editor " ,
218
+ "Not present" ,
206
219
ScopeSupport . supportedButNotPresentInEditor ,
207
- vscode . TreeItemCollapsibleState . Expanded ,
220
+ TreeItemCollapsibleState . Expanded ,
208
221
) ,
209
222
new SupportCategoryTreeItem (
210
- "Supported using legacy pathways " ,
223
+ "Legacy " ,
211
224
ScopeSupport . supportedLegacy ,
212
- vscode . TreeItemCollapsibleState . Expanded ,
225
+ TreeItemCollapsibleState . Expanded ,
213
226
) ,
214
227
new SupportCategoryTreeItem (
215
228
"Unsupported" ,
216
229
ScopeSupport . unsupported ,
217
- vscode . TreeItemCollapsibleState . Collapsed ,
230
+ TreeItemCollapsibleState . Collapsed ,
218
231
) ,
219
232
] ;
220
233
}
221
234
222
- class ScopeSupportTreeItem extends vscode . TreeItem {
223
- public label : vscode . TreeItemLabel ;
235
+ class ScopeSupportTreeItem extends TreeItem {
236
+ public label : TreeItemLabel ;
224
237
225
238
/**
226
239
* @param scopeTypeInfo The scope type info
@@ -237,7 +250,7 @@ class ScopeSupportTreeItem extends vscode.TreeItem {
237
250
: `"${ scopeTypeInfo . spokenForm . preferred } "` ;
238
251
const description = scopeTypeInfo . humanReadableName ;
239
252
240
- super ( label , vscode . TreeItemCollapsibleState . None ) ;
253
+ super ( label , TreeItemCollapsibleState . None ) ;
241
254
242
255
const requiresTalonUpdate =
243
256
scopeTypeInfo . spokenForm . type === "error" &&
@@ -279,16 +292,16 @@ class ScopeSupportTreeItem extends vscode.TreeItem {
279
292
} ;
280
293
281
294
if ( scopeTypeInfo . isLanguageSpecific ) {
282
- this . iconPath = new vscode . ThemeIcon ( "code" ) ;
295
+ this . iconPath = new ThemeIcon ( "code" ) ;
283
296
}
284
297
}
285
298
}
286
299
287
- class SupportCategoryTreeItem extends vscode . TreeItem {
300
+ class SupportCategoryTreeItem extends TreeItem {
288
301
constructor (
289
302
label : string ,
290
303
public readonly scopeSupport : ScopeSupport ,
291
- collapsibleState : vscode . TreeItemCollapsibleState ,
304
+ collapsibleState : TreeItemCollapsibleState ,
292
305
) {
293
306
super ( label , collapsibleState ) ;
294
307
}
0 commit comments