@@ -34,52 +34,13 @@ import { IServerOptions } from './utils/configuration.js';
34
34
import { TypeScriptAutoFixProvider } from './features/fix-all.js' ;
35
35
import { TypeScriptInlayHintsProvider } from './features/inlay-hints.js' ;
36
36
import { SourceDefinitionCommand } from './features/source-definition.js' ;
37
- import { LspClient } from './lsp-client.js' ;
38
37
import { TypeScriptVersion , TypeScriptVersionProvider } from './tsServer/versionProvider.js' ;
39
38
import { Position , Range } from './utils/typeConverters.js' ;
40
39
import { CodeActionKind } from './utils/types.js' ;
41
40
import { ConfigurationManager } from './configuration-manager.js' ;
42
41
43
- class ServerInitializingIndicator {
44
- private _loadingProjectName ?: string ;
45
- private _progressReporter ?: lsp . WorkDoneProgressReporter ;
46
-
47
- constructor ( private lspClient : LspClient ) { }
48
-
49
- public reset ( ) : void {
50
- if ( this . _loadingProjectName ) {
51
- this . _loadingProjectName = undefined ;
52
- if ( this . _progressReporter ) {
53
- this . _progressReporter . done ( ) ;
54
- this . _progressReporter = undefined ;
55
- }
56
- }
57
- }
58
-
59
- public async startedLoadingProject ( projectName : string ) : Promise < void > {
60
- // TS projects are loaded sequentially. Cancel existing task because it should always be resolved before
61
- // the incoming project loading task is.
62
- this . reset ( ) ;
63
-
64
- this . _loadingProjectName = projectName ;
65
- this . _progressReporter = await this . lspClient . createProgressReporter ( ) ;
66
- this . _progressReporter . begin ( 'Initializing JS/TS language features…' ) ;
67
- }
68
-
69
- public finishedLoadingProject ( projectName : string ) : void {
70
- if ( this . _loadingProjectName === projectName ) {
71
- this . _loadingProjectName = undefined ;
72
- if ( this . _progressReporter ) {
73
- this . _progressReporter . done ( ) ;
74
- this . _progressReporter = undefined ;
75
- }
76
- }
77
- }
78
- }
79
-
80
42
export class LspServer {
81
43
private _tspClient : TspClient | null = null ;
82
- private _loadingIndicator : ServerInitializingIndicator | null = null ;
83
44
private initializeParams : TypeScriptInitializeParams | null = null ;
84
45
private diagnosticQueue ?: DiagnosticEventQueue ;
85
46
private configurationManager : ConfigurationManager ;
@@ -106,10 +67,6 @@ export class LspServer {
106
67
this . _tspClient . shutdown ( ) ;
107
68
this . _tspClient = null ;
108
69
}
109
- if ( this . _loadingIndicator ) {
110
- this . _loadingIndicator . reset ( ) ;
111
- this . _loadingIndicator = null ;
112
- }
113
70
}
114
71
115
72
private get tspClient ( ) : TspClient {
@@ -119,13 +76,6 @@ export class LspServer {
119
76
return this . _tspClient ;
120
77
}
121
78
122
- private get loadingIndicator ( ) : ServerInitializingIndicator {
123
- if ( ! this . _loadingIndicator ) {
124
- throw new Error ( 'Loading indicator not created. Did you forget to send the "initialize" request?' ) ;
125
- }
126
- return this . _loadingIndicator ;
127
- }
128
-
129
79
private findTypescriptVersion ( ) : TypeScriptVersion | null {
130
80
const typescriptVersionProvider = new TypeScriptVersionProvider ( this . options , this . logger ) ;
131
81
// User-provided tsserver path.
@@ -158,7 +108,6 @@ export class LspServer {
158
108
}
159
109
this . initializeParams = params ;
160
110
const clientCapabilities = this . initializeParams . capabilities ;
161
- this . _loadingIndicator = new ServerInitializingIndicator ( this . options . lspClient ) ;
162
111
this . workspaceRoot = this . initializeParams . rootUri ? uriToPath ( this . initializeParams . rootUri ) : this . initializeParams . rootPath || undefined ;
163
112
164
113
const userInitializationOptions : TypeScriptInitializationOptions = this . initializeParams . initializationOptions || { } ;
@@ -218,8 +167,8 @@ export class LspServer {
218
167
this . logger ,
219
168
) ;
220
169
this . _tspClient = new TspClient ( {
221
- apiVersion : typescriptVersion . version || API . defaultVersion ,
222
- tsserverPath : typescriptVersion . tsServerPath ,
170
+ lspClient : this . options . lspClient ,
171
+ typescriptVersion,
223
172
logFile,
224
173
logVerbosity,
225
174
disableAutomaticTypingAcquisition,
@@ -400,7 +349,7 @@ export class LspServer {
400
349
401
350
const { files } = this . documents ;
402
351
try {
403
- return await this . tspClient . request ( CommandTypes . Geterr , { delay : 0 , files } , this . diagnosticsTokenSource . token ) ;
352
+ return await this . tspClient . requestGeterr ( { delay : 0 , files } , this . diagnosticsTokenSource . token ) ;
404
353
} finally {
405
354
if ( this . diagnosticsTokenSource === geterrTokenSource ) {
406
355
this . diagnosticsTokenSource = undefined ;
@@ -1176,18 +1125,8 @@ export class LspServer {
1176
1125
}
1177
1126
1178
1127
protected async onTsEvent ( event : protocol . Event ) : Promise < void > {
1179
- if ( event . event === EventTypes . SementicDiag ||
1180
- event . event === EventTypes . SyntaxDiag ||
1181
- event . event === EventTypes . SuggestionDiag ) {
1128
+ if ( event . event === EventTypes . SementicDiag || event . event === EventTypes . SyntaxDiag || event . event === EventTypes . SuggestionDiag ) {
1182
1129
this . diagnosticQueue ?. updateDiagnostics ( event . event , event as tsp . DiagnosticEvent ) ;
1183
- } else if ( event . event === EventTypes . ProjectLoadingStart ) {
1184
- await this . loadingIndicator . startedLoadingProject ( ( event as tsp . ProjectLoadingStartEvent ) . body . projectName ) ;
1185
- } else if ( event . event === EventTypes . ProjectLoadingFinish ) {
1186
- this . loadingIndicator . finishedLoadingProject ( ( event as tsp . ProjectLoadingFinishEvent ) . body . projectName ) ;
1187
- } else {
1188
- this . logger . log ( 'Ignored event' , {
1189
- event : event . event ,
1190
- } ) ;
1191
1130
}
1192
1131
}
1193
1132
0 commit comments