@@ -60,7 +60,6 @@ export const vscodeApi = (serviceCollection: ServiceCollection): typeof vscode =
60
60
FileSystemError : extHostTypes . FileSystemError ,
61
61
FileType : FileType ,
62
62
Uri : URI ,
63
-
64
63
commands : {
65
64
executeCommand : ( commandId : string , ...args : any [ ] ) : any => {
66
65
return commandService . executeCommand ( commandId , ...args ) ;
@@ -69,7 +68,6 @@ export const vscodeApi = (serviceCollection: ServiceCollection): typeof vscode =
69
68
return CommandsRegistry . registerCommand ( id , command ) ;
70
69
} ,
71
70
} ,
72
-
73
71
window : {
74
72
registerTreeDataProvider : ( id : string , dataProvider : ITreeViewDataProvider ) : void => {
75
73
const view = viewsRegistry . getView ( id ) ;
@@ -81,7 +79,6 @@ export const vscodeApi = (serviceCollection: ServiceCollection): typeof vscode =
81
79
notificationService . error ( message ) ;
82
80
} ,
83
81
} ,
84
-
85
82
workspace : {
86
83
registerFileSystemProvider : ( scheme : string , provider : vscode . FileSystemProvider ) : IDisposable => {
87
84
return fileService . registerProvider ( scheme , new FileSystemProvider ( provider ) ) ;
@@ -95,21 +92,15 @@ export const vscodeApi = (serviceCollection: ServiceCollection): typeof vscode =
95
92
*/
96
93
export const coderApi = ( serviceCollection : ServiceCollection ) : typeof coder => {
97
94
const getService = < T > ( id : ServiceIdentifier < T > ) : T => serviceCollection . get < T > ( id ) as T ;
98
-
99
95
return {
100
96
workbench : {
101
97
action : Action ,
102
98
syncActionDescriptor : SyncActionDescriptor ,
103
99
commandRegistry : CommandsRegistry ,
104
100
actionsRegistry : Registry . as < IWorkbenchActionRegistry > ( ActionExtensions . WorkbenchActions ) ,
105
101
registerView : ( viewId , viewName , containerId , containerName , icon ) : void => {
106
- const viewContainersRegistry = Registry . as < IViewContainersRegistry > ( ViewsExtensions . ViewContainersRegistry ) ;
107
- const viewsRegistry = Registry . as < IViewsRegistry > ( ViewsExtensions . ViewsRegistry ) ;
108
- const container = viewContainersRegistry . registerViewContainer ( containerId ) ;
109
-
110
102
const cssClass = `extensionViewlet-${ containerId } ` ;
111
103
const id = `workbench.view.extension.${ containerId } ` ;
112
-
113
104
class CustomViewlet extends ViewContainerViewlet {
114
105
public constructor (
115
106
@IConfigurationService configurationService : IConfigurationService ,
@@ -127,44 +118,32 @@ export const coderApi = (serviceCollection: ServiceCollection): typeof coder =>
127
118
}
128
119
}
129
120
130
- const viewletDescriptor = new ViewletDescriptor (
131
- CustomViewlet as any ,
132
- id ,
133
- containerName ,
134
- cssClass ,
135
- undefined ,
136
- URI . parse ( icon ) ,
121
+ Registry . as < ViewletRegistry > ( ViewletExtensions . Viewlets ) . registerViewlet (
122
+ new ViewletDescriptor ( CustomViewlet as any , id , containerName , cssClass , undefined , URI . parse ( icon ) ) ,
137
123
) ;
138
124
139
- Registry . as < ViewletRegistry > ( ViewletExtensions . Viewlets ) . registerViewlet ( viewletDescriptor ) ;
140
-
141
- const registry = Registry . as < IWorkbenchActionRegistry > ( ActionExtensions . WorkbenchActions ) ;
142
- registry . registerWorkbenchAction (
125
+ Registry . as < IWorkbenchActionRegistry > ( ActionExtensions . WorkbenchActions ) . registerWorkbenchAction (
143
126
new SyncActionDescriptor ( OpenCustomViewletAction as any , id , localize ( "showViewlet" , "Show {0}" , containerName ) ) ,
144
127
"View: Show {0}" ,
145
128
localize ( "view" , "View" ) ,
146
129
) ;
147
130
148
- // Generate CSS to show the icon in the activity bar
131
+ // Generate CSS to show the icon in the activity bar.
149
132
const iconClass = `.monaco-workbench .activitybar .monaco-action-bar .action-label.${ cssClass } ` ;
150
133
createCSSRule ( iconClass , `-webkit-mask: url('${ icon } ') no-repeat 50% 50%` ) ;
151
134
152
- const views = [ {
135
+ const container = Registry . as < IViewContainersRegistry > ( ViewsExtensions . ViewContainersRegistry ) . registerViewContainer ( containerId ) ;
136
+ Registry . as < IViewsRegistry > ( ViewsExtensions . ViewsRegistry ) . registerViews ( [ {
153
137
id : viewId ,
154
138
name : viewName ,
155
139
ctorDescriptor : { ctor : CustomTreeViewPanel } ,
156
140
treeView : getService ( IInstantiationService ) . createInstance ( CustomTreeView as any , viewId , container ) ,
157
- } ] as ITreeViewDescriptor [ ] ;
158
- viewsRegistry . registerViews ( views , container ) ;
141
+ } ] as ITreeViewDescriptor [ ] , container ) ;
159
142
} ,
160
- // Even though the enums are exactly the same, Typescript says they are
161
- // not assignable to each other, so use `any`. I don't know if there is a
162
- // way around this.
163
143
menuRegistry : MenuRegistry as any ,
164
144
statusbarService : getService ( IStatusbarService ) as any ,
165
145
notificationService : getService ( INotificationService ) ,
166
146
terminalService : getService ( ITerminalService ) ,
167
-
168
147
onFileCreate : ( cb ) : void => {
169
148
getService < IFileService > ( IFileService ) . onAfterOperation ( ( e ) => {
170
149
if ( e . operation === FileOperation . CREATE ) {
@@ -198,7 +177,6 @@ export const coderApi = (serviceCollection: ServiceCollection): typeof coder =>
198
177
}
199
178
} ) ;
200
179
} ,
201
-
202
180
onModelAdded : ( cb ) : void => {
203
181
getService < IModelService > ( IModelService ) . onModelAdded ( ( e ) => {
204
182
cb ( e . uri . path , e . getLanguageIdentifier ( ) . language ) ;
@@ -214,15 +192,13 @@ export const coderApi = (serviceCollection: ServiceCollection): typeof coder =>
214
192
cb ( e . model . uri . path , e . model . getLanguageIdentifier ( ) . language , e . oldModeId ) ;
215
193
} ) ;
216
194
} ,
217
-
218
195
onTerminalAdded : ( cb ) : void => {
219
196
getService < ITerminalService > ( ITerminalService ) . onInstanceCreated ( ( ) => cb ( ) ) ;
220
197
} ,
221
198
onTerminalRemoved : ( cb ) : void => {
222
199
getService < ITerminalService > ( ITerminalService ) . onInstanceDisposed ( ( ) => cb ( ) ) ;
223
200
} ,
224
201
} ,
225
-
226
202
// @ts -ignore
227
203
MenuId : MenuId ,
228
204
Severity : Severity ,
@@ -250,9 +226,7 @@ class FileSystemProvider implements IFileSystemProvider {
250
226
public readonly capabilities : FileSystemProviderCapabilities ;
251
227
public readonly onDidChangeCapabilities : Event < void > = Event . None ;
252
228
253
- public constructor (
254
- private readonly provider : vscode . FileSystemProvider ,
255
- ) {
229
+ public constructor ( private readonly provider : vscode . FileSystemProvider ) {
256
230
this . capabilities = FileSystemProviderCapabilities . Readonly ;
257
231
}
258
232
0 commit comments