Archived
1
0

chore(vscode): update to 1.53.2

These conflicts will be resolved in the following commits. We do it this way so
that PR review is possible.
This commit is contained in:
Joe Previte
2021-02-25 11:27:27 -07:00
1900 changed files with 83066 additions and 64589 deletions

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { RequestService, getScheme } from '../requests';
import { RequestService } from '../requests';
import { URI as Uri } from 'vscode-uri';
import * as fs from 'fs';
@ -11,7 +11,7 @@ import { FileType } from 'vscode-css-languageservice';
export function getNodeFSRequestService(): RequestService {
function ensureFileUri(location: string) {
if (getScheme(location) !== 'file') {
if (!location.startsWith('file://')) {
throw new Error('fileRequestService can only handle file URLs');
}
}

View File

@ -3,19 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vscode-uri';
import { RequestType, Connection } from 'vscode-languageserver';
import { RuntimeEnvironment } from './cssServer';
export namespace FsContentRequest {
export const type: RequestType<{ uri: string; encoding?: string; }, string, any, any> = new RequestType('fs/content');
export const type: RequestType<{ uri: string; encoding?: string; }, string, any> = new RequestType('fs/content');
}
export namespace FsStatRequest {
export const type: RequestType<string, FileStat, any, any> = new RequestType('fs/stat');
export const type: RequestType<string, FileStat, any> = new RequestType('fs/stat');
}
export namespace FsReadDirRequest {
export const type: RequestType<string, [string, FileType][], any, any> = new RequestType('fs/readDir');
export const type: RequestType<string, [string, FileType][], any> = new RequestType('fs/readDir');
}
export enum FileType {
@ -99,79 +98,6 @@ export function getRequestService(handledSchemas: string[], connection: Connecti
};
}
export function getScheme(uri: string) {
function getScheme(uri: string) {
return uri.substr(0, uri.indexOf(':'));
}
export function dirname(uri: string) {
const lastIndexOfSlash = uri.lastIndexOf('/');
return lastIndexOfSlash !== -1 ? uri.substr(0, lastIndexOfSlash) : '';
}
export function basename(uri: string) {
const lastIndexOfSlash = uri.lastIndexOf('/');
return uri.substr(lastIndexOfSlash + 1);
}
const Slash = '/'.charCodeAt(0);
const Dot = '.'.charCodeAt(0);
export function extname(uri: string) {
for (let i = uri.length - 1; i >= 0; i--) {
const ch = uri.charCodeAt(i);
if (ch === Dot) {
if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {
return uri.substr(i);
} else {
break;
}
} else if (ch === Slash) {
break;
}
}
return '';
}
export function isAbsolutePath(path: string) {
return path.charCodeAt(0) === Slash;
}
export function resolvePath(uriString: string, path: string): string {
if (isAbsolutePath(path)) {
const uri = URI.parse(uriString);
const parts = path.split('/');
return uri.with({ path: normalizePath(parts) }).toString();
}
return joinPath(uriString, path);
}
export function normalizePath(parts: string[]): string {
const newParts: string[] = [];
for (const part of parts) {
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
// ignore
} else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
newParts.pop();
} else {
newParts.push(part);
}
}
if (parts.length > 1 && parts[parts.length - 1].length === 0) {
newParts.push('');
}
let res = newParts.join('/');
if (parts[0].length === 0) {
res = '/' + res;
}
return res;
}
export function joinPath(uriString: string, ...paths: string[]): string {
const uri = URI.parse(uriString);
const parts = uri.path.split('/');
for (let path of paths) {
parts.push(...path.split('/'));
}
return uri.with({ path: normalizePath(parts) }).toString();
}

View File

@ -1,62 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import * as assert from 'assert';
import { joinPath, normalizePath, resolvePath, extname } from '../requests';
suite('requests', () => {
test('join', async function () {
assert.equal(joinPath('foo://a/foo/bar', 'x'), 'foo://a/foo/bar/x');
assert.equal(joinPath('foo://a/foo/bar/', 'x'), 'foo://a/foo/bar/x');
assert.equal(joinPath('foo://a/foo/bar/', '/x'), 'foo://a/foo/bar/x');
assert.equal(joinPath('foo://a/foo/bar/', 'x/'), 'foo://a/foo/bar/x/');
assert.equal(joinPath('foo://a/foo/bar/', 'x', 'y'), 'foo://a/foo/bar/x/y');
assert.equal(joinPath('foo://a/foo/bar/', 'x/', '/y'), 'foo://a/foo/bar/x/y');
assert.equal(joinPath('foo://a/foo/bar/', '.', '/y'), 'foo://a/foo/bar/y');
assert.equal(joinPath('foo://a/foo/bar/', 'x/y/z', '..'), 'foo://a/foo/bar/x/y');
});
test('resolve', async function () {
assert.equal(resolvePath('foo://a/foo/bar', 'x'), 'foo://a/foo/bar/x');
assert.equal(resolvePath('foo://a/foo/bar/', 'x'), 'foo://a/foo/bar/x');
assert.equal(resolvePath('foo://a/foo/bar/', '/x'), 'foo://a/x');
assert.equal(resolvePath('foo://a/foo/bar/', 'x/'), 'foo://a/foo/bar/x/');
});
test('normalize', async function () {
function assertNormalize(path: string, expected: string) {
assert.equal(normalizePath(path.split('/')), expected, path);
}
assertNormalize('a', 'a');
assertNormalize('/a', '/a');
assertNormalize('a/', 'a/');
assertNormalize('a/b', 'a/b');
assertNormalize('/a/foo/bar/x', '/a/foo/bar/x');
assertNormalize('/a/foo/bar//x', '/a/foo/bar/x');
assertNormalize('/a/foo/bar///x', '/a/foo/bar/x');
assertNormalize('/a/foo/bar/x/', '/a/foo/bar/x/');
assertNormalize('a/foo/bar/x/', 'a/foo/bar/x/');
assertNormalize('a/foo/bar/x//', 'a/foo/bar/x/');
assertNormalize('//a/foo/bar/x//', '/a/foo/bar/x/');
assertNormalize('a/.', 'a');
assertNormalize('a/./b', 'a/b');
assertNormalize('a/././b', 'a/b');
assertNormalize('a/n/../b', 'a/b');
assertNormalize('a/n/../', 'a/');
assertNormalize('a/n/../', 'a/');
assertNormalize('/a/n/../..', '/');
assertNormalize('..', '');
assertNormalize('/..', '/');
});
test('extname', async function () {
function assertExtName(input: string, expected: string) {
assert.equal(extname(input), expected, input);
}
assertExtName('foo://a/foo/bar', '');
assertExtName('foo://a/foo/bar.foo', '.foo');
assertExtName('foo://a/foo/.foo', '');
});
});

View File

@ -6,7 +6,7 @@
import { DocumentContext } from 'vscode-css-languageservice';
import { endsWith, startsWith } from '../utils/strings';
import { WorkspaceFolder } from 'vscode-languageserver';
import { resolvePath } from '../requests';
import { Utils, URI } from 'vscode-uri';
export function getDocumentContext(documentUri: string, workspaceFolders: WorkspaceFolder[]): DocumentContext {
function getRootFolder(): string | undefined {
@ -31,7 +31,7 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
}
}
base = base.substr(0, base.lastIndexOf('/') + 1);
return resolvePath(base, ref);
return Utils.resolvePath(URI.parse(base), ref).toString();
},
};
}

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ResponseError, ErrorCodes, CancellationToken } from 'vscode-languageserver';
import { ResponseError, CancellationToken, LSPErrorCodes } from 'vscode-languageserver';
export function formatError(message: string, err: any): string {
if (err instanceof Error) {
@ -39,5 +39,5 @@ export function runSafeAsync<T>(func: () => Thenable<T>, errorVal: T, errorMessa
}
function cancelValue<E>() {
return new ResponseError<E>(ErrorCodes.RequestCancelled, 'Request cancelled');
return new ResponseError<E>(LSPErrorCodes.RequestCancelled, 'Request cancelled');
}