Skip to content

Commit

Permalink
save temp
Browse files Browse the repository at this point in the history
  • Loading branch information
heejaechang committed Sep 29, 2022
1 parent f721b7d commit 5443b5e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/client/activation/node/languageServerProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import {
LanguageClientOptions,
} from 'vscode-languageclient/node';

import { IExperimentService, IExtensions, IInterpreterPathService, Resource } from '../../common/types';
import {
IConfigurationService,
IExperimentService,
IExtensions,
IInterpreterPathService,
Resource,
} from '../../common/types';
import { IEnvironmentVariablesProvider } from '../../common/variables/types';
import { PythonEnvironment } from '../../pythonEnvironments/info';
import { captureTelemetry, sendTelemetryEvent } from '../../telemetry';
Expand Down Expand Up @@ -47,6 +53,7 @@ namespace GetExperimentValue {
}
}


export class NodeLanguageServerProxy implements ILanguageServerProxy {
public languageClient: LanguageClient | undefined;

Expand All @@ -56,14 +63,20 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {

private lsVersion: string | undefined;

private usePylanceClient = false;
private pylanceApi
constructor(
private readonly factory: ILanguageClientFactory,
private readonly experimentService: IExperimentService,
private readonly interpreterPathService: IInterpreterPathService,
private readonly environmentService: IEnvironmentVariablesProvider,
private readonly workspace: IWorkspaceService,
private readonly extensions: IExtensions,
) {}
configurationService: IConfigurationService,
) {
this.usePylanceClient = configurationService.getSettings().pylanceLspClientEnabled;
const extension = this.extensions.getExtension(PYLANCE_EXTENSION_ID);
}

private static versionTelemetryProps(instance: NodeLanguageServerProxy) {
return {
Expand All @@ -89,24 +102,28 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
interpreter: PythonEnvironment | undefined,
options: LanguageClientOptions,
): Promise<void> {
const extension = this.extensions.getExtension(PYLANCE_EXTENSION_ID);

this.lsVersion = extension?.packageJSON.version || '0';

this.cancellationStrategy = new FileBasedCancellationStrategy();
options.connectionOptions = { cancellationStrategy: this.cancellationStrategy };
if (this.usePylanceClient) {
await = extension.
} else {
this.cancellationStrategy = new FileBasedCancellationStrategy();
options.connectionOptions = { cancellationStrategy: this.cancellationStrategy };

const client = await this.factory.createLanguageClient(resource, interpreter, options);
this.registerHandlers(client, resource);
const client = await this.factory.createLanguageClient(resource, interpreter, options);
this.registerHandlers(client, resource);

this.disposables.push(
this.workspace.onDidGrantWorkspaceTrust(() => {
client.sendNotification('python/workspaceTrusted', { isTrusted: true });
}),
);
this.disposables.push(
this.workspace.onDidGrantWorkspaceTrust(() => {
client.sendNotification('python/workspaceTrusted', { isTrusted: true });
}),
);

await client.start();
await client.start();

this.languageClient = client;
this.languageClient = client;
}
}

@traceDecoratorVerbose('Disposing language server')
Expand Down
1 change: 1 addition & 0 deletions src/client/languageServer/pylanceLSExtensionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class PylanceLSExtensionManager implements IDisposable, ILanguageServerEx
environmentService,
workspaceService,
extensions,
configurationService,
);
this.serverManager = new NodeLanguageServerManager(
serviceContainer,
Expand Down

0 comments on commit 5443b5e

Please sign in to comment.