-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old Pylance-related code (microsoft/vscode-python#22985)
Part of microsoft/vscode-jupyter#14977 Removes some effectively dead code that would only be used by very old (year+) versions of Pylance. This logic has all been moved into vscode-pylance: - Middleware to make the interactive window input box look like a notebook cell - Call to Jupyter to get pythonpath for notebooks. - Configuration hook to get `[python]` value of `editor.formatOnType`. - LSP notebook experiment
- Loading branch information
Showing
9 changed files
with
4 additions
and
558 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
87 changes: 2 additions & 85 deletions
87
extensions/positron-python/src/client/activation/node/languageClientMiddleware.ts
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 |
---|---|---|
@@ -1,104 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { Uri } from 'vscode'; | ||
import { ConfigurationItem, LanguageClient, LSPObject } from 'vscode-languageclient/node'; | ||
import { IJupyterExtensionDependencyManager, IWorkspaceService } from '../../common/application/types'; | ||
import { IJupyterExtensionDependencyManager } from '../../common/application/types'; | ||
import { IServiceContainer } from '../../ioc/types'; | ||
import { JupyterExtensionIntegration } from '../../jupyter/jupyterIntegration'; | ||
import { traceLog } from '../../logging'; | ||
import { LanguageClientMiddleware } from '../languageClientMiddleware'; | ||
import { LspInteractiveWindowMiddlewareAddon } from './lspInteractiveWindowMiddlewareAddon'; | ||
|
||
import { LanguageServerType } from '../types'; | ||
|
||
import { LspNotebooksExperiment } from './lspNotebooksExperiment'; | ||
|
||
export class NodeLanguageClientMiddleware extends LanguageClientMiddleware { | ||
private readonly lspNotebooksExperiment: LspNotebooksExperiment; | ||
|
||
private readonly jupyterExtensionIntegration: JupyterExtensionIntegration; | ||
|
||
private readonly workspaceService: IWorkspaceService; | ||
|
||
public constructor( | ||
serviceContainer: IServiceContainer, | ||
private getClient: () => LanguageClient | undefined, | ||
serverVersion?: string, | ||
) { | ||
public constructor(serviceContainer: IServiceContainer, serverVersion?: string) { | ||
super(serviceContainer, LanguageServerType.Node, serverVersion); | ||
|
||
this.workspaceService = serviceContainer.get<IWorkspaceService>(IWorkspaceService); | ||
|
||
this.lspNotebooksExperiment = serviceContainer.get<LspNotebooksExperiment>(LspNotebooksExperiment); | ||
this.setupHidingMiddleware(serviceContainer); | ||
|
||
this.jupyterExtensionIntegration = serviceContainer.get<JupyterExtensionIntegration>( | ||
JupyterExtensionIntegration, | ||
); | ||
if (!this.notebookAddon) { | ||
this.notebookAddon = new LspInteractiveWindowMiddlewareAddon( | ||
this.getClient, | ||
this.jupyterExtensionIntegration, | ||
); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
protected shouldCreateHidingMiddleware(_: IJupyterExtensionDependencyManager): boolean { | ||
return false; | ||
} | ||
|
||
protected async onExtensionChange(jupyterDependencyManager: IJupyterExtensionDependencyManager): Promise<void> { | ||
if (jupyterDependencyManager && jupyterDependencyManager.isJupyterExtensionInstalled) { | ||
await this.lspNotebooksExperiment.onJupyterInstalled(); | ||
} | ||
|
||
if (!this.notebookAddon) { | ||
this.notebookAddon = new LspInteractiveWindowMiddlewareAddon( | ||
this.getClient, | ||
this.jupyterExtensionIntegration, | ||
); | ||
} | ||
} | ||
|
||
protected async getPythonPathOverride(uri: Uri | undefined): Promise<string | undefined> { | ||
if (!uri) { | ||
return undefined; | ||
} | ||
|
||
const jupyterPythonPathFunction = this.jupyterExtensionIntegration.getJupyterPythonPathFunction(); | ||
if (!jupyterPythonPathFunction) { | ||
return undefined; | ||
} | ||
|
||
const result = await jupyterPythonPathFunction(uri); | ||
|
||
if (result) { | ||
traceLog(`Jupyter provided interpreter path override: ${result}`); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
protected configurationHook(item: ConfigurationItem, settings: LSPObject): void { | ||
if (item.section === 'editor') { | ||
if (this.workspaceService) { | ||
// Get editor.formatOnType using Python language id so [python] setting | ||
// will be honored if present. | ||
const editorConfig = this.workspaceService.getConfiguration( | ||
item.section, | ||
undefined, | ||
/* languageSpecific */ true, | ||
); | ||
|
||
const settingDict: LSPObject & { formatOnType?: boolean } = settings as LSPObject & { | ||
formatOnType: boolean; | ||
}; | ||
|
||
settingDict.formatOnType = editorConfig.get('formatOnType'); | ||
} | ||
} | ||
} | ||
} |
187 changes: 0 additions & 187 deletions
187
extensions/positron-python/src/client/activation/node/lspInteractiveWindowMiddlewareAddon.ts
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
extensions/positron-python/src/client/activation/node/lspNotebooksExperiment.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.