Skip to content

Commit d0f5243

Browse files
committed
fix: Make Infrastructure useMutualizedProxy more configurable
1 parent cd5f57a commit d0f5243

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/infrastructure.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as monaco from 'monaco-editor'
55
import type * as vscode from 'vscode'
66
import { getFile, updateFile } from './customRequests'
77
import { LanguageClientManager } from './languageClient'
8-
import { LanguageClientId } from './languageClientOptions'
8+
import { LanguageClientId, LanguageClientOptions } from './languageClientOptions'
99

1010
export interface Infrastructure {
1111
/**
@@ -22,10 +22,11 @@ export interface Infrastructure {
2222
* Workspace folders
2323
*/
2424
workspaceFolders?: typeof vscode.workspace.workspaceFolders
25+
2526
/**
26-
* The language server proxy is used, so we only need to load configurations for language servers which are not mutualized
27+
* Does a mutualization proxy will be used, it means we don't need to load configurations for this server
2728
*/
28-
useMutualizedProxy: boolean
29+
useMutualizedProxy (languageClientId: LanguageClientId, options: LanguageClientOptions): boolean
2930

3031
/**
3132
* Save a file on the filesystem
@@ -74,7 +75,7 @@ export abstract class CodinGameInfrastructure implements Infrastructure {
7475
* The domain of the server
7576
*/
7677
public serverAddress: string,
77-
public useMutualizedProxy: boolean,
78+
private _useMutualizedProxy: boolean,
7879
/**
7980
* An optional sessionId when connecting to the session-mutualized server
8081
*/
@@ -86,6 +87,10 @@ export abstract class CodinGameInfrastructure implements Infrastructure {
8687
) {
8788
}
8889

90+
useMutualizedProxy (languageClientId: LanguageClientId, options: LanguageClientOptions): boolean {
91+
return this._useMutualizedProxy && options.mutualizable
92+
}
93+
8994
public readonly automaticTextDocumentUpdate = false
9095
public readonly rootUri = 'file:///tmp/project'
9196
public readonly workspaceFolders: typeof vscode.workspace.workspaceFolders = [{

src/languageClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class LanguageClientManager implements LanguageClient {
109109

110110
public async start (): Promise<void> {
111111
try {
112-
await loadExtensionConfigurations([this.id], this.infrastructure.useMutualizedProxy)
112+
await loadExtensionConfigurations([this.id], this.infrastructure.useMutualizedProxy(this.id, this.languageServerOptions))
113113
} catch (error) {
114114
console.error('Unable to load extension configuration', error)
115115
}
@@ -268,7 +268,7 @@ function createLanguageClientManager (
268268
throw new Error(`Unknown ${id} language server`)
269269
}
270270

271-
if (infrastructure.useMutualizedProxy && languageServerOptions.mutualizable) {
271+
if (infrastructure.useMutualizedProxy(id, languageServerOptions) && languageServerOptions.mutualizable) {
272272
// When using the mutualized proxy, we don't need to synchronize the configuration nor send the initialization options
273273
languageServerOptions = {
274274
...languageServerOptions,

src/tests/tools.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'vscode-languageserver/lib/common/api'
99
import { monaco } from '@codingame/monaco-editor-wrapper'
1010
import { getFile, updateFile } from '../customRequests'
11-
import { Infrastructure, LanguageClientManager, TextDocument, TextDocumentSaveReason } from '../'
11+
import { Infrastructure, LanguageClientId, LanguageClientManager, LanguageClientOptions, TextDocument, TextDocumentSaveReason } from '../'
1212

1313
class PipedMessageReader extends AbstractMessageReader {
1414
private callback: DataCallback | undefined
@@ -121,9 +121,13 @@ export class TestInfrastructure implements Infrastructure {
121121

122122
constructor (
123123
public automaticTextDocumentUpdate: boolean,
124-
public useMutualizedProxy: boolean
124+
public _useMutualizedProxy: boolean
125125
) {}
126126

127+
useMutualizedProxy (languageClientId: LanguageClientId, options: LanguageClientOptions): boolean {
128+
return this._useMutualizedProxy && options.mutualizable
129+
}
130+
127131
rootUri = 'file:///tmp/project'
128132
workspaceFolders = []
129133

0 commit comments

Comments
 (0)