Skip to content

Commit

Permalink
changed API format
Browse files Browse the repository at this point in the history
  • Loading branch information
heejaechang committed Sep 30, 2022
1 parent 1c3c449 commit d2e4216
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/client/activation/node/languageServerProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ namespace GetExperimentValue {
}

interface PylanceApi {
startClient?(): Promise<void>;
stopClient?(): Promise<void>;
client?: {
start(): Promise<void>;
stop(): Promise<void>;
};
}

export class NodeLanguageServerProxy implements ILanguageServerProxy {
Expand Down Expand Up @@ -101,9 +103,9 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
const extension = await this.getPylanceExtension();
this.lsVersion = extension?.packageJSON.version || '0';

if (extension && (extension.exports as PylanceApi).startClient) {
if (extension && (extension.exports as PylanceApi).client) {
this.pylanceApi = extension.exports as PylanceApi;
await this.pylanceApi.startClient!();
await this.pylanceApi.client!.start();
return;
}

Expand All @@ -126,7 +128,7 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
@traceDecoratorVerbose('Disposing language server')
public async stop(): Promise<void> {
if (this.pylanceApi) {
this.pylanceApi.stopClient!();
this.pylanceApi.client!.stop();
this.pylanceApi = undefined;

return;
Expand Down
12 changes: 7 additions & 5 deletions src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ interface BrowserConfig {
}

interface PylanceApi {
startClient?(): Promise<void>;
stopClient?(): Promise<void>;
client?: {
start(): Promise<void>;
stop(): Promise<void>;
};
}

let languageClient: LanguageClient | undefined;
Expand All @@ -44,7 +46,7 @@ export async function deactivate(): Promise<void> {
const api = pylanceApi;
pylanceApi = undefined;

await api?.stopClient!();
await api?.client!.stop();

const client = languageClient;
languageClient = undefined;
Expand All @@ -60,9 +62,9 @@ async function runPylance(
context.subscriptions.push(createStatusItem());

pylanceExtension = await getActivatedExtension(pylanceExtension);
if ((pylanceExtension.exports as PylanceApi).startClient) {
if ((pylanceExtension.exports as PylanceApi).client) {
pylanceApi = pylanceExtension.exports as PylanceApi;
await pylanceApi.startClient!();
await pylanceApi.client!.start();
return;
}

Expand Down

0 comments on commit d2e4216

Please sign in to comment.