Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest lsp for pull diagnostics #23979

Merged
merged 19 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"no-control-regex": "off",
"no-extend-native": "off",
"no-multi-str": "off",
"no-shadow": "off",
"no-param-reassign": "off",
"no-prototype-builtins": "off",
"no-restricted-syntax": [
Expand Down
2,709 changes: 1,849 additions & 860 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1525,11 +1525,11 @@
"@iarna/toml": "^2.2.5",
"@vscode/extension-telemetry": "^0.8.4",
"arch": "^2.1.0",
"fs-extra": "^10.0.1",
"fs-extra": "^11.2.0",
"glob": "^7.2.0",
"hash.js": "^1.1.7",
"iconv-lite": "^0.6.3",
"inversify": "^5.0.4",
"inversify": "^6.0.2",
"jsonc-parser": "^3.0.0",
"lodash": "^4.17.21",
"minimatch": "^5.0.1",
Expand All @@ -1544,11 +1544,10 @@
"tmp": "^0.0.33",
"uint64be": "^3.0.0",
"unicode": "^14.0.0",
"untildify": "^4.0.0",
"vscode-debugprotocol": "^1.28.0",
"vscode-jsonrpc": "^9.0.0-next.2",
"vscode-languageclient": "^10.0.0-next.2",
"vscode-languageserver-protocol": "^3.17.6-next.3",
"vscode-jsonrpc": "^9.0.0-next.5",
"vscode-languageclient": "^10.0.0-next.12",
"vscode-languageserver-protocol": "^3.17.6-next.10",
"vscode-tas-client": "^0.1.84",
"which": "^2.0.2",
"winreg": "^1.2.4",
Expand All @@ -1561,22 +1560,22 @@
"@types/chai-arrays": "^2.0.0",
"@types/chai-as-promised": "^7.1.0",
"@types/download": "^8.0.1",
"@types/fs-extra": "^9.0.13",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^7.2.0",
"@types/lodash": "^4.14.104",
"@types/mocha": "^9.1.0",
"@types/node": "^18.17.1",
"@types/node": "^22.5.0",
"@types/semver": "^5.5.0",
"@types/shortid": "^0.0.29",
"@types/sinon": "^10.0.11",
"@types/sinon": "^17.0.3",
"@types/stack-trace": "0.0.29",
"@types/tmp": "^0.0.33",
"@types/vscode": "^1.81.0",
"@types/which": "^2.0.1",
"@types/winreg": "^1.2.30",
"@types/xml2js": "^0.4.2",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vscode/test-electron": "^2.3.8",
"@vscode/vsce": "^2.27.0",
"bent": "^7.3.12",
Expand All @@ -1590,7 +1589,7 @@
"eslint": "^7.2.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.0",
Expand All @@ -1609,14 +1608,14 @@
"prettier": "^2.0.2",
"rewiremock": "^3.13.0",
"shortid": "^2.2.8",
"sinon": "^13.0.1",
"sinon": "^18.0.0",
"source-map-support": "^0.5.12",
"ts-loader": "^9.2.8",
"ts-mockito": "^2.5.0",
"ts-node": "^10.7.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typemoq": "^2.1.0",
"typescript": "4.5.5",
"typescript": "~5.2",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the new way Dirk is exporting the api from the LSP client, I had to update the typescript compiler and the tsconfig.json. It's basically what caused all of these changes.

"uuid": "^8.3.2",
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const InvalidMacPythonInterpreterServiceId = 'InvalidMacPythonInterpreter
export class InvalidMacPythonInterpreterService extends BaseDiagnosticsService {
protected changeThrottleTimeout = 1000;

private timeOut?: NodeJS.Timer | number;
private timeOut?: NodeJS.Timeout | number;

constructor(
@inject(IServiceContainer) serviceContainer: IServiceContainer,
Expand Down
2 changes: 1 addition & 1 deletion src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function runPylance(
middleware,
};

const client = new LanguageClient('python', 'Python Language Server', clientOptions, worker);
const client = new LanguageClient('python', 'Python Language Server', worker, clientOptions);
languageClient = client;

context.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

'use strict';

import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import { inject, injectable } from 'inversify';
import { isEqual } from 'lodash';
import * as fs from '../../platform/fs-paths';
import { IExtensionSingleActivationService } from '../../../activation/types';
import { IApplicationEnvironment, ICommandManager, IWorkspaceService } from '../types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
Expand Down
3 changes: 1 addition & 2 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import { debounceSync } from './utils/decorators';
import { SystemVariables } from './variables/systemVariables';
import { getOSType, OSType } from './utils/platform';
import { isWindows } from './platform/platformService';

const untildify = require('untildify');
import { untildify } from './helpers';

export class PythonSettings implements IPythonSettings {
private get onDidChange(): Event<ConfigurationChangeEvent | undefined> {
Expand Down
7 changes: 0 additions & 7 deletions src/client/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ String.prototype.trimQuotes = function (this: string): string {
return this.replace(/(^['"])|(['"]$)/g, '');
};

declare interface Promise<T> {
/**
* Catches task error and ignores them.
*/
ignoreErrors(): Promise<void>;
}

/**
* Explicitly tells that promise should be run asynchonously.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/client/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

'use strict';
import * as os from 'os';

import { ModuleNotInstalledError } from './errors/moduleNotInstalledError';

Expand All @@ -19,3 +20,7 @@ export function isNotInstalledError(error: Error): boolean {
const isModuleNoInstalledError = error.message.indexOf('No module named') >= 0;
return errorObj.code === 'ENOENT' || errorObj.code === 127 || isModuleNoInstalledError;
}

export function untildify(path: string): string {
return path.replace(/^~($|\/|\\)/, `${os.homedir()}$1`);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untilidify doesn't work so well with new typescript. Just asked copilot to generate a new one.

}
1 change: 1 addition & 0 deletions src/client/common/installer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface IProductPathService {
}

export enum ModuleInstallFlags {
none = 0,
upgrade = 1,
updateDependencies = 2,
reInstall = 4,
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/interpreterPathService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

import * as fs from 'fs-extra';
import * as fs from '../common/platform/fs-paths';
import { inject, injectable } from 'inversify';
import { ConfigurationChangeEvent, ConfigurationTarget, Event, EventEmitter, Uri } from 'vscode';
import { traceError, traceVerbose } from '../logging';
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/platform/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class FileSystemUtils implements IFileSystemUtils {
pathUtils.paths,
tmp || TemporaryFileSystem.withDefaults(),
getHash || getHashString,
globFiles || promisify(glob),
globFiles || promisify(glob.default),
);
}

Expand Down
184 changes: 181 additions & 3 deletions src/client/common/platform/fs-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import * as nodepath from 'path';
import { getSearchPathEnvVarNames } from '../utils/exec';
import * as fs from 'fs-extra';
import * as os from 'os';
import { getOSType, OSType } from '../utils/platform';
import { IExecutables, IFileSystemPaths, IFileSystemPathUtils } from './types';

const untildify = require('untildify');

// The parts of node's 'path' module used by FileSystemPaths.
interface INodePath {
sep: string;
Expand Down Expand Up @@ -120,7 +119,7 @@ export class FileSystemPathUtils implements IFileSystemPathUtils {
}
return new FileSystemPathUtils(
// Use the current user's home directory.
untildify('~'),
os.homedir(),
paths,
Executables.withDefaults(),
// Use the actual node "path" module.
Expand Down Expand Up @@ -183,10 +182,189 @@ export async function copyFile(src: string, dest: string): Promise<void> {
});
}

// These function exist so we can stub them out in tests. We can't stub out the fs module directly
// because of the way that sinon does stubbing, so we have these intermediaries instead.
export { Stats, WriteStream, ReadStream, PathLike, Dirent, PathOrFileDescriptor } from 'fs-extra';

export function existsSync(path: string): boolean {
return fs.existsSync(path);
}

export function readFileSync(filePath: string, encoding: BufferEncoding): string;
export function readFileSync(filePath: string): Buffer;
export function readFileSync(filePath: string, options: { encoding: BufferEncoding }): string;
export function readFileSync(
filePath: string,
options?: { encoding: BufferEncoding } | BufferEncoding | undefined,
): string | Buffer {
if (typeof options === 'string') {
return fs.readFileSync(filePath, { encoding: options });
}
return fs.readFileSync(filePath, options);
}

export function readJSONSync(filePath: string): any {
return fs.readJSONSync(filePath);
}

export function readdirSync(path: string): string[];
export function readdirSync(
path: string,
options: fs.ObjectEncodingOptions & {
withFileTypes: true;
},
): fs.Dirent[];
export function readdirSync(
path: string,
options: fs.ObjectEncodingOptions & {
withFileTypes: false;
},
): string[];
export function readdirSync(
path: fs.PathLike,
options?: fs.ObjectEncodingOptions & {
withFileTypes: boolean;
recursive?: boolean | undefined;
},
): string[] | fs.Dirent[] {
if (options === undefined || options.withFileTypes === false) {
return fs.readdirSync(path);
}
return fs.readdirSync(path, { ...options, withFileTypes: true });
}

export function readlink(path: string): Promise<string> {
return fs.readlink(path);
}

export function unlink(path: string): Promise<void> {
return fs.unlink(path);
}

export function symlink(target: string, path: string, type?: fs.SymlinkType): Promise<void> {
return fs.symlink(target, path, type);
}

export function symlinkSync(target: string, path: string, type?: fs.SymlinkType): void {
return fs.symlinkSync(target, path, type);
}

export function unlinkSync(path: string): void {
return fs.unlinkSync(path);
}

export function statSync(path: string): fs.Stats {
return fs.statSync(path);
}

export function stat(path: string): Promise<fs.Stats> {
return fs.stat(path);
}

export function lstat(path: string): Promise<fs.Stats> {
return fs.lstat(path);
}

export function chmod(path: string, mod: fs.Mode): Promise<void> {
return fs.chmod(path, mod);
}

export function createReadStream(path: string): fs.ReadStream {
return fs.createReadStream(path);
}

export function createWriteStream(path: string): fs.WriteStream {
return fs.createWriteStream(path);
}

export function pathExistsSync(path: string): boolean {
return fs.pathExistsSync(path);
}

export function pathExists(absPath: string): Promise<boolean> {
return fs.pathExists(absPath);
}

export function createFile(filename: string): Promise<void> {
return fs.createFile(filename);
}

export function rmdir(path: string, options?: fs.RmDirOptions): Promise<void> {
return fs.rmdir(path, options);
}

export function remove(path: string): Promise<void> {
return fs.remove(path);
}

export function readFile(filePath: string, encoding: BufferEncoding): Promise<string>;
export function readFile(filePath: string): Promise<Buffer>;
export function readFile(filePath: string, options: { encoding: BufferEncoding }): Promise<string>;
export function readFile(
filePath: string,
options?: { encoding: BufferEncoding } | BufferEncoding | undefined,
): Promise<string | Buffer> {
if (typeof options === 'string') {
return fs.readFile(filePath, { encoding: options });
}
return fs.readFile(filePath, options);
}

export function readJson(filePath: string): Promise<any> {
return fs.readJson(filePath);
}

export function writeFile(filePath: string, data: any, options?: { encoding: BufferEncoding }): Promise<void> {
return fs.writeFile(filePath, data, options);
}

export function mkdir(dirPath: string): Promise<void> {
return fs.mkdir(dirPath);
}

export function mkdirp(dirPath: string): Promise<void> {
return fs.mkdirp(dirPath);
}

export function rename(oldPath: string, newPath: string): Promise<void> {
return fs.rename(oldPath, newPath);
}

export function ensureDir(dirPath: string): Promise<void> {
return fs.ensureDir(dirPath);
}

export function ensureFile(filePath: string): Promise<void> {
return fs.ensureFile(filePath);
}

export function ensureSymlink(target: string, filePath: string, type?: fs.SymlinkType): Promise<void> {
return fs.ensureSymlink(target, filePath, type);
}

export function appendFile(filePath: string, data: any, options?: { encoding: BufferEncoding }): Promise<void> {
return fs.appendFile(filePath, data, options);
}

export function readdir(path: string): Promise<string[]>;
export function readdir(
path: string,
options: fs.ObjectEncodingOptions & {
withFileTypes: true;
},
): Promise<fs.Dirent[]>;
export function readdir(
path: fs.PathLike,
options?: fs.ObjectEncodingOptions & {
withFileTypes: true;
},
): Promise<string[] | fs.Dirent[]> {
if (options === undefined) {
return fs.readdir(path);
}
return fs.readdir(path, options);
}

export function emptyDir(dirPath: string): Promise<void> {
return fs.emptyDir(dirPath);
}
Loading
Loading