@@ -31,7 +31,16 @@ import { GradleDependencyProvider } from "./dependencies/GradleDependencyProvide
31
31
import { isLanguageServerStarted , startLanguageServer , syncLanguageServer } from "./languageServer/languageServer" ;
32
32
import { DefaultProjectsTreeDataProvider } from "./views/defaultProject/DefaultProjectsTreeDataProvider" ;
33
33
import { GradleProjectContentProvider } from "./projectContent/GradleProjectContentProvider" ;
34
- import { Context } from "./constant" ;
34
+ import {
35
+ CompletionKinds ,
36
+ Context ,
37
+ GRADLE_BUILD_FILE_CHANGE ,
38
+ GRADLE_BUILD_FILE_OPEN ,
39
+ GRADLE_COMPLETION ,
40
+ GRADLE_PROPERTIES_FILE_CHANGE ,
41
+ VSCODE_TRIGGER_COMPLETION ,
42
+ } from "./constant" ;
43
+ import { instrumentOperation , sendInfo } from "vscode-extension-telemetry-wrapper" ;
35
44
36
45
export class Extension {
37
46
private readonly client : GradleClient ;
@@ -181,6 +190,28 @@ export class Extension {
181
190
}
182
191
} ) ;
183
192
193
+ this . context . subscriptions . push (
194
+ vscode . commands . registerCommand (
195
+ GRADLE_COMPLETION ,
196
+ instrumentOperation ( GRADLE_COMPLETION , async ( operationId : string , ...args : string [ ] ) => {
197
+ if ( args . length === 2 ) {
198
+ const completionKind = args [ 0 ] ;
199
+ const completionContent = args [ 1 ] ;
200
+ sendInfo ( operationId , {
201
+ kind : completionKind ,
202
+ content : completionContent ,
203
+ } ) ;
204
+ if (
205
+ completionKind === CompletionKinds . DEPENDENCY_GROUP ||
206
+ completionKind === CompletionKinds . DEPENDENCY_ARTIFACT
207
+ ) {
208
+ vscode . commands . executeCommand ( VSCODE_TRIGGER_COMPLETION ) ;
209
+ }
210
+ }
211
+ } )
212
+ )
213
+ ) ;
214
+
184
215
void this . activate ( ) ;
185
216
void startLanguageServer ( this . context , this . gradleProjectContentProvider ) ;
186
217
void vscode . commands . executeCommand ( "setContext" , "allowParallelRun" , getAllowParallelRun ( ) ) ;
@@ -258,22 +289,28 @@ export class Extension {
258
289
}
259
290
260
291
private handleWatchEvents ( ) : void {
261
- this . buildFileWatcher . onDidChange ( async ( uri : vscode . Uri ) => {
262
- logger . info ( "Build file changed:" , uri . fsPath ) ;
263
- await this . refresh ( ) ;
264
- void this . syncBuildFile ( uri ) ;
265
- } ) ;
266
- this . buildFileWatcher . onDidOpen ( async ( uri : vscode . Uri ) => {
267
- logger . info ( "Build file opened:" , uri . fsPath ) ;
268
- void this . syncBuildFile ( uri ) ;
269
- } ) ;
270
- this . gradleWrapperWatcher . onDidChange ( async ( uri : vscode . Uri ) => {
271
- logger . info ( "Gradle wrapper properties changed:" , uri . fsPath ) ;
272
- await this . restartServer ( ) ;
273
- if ( isLanguageServerStarted ) {
274
- void vscode . commands . executeCommand ( "gradle.distributionChanged" ) ;
275
- }
276
- } ) ;
292
+ this . buildFileWatcher . onDidChange (
293
+ instrumentOperation ( GRADLE_BUILD_FILE_CHANGE , async ( _operationId : string , uri : vscode . Uri ) => {
294
+ logger . info ( "Build file changed:" , uri . fsPath ) ;
295
+ await this . refresh ( ) ;
296
+ void this . syncBuildFile ( uri ) ;
297
+ } )
298
+ ) ;
299
+ this . buildFileWatcher . onDidOpen (
300
+ instrumentOperation ( GRADLE_BUILD_FILE_OPEN , async ( _operationId : string , uri : vscode . Uri ) => {
301
+ logger . info ( "Build file opened:" , uri . fsPath ) ;
302
+ void this . syncBuildFile ( uri ) ;
303
+ } )
304
+ ) ;
305
+ this . gradleWrapperWatcher . onDidChange (
306
+ instrumentOperation ( GRADLE_PROPERTIES_FILE_CHANGE , async ( _operationId : string , uri : vscode . Uri ) => {
307
+ logger . info ( "Gradle wrapper properties changed:" , uri . fsPath ) ;
308
+ await this . restartServer ( ) ;
309
+ if ( isLanguageServerStarted ) {
310
+ void vscode . commands . executeCommand ( "gradle.distributionChanged" ) ;
311
+ }
312
+ } )
313
+ ) ;
277
314
}
278
315
279
316
private async syncBuildFile ( uri : vscode . Uri ) : Promise < void > {
0 commit comments