mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-03 19:37:39 +03:00
pull-pylance-with-pyright-1.1.247 (#3474)
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com> Co-authored-by: HeeJae Chang <hechang@microsoft.com> Co-authored-by: Erik De Bonte <erikd@microsoft.com>
This commit is contained in:
parent
e3b6e7b51c
commit
0577bc22b9
30
packages/pyright-internal/package-lock.json
generated
30
packages/pyright-internal/package-lock.json
generated
@ -3123,25 +3123,25 @@
|
||||
}
|
||||
},
|
||||
"vscode-jsonrpc": {
|
||||
"version": "8.0.0-next.7",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.7.tgz",
|
||||
"integrity": "sha512-JX/F31LEsims0dAlOTKFE4E+AJMiJvdRSRViifFJSqSN7EzeYyWlfuDchF7g91oRNPZOIWfibTkDf3/UMsQGzQ=="
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.1.tgz",
|
||||
"integrity": "sha512-N/WKvghIajmEvXpatSzvTvOIz61ZSmOSa4BRA4pTLi+1+jozquQKP/MkaylP9iB68k73Oua1feLQvH3xQuigiQ=="
|
||||
},
|
||||
"vscode-languageserver": {
|
||||
"version": "8.0.0-next.10",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.0-next.10.tgz",
|
||||
"integrity": "sha512-sdjldl9ipuBSWVw5ENVMRcOVQwF0o+J6+lNA7FrB8MiLmzflnfjRoJMqA5tCEY8S/J/+P56ZR/dqiQnRYg5m8w==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.1.tgz",
|
||||
"integrity": "sha512-sn7SjBwWm3OlmLtgg7jbM0wBULppyL60rj8K5HF0ny/MzN+GzPBX1kCvYdybhl7UW63V5V5tRVnyB8iwC73lSQ==",
|
||||
"requires": {
|
||||
"vscode-languageserver-protocol": "3.17.0-next.16"
|
||||
"vscode-languageserver-protocol": "3.17.1"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-protocol": {
|
||||
"version": "3.17.0-next.16",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.16.tgz",
|
||||
"integrity": "sha512-tx4DnXw9u3N7vw+bx6n2NKp6FoxoNwiP/biH83AS30I2AnTGyLd7afSeH6Oewn2E8jvB7K15bs12sMppkKOVeQ==",
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.1.tgz",
|
||||
"integrity": "sha512-BNlAYgQoYwlSgDLJhSG+DeA8G1JyECqRzM2YO6tMmMji3Ad9Mw6AW7vnZMti90qlAKb0LqAlJfSVGEdqMMNzKg==",
|
||||
"requires": {
|
||||
"vscode-jsonrpc": "8.0.0-next.7",
|
||||
"vscode-languageserver-types": "3.17.0-next.9"
|
||||
"vscode-jsonrpc": "8.0.1",
|
||||
"vscode-languageserver-types": "3.17.1"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-textdocument": {
|
||||
@ -3150,9 +3150,9 @@
|
||||
"integrity": "sha512-/xhqXP/2A2RSs+J8JNXpiiNVvvNM0oTosNVmQnunlKvq9o4mupHOBAnnzH0lwIPKazXKvAKsVp1kr+H/K4lgoQ=="
|
||||
},
|
||||
"vscode-languageserver-types": {
|
||||
"version": "3.17.0-next.9",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.9.tgz",
|
||||
"integrity": "sha512-9/PeDNPYduaoXRUzYpqmu4ZV9L01HGo0wH9FUt+sSHR7IXwA7xoXBfNUlv8gB9H0D2WwEmMomSy1NmhjKQyn3A=="
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.1.tgz",
|
||||
"integrity": "sha512-K3HqVRPElLZVVPtMeKlsyL9aK0GxGQpvtAUTfX4k7+iJ4mc1M+JM+zQwkgGy2LzY0f0IAafe8MKqIkJrxfGGjQ=="
|
||||
},
|
||||
"vscode-uri": {
|
||||
"version": "3.0.3",
|
||||
|
@ -26,10 +26,10 @@
|
||||
"source-map-support": "^0.5.21",
|
||||
"tmp": "^0.2.1",
|
||||
"typescript-char": "^0.0.0",
|
||||
"vscode-jsonrpc": "8.0.0-next.7",
|
||||
"vscode-languageserver": "8.0.0-next.10",
|
||||
"vscode-jsonrpc": "8.0.1",
|
||||
"vscode-languageserver": "8.0.1",
|
||||
"vscode-languageserver-textdocument": "^1.0.4",
|
||||
"vscode-languageserver-types": "3.17.0-next.9",
|
||||
"vscode-languageserver-types": "3.17.1",
|
||||
"vscode-uri": "^3.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -100,7 +100,7 @@ import { LanguageServiceExtension } from './common/extensibility';
|
||||
import { FileSystem, FileWatcherEventType, FileWatcherProvider } from './common/fileSystem';
|
||||
import { Host } from './common/host';
|
||||
import { fromLSPAny } from './common/lspUtils';
|
||||
import { convertPathToUri, normalizeSlashes } from './common/pathUtils';
|
||||
import { convertPathToUri } from './common/pathUtils';
|
||||
import { ProgressReporter, ProgressReportTracker } from './common/progressReporter';
|
||||
import { DocumentRange, Position, Range } from './common/textRange';
|
||||
import { UriParser } from './common/uriParser';
|
||||
@ -201,6 +201,7 @@ interface ClientCapabilities {
|
||||
hasVisualStudioExtensionsCapability: boolean;
|
||||
hasWorkspaceFoldersCapability: boolean;
|
||||
hasWatchFileCapability: boolean;
|
||||
hasWatchFileRelativePathCapability: boolean;
|
||||
hasActiveParameterCapability: boolean;
|
||||
hasSignatureLabelOffsetCapability: boolean;
|
||||
hasHierarchicalDocumentSymbolCapability: boolean;
|
||||
@ -244,6 +245,7 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
hasVisualStudioExtensionsCapability: false,
|
||||
hasWorkspaceFoldersCapability: false,
|
||||
hasWatchFileCapability: false,
|
||||
hasWatchFileRelativePathCapability: false,
|
||||
hasActiveParameterCapability: false,
|
||||
hasSignatureLabelOffsetCapability: false,
|
||||
hasHierarchicalDocumentSymbolCapability: false,
|
||||
@ -509,6 +511,8 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
const capabilities = params.capabilities;
|
||||
this.client.hasConfigurationCapability = !!capabilities.workspace?.configuration;
|
||||
this.client.hasWatchFileCapability = !!capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration;
|
||||
this.client.hasWatchFileRelativePathCapability =
|
||||
!!capabilities.workspace?.didChangeWatchedFiles?.relativePatternSupport;
|
||||
this.client.hasWorkspaceFoldersCapability = !!capabilities.workspace?.workspaceFolders;
|
||||
this.client.hasVisualStudioExtensionsCapability = !!(capabilities as any).supportsVisualStudioExtensions;
|
||||
this.client.hasActiveParameterCapability =
|
||||
@ -604,6 +608,8 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
this._workspaceMap.set(rootPath, newWorkspace);
|
||||
await this.updateSettingsForWorkspace(newWorkspace);
|
||||
});
|
||||
|
||||
this._setupFileWatcher();
|
||||
});
|
||||
|
||||
this._setupFileWatcher();
|
||||
@ -630,13 +636,15 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
];
|
||||
|
||||
// Add all python search paths to watch list
|
||||
for (const workspace of this._workspaceMap.getNonDefaultWorkspaces()) {
|
||||
workspace.searchPathsToWatch.forEach((p) => {
|
||||
watchers.push({
|
||||
globPattern: `${normalizeSlashes(this.fs.realCasePath(p), '/')}/**`,
|
||||
kind: WatchKind.Create | WatchKind.Change | WatchKind.Delete,
|
||||
if (this.client.hasWatchFileRelativePathCapability) {
|
||||
for (const workspace of this._workspaceMap.getNonDefaultWorkspaces()) {
|
||||
workspace.searchPathsToWatch.forEach((p) => {
|
||||
watchers.push({
|
||||
globPattern: { baseUri: convertPathToUri(this.fs, p), pattern: '**' },
|
||||
kind: WatchKind.Create | WatchKind.Change | WatchKind.Delete,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this._connection.client.register(DidChangeWatchedFilesNotification.type, { watchers }).then((d) => {
|
||||
@ -1265,11 +1273,14 @@ export abstract class LanguageServerBase implements LanguageServerInterface {
|
||||
}
|
||||
|
||||
updateSettingsForAllWorkspaces(): void {
|
||||
const tasks: Promise<void>[] = [];
|
||||
this._workspaceMap.forEach((workspace) => {
|
||||
this.updateSettingsForWorkspace(workspace).ignoreErrors();
|
||||
tasks.push(this.updateSettingsForWorkspace(workspace));
|
||||
});
|
||||
|
||||
this._setupFileWatcher();
|
||||
Promise.all(tasks).then(() => {
|
||||
this._setupFileWatcher();
|
||||
});
|
||||
}
|
||||
|
||||
protected getCompletionOptions(params?: CompletionParams) {
|
||||
|
44
packages/vscode-pyright/package-lock.json
generated
44
packages/vscode-pyright/package-lock.json
generated
@ -84,9 +84,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/vscode": {
|
||||
"version": "1.63.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.2.tgz",
|
||||
"integrity": "sha512-awvdx4vX7SkMKyvWIlRjycjb4blYRSQI3Bav0YMn+lJLGN6gJgb20urN/dQCv/2ejDu5S6ADEBt6O15DOpIAkg==",
|
||||
"version": "1.66.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.66.0.tgz",
|
||||
"integrity": "sha512-ZfJck4M7nrGasfs4A4YbUoxis3Vu24cETw3DERsNYtDZmYSYtk6ljKexKFKhImO/ZmY6ZMsmegu2FPkXoUFImA==",
|
||||
"dev": true
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
@ -2294,41 +2294,41 @@
|
||||
}
|
||||
},
|
||||
"vscode-jsonrpc": {
|
||||
"version": "8.0.0-next.7",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.7.tgz",
|
||||
"integrity": "sha512-JX/F31LEsims0dAlOTKFE4E+AJMiJvdRSRViifFJSqSN7EzeYyWlfuDchF7g91oRNPZOIWfibTkDf3/UMsQGzQ=="
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.1.tgz",
|
||||
"integrity": "sha512-N/WKvghIajmEvXpatSzvTvOIz61ZSmOSa4BRA4pTLi+1+jozquQKP/MkaylP9iB68k73Oua1feLQvH3xQuigiQ=="
|
||||
},
|
||||
"vscode-languageclient": {
|
||||
"version": "8.0.0-next.14",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.14.tgz",
|
||||
"integrity": "sha512-NqjkOuDTMu8uo+PhoMsV72VO9Gd3wBi/ZpOrkRUOrWKQo7yUdiIw183g8wjH8BImgbK9ZP51HM7TI0ZhCnI1Mw==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.1.tgz",
|
||||
"integrity": "sha512-9XoE+HJfaWvu7Y75H3VmLo5WLCtsbxEgEhrLPqwt7eyoR49lUIyyrjb98Yfa50JCMqF2cePJAEVI6oe2o1sIhw==",
|
||||
"requires": {
|
||||
"minimatch": "^3.0.4",
|
||||
"semver": "^7.3.5",
|
||||
"vscode-languageserver-protocol": "3.17.0-next.16"
|
||||
"vscode-languageserver-protocol": "3.17.1"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver": {
|
||||
"version": "8.0.0-next.10",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.0-next.10.tgz",
|
||||
"integrity": "sha512-sdjldl9ipuBSWVw5ENVMRcOVQwF0o+J6+lNA7FrB8MiLmzflnfjRoJMqA5tCEY8S/J/+P56ZR/dqiQnRYg5m8w==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.1.tgz",
|
||||
"integrity": "sha512-sn7SjBwWm3OlmLtgg7jbM0wBULppyL60rj8K5HF0ny/MzN+GzPBX1kCvYdybhl7UW63V5V5tRVnyB8iwC73lSQ==",
|
||||
"requires": {
|
||||
"vscode-languageserver-protocol": "3.17.0-next.16"
|
||||
"vscode-languageserver-protocol": "3.17.1"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-protocol": {
|
||||
"version": "3.17.0-next.16",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.16.tgz",
|
||||
"integrity": "sha512-tx4DnXw9u3N7vw+bx6n2NKp6FoxoNwiP/biH83AS30I2AnTGyLd7afSeH6Oewn2E8jvB7K15bs12sMppkKOVeQ==",
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.1.tgz",
|
||||
"integrity": "sha512-BNlAYgQoYwlSgDLJhSG+DeA8G1JyECqRzM2YO6tMmMji3Ad9Mw6AW7vnZMti90qlAKb0LqAlJfSVGEdqMMNzKg==",
|
||||
"requires": {
|
||||
"vscode-jsonrpc": "8.0.0-next.7",
|
||||
"vscode-languageserver-types": "3.17.0-next.9"
|
||||
"vscode-jsonrpc": "8.0.1",
|
||||
"vscode-languageserver-types": "3.17.1"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-types": {
|
||||
"version": "3.17.0-next.9",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.9.tgz",
|
||||
"integrity": "sha512-9/PeDNPYduaoXRUzYpqmu4ZV9L01HGo0wH9FUt+sSHR7IXwA7xoXBfNUlv8gB9H0D2WwEmMomSy1NmhjKQyn3A=="
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.1.tgz",
|
||||
"integrity": "sha512-K3HqVRPElLZVVPtMeKlsyL9aK0GxGQpvtAUTfX4k7+iJ4mc1M+JM+zQwkgGy2LzY0f0IAafe8MKqIkJrxfGGjQ=="
|
||||
},
|
||||
"watchpack": {
|
||||
"version": "2.3.1",
|
||||
|
@ -14,7 +14,7 @@
|
||||
"url": "https://github.com/Microsoft/pyright"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.66.0"
|
||||
"vscode": "^1.67.0"
|
||||
},
|
||||
"keywords": [
|
||||
"python"
|
||||
@ -844,15 +844,15 @@
|
||||
"webpack-dev": "npm run clean && webpack --mode development --watch --progress"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-jsonrpc": "8.0.0-next.7",
|
||||
"vscode-languageclient": "8.0.0-next.14",
|
||||
"vscode-languageserver": "8.0.0-next.10",
|
||||
"vscode-languageserver-protocol": "3.17.0-next.16"
|
||||
"vscode-jsonrpc": "8.0.1",
|
||||
"vscode-languageclient": "8.0.1",
|
||||
"vscode-languageserver": "8.0.1",
|
||||
"vscode-languageserver-protocol": "3.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/copy-webpack-plugin": "^10.1.0",
|
||||
"@types/node": "^17.0.14",
|
||||
"@types/vscode": "~1.63.1",
|
||||
"@types/vscode": "~1.66.0",
|
||||
"copy-webpack-plugin": "^10.2.4",
|
||||
"detect-indent": "^6.1.0",
|
||||
"shx": "^0.3.4",
|
||||
|
@ -43,12 +43,14 @@ import { FileBasedCancellationStrategy } from './cancellationUtils';
|
||||
|
||||
let cancellationStrategy: FileBasedCancellationStrategy | undefined;
|
||||
|
||||
let languageClient: LanguageClient | undefined;
|
||||
|
||||
const pythonPathChangedListenerMap = new Map<string, string>();
|
||||
|
||||
// Request a heap size of 3GB. This is reasonable for modern systems.
|
||||
const defaultHeapSize = 3072;
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
export async function activate(context: ExtensionContext) {
|
||||
// See if Pylance is installed. If so, don't activate the Pyright extension.
|
||||
// Doing so will generate "command already registered" errors and redundant
|
||||
// hover text, etc.because the two extensions overlap in functionality.
|
||||
@ -129,10 +131,10 @@ export function activate(context: ExtensionContext) {
|
||||
const pythonPathPromises: Promise<string | undefined>[] = params.items.map((item) => {
|
||||
if (item.section === 'python') {
|
||||
const uri = item.scopeUri ? Uri.parse(item.scopeUri) : undefined;
|
||||
return getPythonPathFromPythonExtension(languageClient.outputChannel, uri, () => {
|
||||
return getPythonPathFromPythonExtension(client.outputChannel, uri, () => {
|
||||
// Posts a "workspace/didChangeConfiguration" message to the service
|
||||
// so it re-queries the settings for all workspaces.
|
||||
languageClient.sendNotification(DidChangeConfigurationNotification.type, {
|
||||
client.sendNotification(DidChangeConfigurationNotification.type, {
|
||||
settings: null,
|
||||
});
|
||||
});
|
||||
@ -164,12 +166,8 @@ export function activate(context: ExtensionContext) {
|
||||
};
|
||||
|
||||
// Create the language client and start the client.
|
||||
const languageClient = new LanguageClient('python', 'Pyright', serverOptions, clientOptions);
|
||||
const disposable = languageClient.start();
|
||||
|
||||
// Push the disposable to the context's subscriptions so that the
|
||||
// client can be deactivated on extension deactivation.
|
||||
context.subscriptions.push(disposable);
|
||||
const client = new LanguageClient('python', 'Pyright', serverOptions, clientOptions);
|
||||
languageClient = client;
|
||||
|
||||
// Register our custom commands.
|
||||
const textEditorCommands = [Commands.orderImports, Commands.addMissingOptionalToParam];
|
||||
@ -183,23 +181,18 @@ export function activate(context: ExtensionContext) {
|
||||
arguments: [editor.document.uri.toString(), ...args],
|
||||
};
|
||||
|
||||
languageClient
|
||||
.sendRequest<TextEdit[] | undefined>('workspace/executeCommand', cmd)
|
||||
.then((edits) => {
|
||||
if (edits && edits.length > 0) {
|
||||
editor.edit((editBuilder) => {
|
||||
edits.forEach((edit) => {
|
||||
const startPos = new Position(
|
||||
edit.range.start.line,
|
||||
edit.range.start.character
|
||||
);
|
||||
const endPos = new Position(edit.range.end.line, edit.range.end.character);
|
||||
const range = new Range(startPos, endPos);
|
||||
editBuilder.replace(range, edit.newText);
|
||||
});
|
||||
client.sendRequest<TextEdit[] | undefined>('workspace/executeCommand', cmd).then((edits) => {
|
||||
if (edits && edits.length > 0) {
|
||||
editor.edit((editBuilder) => {
|
||||
edits.forEach((edit) => {
|
||||
const startPos = new Position(edit.range.start.line, edit.range.start.character);
|
||||
const endPos = new Position(edit.range.end.line, edit.range.end.character);
|
||||
const range = new Range(startPos, endPos);
|
||||
editBuilder.replace(range, edit.newText);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
() => {
|
||||
// Error received. For now, do nothing.
|
||||
@ -212,10 +205,12 @@ export function activate(context: ExtensionContext) {
|
||||
genericCommands.forEach((command) => {
|
||||
context.subscriptions.push(
|
||||
commands.registerCommand(command, (...args: any[]) => {
|
||||
languageClient.sendRequest('workspace/executeCommand', { command, arguments: args });
|
||||
client.sendRequest('workspace/executeCommand', { command, arguments: args });
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
await client.start();
|
||||
}
|
||||
|
||||
export function deactivate() {
|
||||
@ -224,10 +219,10 @@ export function deactivate() {
|
||||
cancellationStrategy = undefined;
|
||||
}
|
||||
|
||||
// Return undefined rather than a promise to indicate
|
||||
// that deactivation is done synchronously. We don't have
|
||||
// anything to do here.
|
||||
return undefined;
|
||||
const client = languageClient;
|
||||
languageClient = undefined;
|
||||
|
||||
return client?.stop();
|
||||
}
|
||||
|
||||
// The VS Code Python extension manages its own internal store of configuration settings.
|
||||
|
Loading…
Reference in New Issue
Block a user