forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made browser to expose pylance api. (#20847)
This will let pylance to create LS Client on browser
- Loading branch information
1 parent
0735876
commit 1668d06
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { BaseLanguageClient } from 'vscode-languageclient'; | ||
import { LanguageClient } from 'vscode-languageclient/browser'; | ||
import { PYTHON_LANGUAGE } from '../common/constants'; | ||
|
||
export interface IBrowserExtensionApi { | ||
/** | ||
* @deprecated Temporarily exposed for Pylance until we expose this API generally. Will be removed in an | ||
* iteration or two. | ||
*/ | ||
pylance: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
createClient(...args: any[]): BaseLanguageClient; | ||
start(client: BaseLanguageClient): Promise<void>; | ||
stop(client: BaseLanguageClient): Promise<void>; | ||
}; | ||
} | ||
|
||
export function buildApi(): IBrowserExtensionApi { | ||
const api: IBrowserExtensionApi = { | ||
pylance: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
createClient: (...args: any[]): BaseLanguageClient => | ||
new LanguageClient(PYTHON_LANGUAGE, 'Python Language Server', args[0], args[1]), | ||
start: (client: BaseLanguageClient): Promise<void> => client.start(), | ||
stop: (client: BaseLanguageClient): Promise<void> => client.stop(), | ||
}, | ||
}; | ||
|
||
return api; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters