Skip to content

Commit d6f367e

Browse files
authored
Merge pull request #37 from CodinGame/add-clientoptions-param
Add clientoptions param
2 parents bebc06e + 257a79b commit d6f367e

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/languageClient.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export class LanguageClientManager implements LanguageClient {
3434

3535
constructor (
3636
private id: LanguageClientId,
37-
private languageServerOptions: LanguageClientOptions,
37+
private clientOptions: LanguageClientOptions,
3838
private infrastructure: Infrastructure
3939
) {
40-
this.useMutualizedProxy = this.infrastructure.useMutualizedProxy(this.id, this.languageServerOptions)
40+
this.useMutualizedProxy = this.infrastructure.useMutualizedProxy(this.id, this.clientOptions)
4141
}
4242

4343
private updateStatus (status: Status) {
@@ -85,10 +85,10 @@ export class LanguageClientManager implements LanguageClient {
8585
}
8686

8787
isModelManaged (document: TextDocument): boolean {
88-
if (this.languageServerOptions.documentSelector == null) {
88+
if (this.clientOptions.documentSelector == null) {
8989
return false
9090
}
91-
return Services.get().languages.match(this.languageServerOptions.documentSelector, document)
91+
return Services.get().languages.match(this.clientOptions.documentSelector, document)
9292
}
9393

9494
isDisposed (): boolean {
@@ -132,23 +132,23 @@ export class LanguageClientManager implements LanguageClient {
132132
const languageClient = createLanguageClient(
133133
this.id,
134134
this.infrastructure,
135-
this.languageServerOptions, {
135+
this.clientOptions, {
136136
error: this.handleError,
137137
closed: this.handleClose
138138
}, {
139-
...(this.languageServerOptions.middleware ?? {}),
139+
...(this.clientOptions.middleware ?? {}),
140140
handleDiagnostics: (uri, diagnostics, next) => {
141-
if (this.languageServerOptions.middleware?.handleDiagnostics != null) {
142-
this.languageServerOptions.middleware.handleDiagnostics(uri, diagnostics, next)
141+
if (this.clientOptions.middleware?.handleDiagnostics != null) {
142+
this.clientOptions.middleware.handleDiagnostics(uri, diagnostics, next)
143143
} else {
144144
next(uri, diagnostics)
145145
}
146146
onServerResponse.fire()
147147
},
148148
provideCodeActions: async (document, range, context, token, next) => {
149149
try {
150-
if (this.languageServerOptions.middleware?.provideCodeActions != null) {
151-
return await this.languageServerOptions.middleware.provideCodeActions(document, range, context, token, next)
150+
if (this.clientOptions.middleware?.provideCodeActions != null) {
151+
return await this.clientOptions.middleware.provideCodeActions(document, range, context, token, next)
152152
} else {
153153
return await next(document, range, context, token)
154154
}
@@ -158,8 +158,8 @@ export class LanguageClientManager implements LanguageClient {
158158
},
159159
provideDocumentRangeSemanticTokens: async (document, range, token, next) => {
160160
try {
161-
if (this.languageServerOptions.middleware?.provideDocumentRangeSemanticTokens != null) {
162-
return await this.languageServerOptions.middleware.provideDocumentRangeSemanticTokens(document, range, token, next)
161+
if (this.clientOptions.middleware?.provideDocumentRangeSemanticTokens != null) {
162+
return await this.clientOptions.middleware.provideDocumentRangeSemanticTokens(document, range, token, next)
163163
} else {
164164
return await next(document, range, token)
165165
}
@@ -169,8 +169,8 @@ export class LanguageClientManager implements LanguageClient {
169169
},
170170
provideDocumentSemanticTokens: async (document, token, next) => {
171171
try {
172-
if (this.languageServerOptions.middleware?.provideDocumentSemanticTokens != null) {
173-
return await this.languageServerOptions.middleware.provideDocumentSemanticTokens(document, token, next)
172+
if (this.clientOptions.middleware?.provideDocumentSemanticTokens != null) {
173+
return await this.clientOptions.middleware.provideDocumentSemanticTokens(document, token, next)
174174
} else {
175175
return await next(document, token)
176176
}
@@ -179,8 +179,8 @@ export class LanguageClientManager implements LanguageClient {
179179
}
180180
},
181181
handleWorkDoneProgress: async (token, params, next) => {
182-
if (this.languageServerOptions.middleware?.handleWorkDoneProgress != null) {
183-
this.languageServerOptions.middleware.handleWorkDoneProgress(token, params, next)
182+
if (this.clientOptions.middleware?.handleWorkDoneProgress != null) {
183+
this.clientOptions.middleware.handleWorkDoneProgress(token, params, next)
184184
} else {
185185
next(token, params)
186186
}
@@ -190,8 +190,8 @@ export class LanguageClientManager implements LanguageClient {
190190
},
191191
provideHover: async (document, position, token, next) => {
192192
try {
193-
if (this.languageServerOptions.middleware?.provideHover != null) {
194-
return await this.languageServerOptions.middleware.provideHover(document, position, token, next)
193+
if (this.clientOptions.middleware?.provideHover != null) {
194+
return await this.clientOptions.middleware.provideHover(document, position, token, next)
195195
} else {
196196
return await next(document, position, token)
197197
}
@@ -211,7 +211,7 @@ export class LanguageClientManager implements LanguageClient {
211211
const disposableCollection = new DisposableCollection()
212212

213213
let readyPromise: Promise<void>
214-
const { maxInitializeDuration, readinessMessageMatcher } = this.languageServerOptions
214+
const { maxInitializeDuration, readinessMessageMatcher } = this.clientOptions
215215
if (readinessMessageMatcher != null && !this.useMutualizedProxy) {
216216
readyPromise = new Promise<void>(resolve => {
217217
disposableCollection.push(languageClient.onNotification(LogMessageNotification.type, logMessage => {
@@ -281,26 +281,26 @@ export class LanguageClientManager implements LanguageClient {
281281
*/
282282
function createLanguageClientManager (
283283
id: LanguageClientId,
284-
infrastructure: Infrastructure
284+
infrastructure: Infrastructure,
285+
clientOptions: LanguageClientOptions = getLanguageClientOptions(id)
285286
): LanguageClientManager {
286-
let languageServerOptions = getLanguageClientOptions(id)
287287
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
288-
if (languageServerOptions == null) {
288+
if (clientOptions == null) {
289289
throw new Error(`Unknown ${id} language server`)
290290
}
291291

292-
if (infrastructure.useMutualizedProxy(id, languageServerOptions) && languageServerOptions.mutualizable) {
292+
if (infrastructure.useMutualizedProxy(id, clientOptions) && clientOptions.mutualizable) {
293293
// When using the mutualized proxy, we don't need to synchronize the configuration nor send the initialization options
294-
languageServerOptions = {
295-
...languageServerOptions,
294+
clientOptions = {
295+
...clientOptions,
296296
synchronize: undefined,
297297
initializationOptions: undefined
298298
}
299299
}
300300

301301
updateServices(infrastructure)
302302

303-
return new LanguageClientManager(id, languageServerOptions, infrastructure)
303+
return new LanguageClientManager(id, clientOptions, infrastructure)
304304
}
305305

306306
export {

0 commit comments

Comments
 (0)