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:
@ -25,26 +25,22 @@ namespace CustomDataChangedNotification {
|
||||
}
|
||||
|
||||
namespace TagCloseRequest {
|
||||
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('html/tag');
|
||||
export const type: RequestType<TextDocumentPositionParams, string, any> = new RequestType('html/tag');
|
||||
}
|
||||
namespace LinkedEditingRequest {
|
||||
export const type: RequestType<TextDocumentPositionParams, LspRange[] | null, any, any> = new RequestType('html/linkedEditing');
|
||||
}
|
||||
|
||||
// experimental: semantic tokens
|
||||
interface SemanticTokenParams {
|
||||
textDocument: TextDocumentIdentifier;
|
||||
ranges?: LspRange[];
|
||||
}
|
||||
namespace SemanticTokenRequest {
|
||||
export const type: RequestType<SemanticTokenParams, number[] | null, any, any> = new RequestType('html/semanticTokens');
|
||||
export const type: RequestType<SemanticTokenParams, number[] | null, any> = new RequestType('html/semanticTokens');
|
||||
}
|
||||
namespace SemanticTokenLegendRequest {
|
||||
export const type: RequestType0<{ types: string[]; modifiers: string[] } | null, any, any> = new RequestType0('html/semanticTokenLegend');
|
||||
export const type: RequestType0<{ types: string[]; modifiers: string[] } | null, any> = new RequestType0('html/semanticTokenLegend');
|
||||
}
|
||||
|
||||
namespace SettingIds {
|
||||
export const linkedRename = 'editor.linkedRename';
|
||||
export const linkedEditing = 'editor.linkedEditing';
|
||||
export const formatEnable = 'html.format.enable';
|
||||
|
||||
}
|
||||
@ -168,22 +164,6 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
|
||||
toDispose.push(languages.registerDocumentSemanticTokensProvider(documentSelector, provider, new SemanticTokensLegend(legend.types, legend.modifiers)));
|
||||
}
|
||||
});
|
||||
|
||||
disposable = languages.registerLinkedEditingRangeProvider(documentSelector, {
|
||||
async provideLinkedEditingRanges(document, position) {
|
||||
const param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
|
||||
return client.sendRequest(LinkedEditingRequest.type, param).then(response => {
|
||||
if (response) {
|
||||
return {
|
||||
ranges: response.map(r => client.protocol2CodeConverter.asRange(r))
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
});
|
||||
toDispose.push(disposable);
|
||||
|
||||
});
|
||||
|
||||
function updateFormatterRegistration() {
|
||||
@ -194,10 +174,16 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
|
||||
} else if (formatEnabled && !rangeFormatting) {
|
||||
rangeFormatting = languages.registerDocumentRangeFormattingEditProvider(documentSelector, {
|
||||
provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]> {
|
||||
const filesConfig = workspace.getConfiguration('files', document);
|
||||
const fileFormattingOptions = {
|
||||
trimTrailingWhitespace: filesConfig.get<boolean>('trimTrailingWhitespace'),
|
||||
trimFinalNewlines: filesConfig.get<boolean>('trimFinalNewlines'),
|
||||
insertFinalNewline: filesConfig.get<boolean>('insertFinalNewline'),
|
||||
};
|
||||
let params: DocumentRangeFormattingParams = {
|
||||
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
||||
range: client.code2ProtocolConverter.asRange(range),
|
||||
options: client.code2ProtocolConverter.asFormattingOptions(options)
|
||||
options: client.code2ProtocolConverter.asFormattingOptions(options, fileFormattingOptions)
|
||||
};
|
||||
return client.sendRequest(DocumentRangeFormattingRequest.type, params, token).then(
|
||||
client.protocol2CodeConverter.asTextEdits,
|
||||
@ -298,25 +284,25 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
|
||||
}
|
||||
});
|
||||
|
||||
const promptForTypeOnRenameKey = 'html.promptForTypeOnRename';
|
||||
const promptForTypeOnRename = extensions.getExtension('formulahendry.auto-rename-tag') !== undefined &&
|
||||
(context.globalState.get(promptForTypeOnRenameKey) !== false) &&
|
||||
!workspace.getConfiguration('editor', { languageId: 'html' }).get('linkedRename');
|
||||
|
||||
if (promptForTypeOnRename) {
|
||||
const activeEditorListener = window.onDidChangeActiveTextEditor(async e => {
|
||||
if (e && documentSelector.indexOf(e.document.languageId) !== -1) {
|
||||
context.globalState.update(promptForTypeOnRenameKey, false);
|
||||
activeEditorListener.dispose();
|
||||
const configure = localize('configureButton', 'Configure');
|
||||
const res = await window.showInformationMessage(localize('linkedRenameQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
|
||||
if (res === configure) {
|
||||
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedRename);
|
||||
const promptForLinkedEditingKey = 'html.promptForLinkedEditing';
|
||||
if (extensions.getExtension('formulahendry.auto-rename-tag') !== undefined && (context.globalState.get(promptForLinkedEditingKey) !== false)) {
|
||||
const config = workspace.getConfiguration('editor', { languageId: 'html' });
|
||||
if (!config.get('linkedEditing') && !config.get('renameOnType')) {
|
||||
const activeEditorListener = window.onDidChangeActiveTextEditor(async e => {
|
||||
if (e && documentSelector.indexOf(e.document.languageId) !== -1) {
|
||||
context.globalState.update(promptForLinkedEditingKey, false);
|
||||
activeEditorListener.dispose();
|
||||
const configure = localize('configureButton', 'Configure');
|
||||
const res = await window.showInformationMessage(localize('linkedEditingQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
|
||||
if (res === configure) {
|
||||
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedEditing);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
toDispose.push(activeEditorListener);
|
||||
});
|
||||
toDispose.push(activeEditorListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toDispose.push();
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import { RequestType, CommonLanguageClient } from 'vscode-languageclient';
|
||||
import { Runtime } from './htmlClient';
|
||||
|
||||
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 function serveFileSystemRequests(client: CommonLanguageClient, runtime: Runtime) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
"scripts": {
|
||||
"compile": "npx gulp compile-extension:html-language-features-client compile-extension:html-language-features-server",
|
||||
"watch": "npx gulp watch-extension:html-language-features-client watch-extension:html-language-features-server",
|
||||
"postinstall": "cd server && yarn install",
|
||||
"install-client-next": "yarn add vscode-languageclient@next"
|
||||
},
|
||||
"categories": [
|
||||
@ -148,17 +147,13 @@
|
||||
"description": "%html.format.wrapAttributesIndentSize.desc%"
|
||||
},
|
||||
"html.format.templating": {
|
||||
"type": [
|
||||
"boolean"
|
||||
],
|
||||
"type": "boolean",
|
||||
"scope": "resource",
|
||||
"default": false,
|
||||
"description": "%html.format.templating.desc%"
|
||||
},
|
||||
"html.format.unformattedContentDelimiter": {
|
||||
"type": [
|
||||
"string"
|
||||
],
|
||||
"type": "string",
|
||||
"scope": "resource",
|
||||
"default": "",
|
||||
"markdownDescription": "%html.format.unformattedContentDelimiter.desc%"
|
||||
@ -240,10 +235,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-extension-telemetry": "0.1.1",
|
||||
"vscode-languageclient": "7.0.0-next.5.1",
|
||||
"vscode-languageclient": "^7.0.0",
|
||||
"vscode-nls": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.11.7"
|
||||
"@types/node": "^12.19.9"
|
||||
}
|
||||
}
|
||||
|
@ -9,27 +9,23 @@
|
||||
},
|
||||
"main": "./out/node/htmlServerMain",
|
||||
"dependencies": {
|
||||
"vscode-css-languageservice": "^4.4.0",
|
||||
"vscode-html-languageservice": "^3.2.0",
|
||||
"vscode-languageserver": "7.0.0-next.3",
|
||||
"vscode-css-languageservice": "^5.0.3",
|
||||
"vscode-html-languageservice": "^4.0.1",
|
||||
"vscode-languageserver": "^7.0.0",
|
||||
"vscode-nls": "^5.0.0",
|
||||
"vscode-uri": "^2.1.2"
|
||||
"vscode-uri": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.0.3",
|
||||
"@types/node": "^12.11.7",
|
||||
"glob": "^7.1.6",
|
||||
"mocha": "^8.1.3",
|
||||
"mocha-junit-reporter": "^2.0.0",
|
||||
"mocha-multi-reporters": "^1.1.7"
|
||||
"@types/mocha": "^8.2.0",
|
||||
"@types/node": "^12.19.9"
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "npx gulp compile-extension:html-language-features-server",
|
||||
"watch": "npx gulp watch-extension:html-language-features-server",
|
||||
"install-service-next": "yarn add vscode-css-languageservice@next && yarn add vscode-html-languageservice@next",
|
||||
"install-service-local": "npm install ../../../../vscode-css-languageservice -f && npm install ../../../../vscode-html-languageservice -f",
|
||||
"install-service-local": "yarn link vscode-css-languageservice && yarn link vscode-html-languageservice",
|
||||
"install-server-next": "yarn add vscode-languageserver@next",
|
||||
"install-server-local": "npm install ../../../../vscode-languageserver-node/server -f",
|
||||
"install-server-local": "yarn link vscode-languageserver",
|
||||
"test": "npm run compile && node ./test/index.js"
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
Connection, TextDocuments, InitializeParams, InitializeResult, RequestType,
|
||||
DocumentRangeFormattingRequest, Disposable, DocumentSelector, TextDocumentPositionParams, ServerCapabilities,
|
||||
ConfigurationRequest, ConfigurationParams, DidChangeWorkspaceFoldersNotification,
|
||||
DocumentColorRequest, ColorPresentationRequest, TextDocumentSyncKind, NotificationType
|
||||
DocumentColorRequest, ColorPresentationRequest, TextDocumentSyncKind, NotificationType, RequestType0
|
||||
} from 'vscode-languageserver';
|
||||
import {
|
||||
getLanguageModes, LanguageModes, Settings, TextDocument, Position, Diagnostic, WorkspaceFolder, ColorInformation,
|
||||
@ -31,10 +31,7 @@ namespace CustomDataChangedNotification {
|
||||
}
|
||||
|
||||
namespace TagCloseRequest {
|
||||
export const type: RequestType<TextDocumentPositionParams, string | null, any, any> = new RequestType('html/tag');
|
||||
}
|
||||
namespace LinkedEditingRequest {
|
||||
export const type: RequestType<TextDocumentPositionParams, Range[] | null, any, any> = new RequestType('html/linkedEditing');
|
||||
export const type: RequestType<TextDocumentPositionParams, string | null, any> = new RequestType('html/tag');
|
||||
}
|
||||
|
||||
// experimental: semantic tokens
|
||||
@ -43,10 +40,10 @@ interface SemanticTokenParams {
|
||||
ranges?: Range[];
|
||||
}
|
||||
namespace SemanticTokenRequest {
|
||||
export const type: RequestType<SemanticTokenParams, number[] | null, any, any> = new RequestType('html/semanticTokens');
|
||||
export const type: RequestType<SemanticTokenParams, number[] | null, any> = new RequestType('html/semanticTokens');
|
||||
}
|
||||
namespace SemanticTokenLegendRequest {
|
||||
export const type: RequestType<void, { types: string[]; modifiers: string[] } | null, any, any> = new RequestType('html/semanticTokenLegend');
|
||||
export const type: RequestType0<{ types: string[]; modifiers: string[] } | null, any> = new RequestType0('html/semanticTokenLegend');
|
||||
}
|
||||
|
||||
export interface RuntimeEnvironment {
|
||||
@ -164,7 +161,8 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
|
||||
colorProvider: {},
|
||||
foldingRangeProvider: true,
|
||||
selectionRangeProvider: true,
|
||||
renameProvider: true
|
||||
renameProvider: true,
|
||||
linkedEditingRangeProvider: true
|
||||
};
|
||||
return { capabilities };
|
||||
});
|
||||
@ -501,24 +499,28 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
|
||||
const position: Position = params.position;
|
||||
|
||||
if (document) {
|
||||
const htmlMode = languageModes.getMode('html');
|
||||
if (htmlMode && htmlMode.doRename) {
|
||||
return htmlMode.doRename(document, position, params.newName);
|
||||
const mode = languageModes.getModeAtPosition(document, params.position);
|
||||
|
||||
if (mode && mode.doRename) {
|
||||
return mode.doRename(document, position, params.newName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, null, `Error while computing rename for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
connection.onRequest(LinkedEditingRequest.type, (params, token) => {
|
||||
return runSafe(async () => {
|
||||
connection.languages.onLinkedEditingRange((params, token) => {
|
||||
return <any> /* todo remove when microsoft/vscode-languageserver-node#700 fixed */ runSafe(async () => {
|
||||
const document = documents.get(params.textDocument.uri);
|
||||
if (document) {
|
||||
const pos = params.position;
|
||||
if (pos.character > 0) {
|
||||
const mode = languageModes.getModeAtPosition(document, Position.create(pos.line, pos.character - 1));
|
||||
if (mode && mode.doLinkedEditing) {
|
||||
return mode.doLinkedEditing(document, pos);
|
||||
const ranges = await mode.doLinkedEditing(document, pos);
|
||||
if (ranges) {
|
||||
return { ranges };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -544,7 +546,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
|
||||
}, null, `Error while computing semantic tokens for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
connection.onRequest(SemanticTokenLegendRequest.type, (_params, token) => {
|
||||
connection.onRequest(SemanticTokenLegendRequest.type, token => {
|
||||
return runSafe(async () => {
|
||||
return getSemanticTokenProvider().legend;
|
||||
}, null, `Error while computing semantic tokens legend`, token);
|
||||
|
@ -188,6 +188,28 @@ export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
||||
}
|
||||
return null;
|
||||
},
|
||||
async doRename(document: TextDocument, position: Position, newName: string) {
|
||||
const jsDocument = jsDocuments.get(document);
|
||||
const jsLanguageService = await host.getLanguageService(jsDocument);
|
||||
const jsDocumentPosition = jsDocument.offsetAt(position);
|
||||
const { canRename } = jsLanguageService.getRenameInfo(jsDocument.uri, jsDocumentPosition);
|
||||
if (!canRename) {
|
||||
return null;
|
||||
}
|
||||
const renameInfos = jsLanguageService.findRenameLocations(jsDocument.uri, jsDocumentPosition, false, false);
|
||||
|
||||
const edits: TextEdit[] = [];
|
||||
renameInfos?.map(renameInfo => {
|
||||
edits.push({
|
||||
range: convertRange(jsDocument, renameInfo.textSpan),
|
||||
newText: newName,
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
changes: { [document.uri]: edits },
|
||||
};
|
||||
},
|
||||
async findDocumentHighlight(document: TextDocument, position: Position): Promise<DocumentHighlight[]> {
|
||||
const jsDocument = jsDocuments.get(document);
|
||||
const jsLanguageService = await host.getLanguageService(jsDocument);
|
||||
|
@ -45,7 +45,7 @@ export function newSemanticTokenProvider(languageModes: LanguageModes): Semantic
|
||||
}
|
||||
}
|
||||
}
|
||||
return encodeTokens(allTokens, ranges);
|
||||
return encodeTokens(allTokens, ranges, document);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -94,15 +94,13 @@ function applyModifiersMapping(tokens: SemanticTokenData[], modifiersMapping: nu
|
||||
}
|
||||
}
|
||||
|
||||
const fullRange = [Range.create(Position.create(0, 0), Position.create(Number.MAX_VALUE, 0))];
|
||||
|
||||
function encodeTokens(tokens: SemanticTokenData[], ranges?: Range[]): number[] {
|
||||
function encodeTokens(tokens: SemanticTokenData[], ranges: Range[] | undefined, document: TextDocument): number[] {
|
||||
|
||||
const resultTokens = tokens.sort((d1, d2) => d1.start.line - d2.start.line || d1.start.character - d2.start.character);
|
||||
if (ranges) {
|
||||
ranges = ranges.sort((d1, d2) => d1.start.line - d2.start.line || d1.start.character - d2.start.character);
|
||||
} else {
|
||||
ranges = fullRange;
|
||||
ranges = [Range.create(Position.create(0, 0), Position.create(document.lineCount, 0))];
|
||||
}
|
||||
|
||||
let rangeIndex = 0;
|
||||
|
@ -8,14 +8,14 @@ import { RequestType, Connection } from 'vscode-languageserver';
|
||||
import { RuntimeEnvironment } from './htmlServer';
|
||||
|
||||
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 {
|
||||
|
@ -0,0 +1,205 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { WorkspaceEdit, TextDocument, getLanguageModes, ClientCapabilities } from '../modes/languageModes';
|
||||
import { getNodeFSRequestService } from '../node/nodeFs';
|
||||
|
||||
|
||||
async function testRename(value: string, newName: string, expectedDocContent: string): Promise<void> {
|
||||
const offset = value.indexOf('|');
|
||||
value = value.substr(0, offset) + value.substr(offset + 1);
|
||||
|
||||
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
const workspace = {
|
||||
settings: {},
|
||||
folders: [{ name: 'foo', uri: 'test://foo' }]
|
||||
};
|
||||
const languageModes = getLanguageModes({ css: true, javascript: true }, workspace, ClientCapabilities.LATEST, getNodeFSRequestService());
|
||||
const javascriptMode = languageModes.getMode('javascript')
|
||||
const position = document.positionAt(offset);
|
||||
|
||||
if (javascriptMode) {
|
||||
const workspaceEdit: WorkspaceEdit | null = await javascriptMode.doRename!(document, position, newName);
|
||||
|
||||
if (!workspaceEdit || !workspaceEdit.changes) {
|
||||
assert.fail('No workspace edits');
|
||||
}
|
||||
|
||||
const edits = workspaceEdit.changes[document.uri.toString()];
|
||||
if (!edits) {
|
||||
assert.fail(`No edits for file at ${document.uri.toString()}`);
|
||||
}
|
||||
|
||||
const newDocContent = TextDocument.applyEdits(document, edits);
|
||||
assert.equal(newDocContent, expectedDocContent, `Expected: ${expectedDocContent}\nActual: ${newDocContent}`);
|
||||
} else {
|
||||
assert.fail('should have javascriptMode but no')
|
||||
}
|
||||
}
|
||||
|
||||
async function testNoRename(value: string, newName: string): Promise<void> {
|
||||
const offset = value.indexOf('|');
|
||||
value = value.substr(0, offset) + value.substr(offset + 1);
|
||||
|
||||
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
|
||||
const workspace = {
|
||||
settings: {},
|
||||
folders: [{ name: 'foo', uri: 'test://foo' }]
|
||||
};
|
||||
const languageModes = getLanguageModes({ css: true, javascript: true }, workspace, ClientCapabilities.LATEST, getNodeFSRequestService());
|
||||
const javascriptMode = languageModes.getMode('javascript')
|
||||
const position = document.positionAt(offset);
|
||||
|
||||
if (javascriptMode) {
|
||||
const workspaceEdit: WorkspaceEdit | null = await javascriptMode.doRename!(document, position, newName);
|
||||
|
||||
assert.ok(workspaceEdit?.changes === undefined, 'Should not rename but rename happened')
|
||||
} else {
|
||||
assert.fail('should have javascriptMode but no')
|
||||
}
|
||||
}
|
||||
|
||||
suite('HTML Javascript Rename', () => {
|
||||
test('Rename Variable', async () => {
|
||||
const input = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
'const |a = 2;',
|
||||
'const b = a + 2',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
const output = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
'const h = 2;',
|
||||
'const b = h + 2',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
await testRename(input.join('\n'), 'h', output.join('\n'))
|
||||
})
|
||||
|
||||
test('Rename Function', async () => {
|
||||
const input = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const name = 'cjg';`,
|
||||
'function |sayHello(name) {',
|
||||
`console.log('hello', name)`,
|
||||
'}',
|
||||
'sayHello(name)',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
const output = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const name = 'cjg';`,
|
||||
'function sayName(name) {',
|
||||
`console.log('hello', name)`,
|
||||
'}',
|
||||
'sayName(name)',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
await testRename(input.join('\n'), 'sayName', output.join('\n'))
|
||||
})
|
||||
|
||||
test('Rename Function Params', async () => {
|
||||
const input = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const name = 'cjg';`,
|
||||
'function sayHello(|name) {',
|
||||
`console.log('hello', name)`,
|
||||
'}',
|
||||
'sayHello(name)',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
const output = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const name = 'cjg';`,
|
||||
'function sayHello(newName) {',
|
||||
`console.log('hello', newName)`,
|
||||
'}',
|
||||
'sayHello(name)',
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
await testRename(input.join('\n'), 'newName', output.join('\n'))
|
||||
})
|
||||
|
||||
test('Rename Class', async () => {
|
||||
const input = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`class |Foo {}`,
|
||||
`const foo = new Foo()`,
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
const output = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`class Bar {}`,
|
||||
`const foo = new Bar()`,
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
await testRename(input.join('\n'), 'Bar', output.join('\n'))
|
||||
})
|
||||
|
||||
test('Cannot Rename literal', async () => {
|
||||
const stringLiteralInput = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const name = |'cjg';`,
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
const numberLiteralInput = [
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<script>',
|
||||
`const num = |2;`,
|
||||
'</script>',
|
||||
'</head>',
|
||||
'</html>'
|
||||
]
|
||||
|
||||
await testNoRename(stringLiteralInput.join('\n'), 'something')
|
||||
await testNoRename(numberLiteralInput.join('\n'), 'hhhh')
|
||||
})
|
||||
});
|
@ -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) {
|
||||
@ -41,5 +41,5 @@ export function runSafe<T>(func: () => Thenable<T>, errorVal: T, errorMessage: s
|
||||
|
||||
|
||||
function cancelValue<E>() {
|
||||
return new ResponseError<E>(ErrorCodes.RequestCancelled, 'Request cancelled');
|
||||
return new ResponseError<E>(LSPErrorCodes.RequestCancelled, 'Request cancelled');
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/node@^12.11.7":
|
||||
version "12.11.7"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.11.7.tgz#57682a9771a3f7b09c2497f28129a0462966524a"
|
||||
integrity sha512-JNbGaHFCLwgHn/iCckiGSOZ1XYHsKFwREtzPwSGCVld1SGhOlmZw2D4ZI94HQCrBHbADzW9m4LER/8olJTRGHA==
|
||||
"@types/node@^12.19.9":
|
||||
version "12.19.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.9.tgz#990ad687ad8b26ef6dcc34a4f69c33d40c95b679"
|
||||
integrity sha512-yj0DOaQeUrk3nJ0bd3Y5PeDRJ6W0r+kilosLA+dzF3dola/o9hxhMSg2sFvVcA2UHS5JSOsZp4S0c1OEXc4m1Q==
|
||||
|
||||
applicationinsights@1.0.8:
|
||||
version "1.0.8"
|
||||
@ -16,6 +16,24 @@ applicationinsights@1.0.8:
|
||||
diagnostic-channel-publishers "0.2.1"
|
||||
zone.js "0.7.6"
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
|
||||
diagnostic-channel-publishers@0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.2.1.tgz#8e2d607a8b6d79fe880b548bc58cc6beb288c4f3"
|
||||
@ -28,15 +46,31 @@ diagnostic-channel@0.2.0:
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
|
||||
lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
|
||||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
semver@^5.3.0:
|
||||
version "5.5.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477"
|
||||
integrity sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==
|
||||
|
||||
semver@^6.3.0:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
semver@^7.3.4:
|
||||
version "7.3.4"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
|
||||
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
vscode-extension-telemetry@0.1.1:
|
||||
version "0.1.1"
|
||||
@ -45,37 +79,43 @@ vscode-extension-telemetry@0.1.1:
|
||||
dependencies:
|
||||
applicationinsights "1.0.8"
|
||||
|
||||
vscode-jsonrpc@6.0.0-next.2:
|
||||
version "6.0.0-next.2"
|
||||
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0-next.2.tgz#3d73f86d812304cb91b9fb1efee40ec60b09ed7f"
|
||||
integrity sha512-dKQXRYNUY6BHALQJBJlyZyv9oWlYpbJ2vVoQNNVNPLAYQ3hzNp4zy+iSo7zGx1BPXByArJQDWTKLQh8dz3dnNw==
|
||||
vscode-jsonrpc@6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz#108bdb09b4400705176b957ceca9e0880e9b6d4e"
|
||||
integrity sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==
|
||||
|
||||
vscode-languageclient@7.0.0-next.5.1:
|
||||
version "7.0.0-next.5.1"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-7.0.0-next.5.1.tgz#ed93f14e4c2cdccedf15002c7bf8ef9cb638f36c"
|
||||
integrity sha512-OONvbk3IFpubwF8/Y5uPQaq5J5CEskpeET3SfK4iGlv5OUK+44JawH/SEW5wXuEPpfdMLEMZLuGLU5v5d7N7PQ==
|
||||
vscode-languageclient@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-7.0.0.tgz#b505c22c21ffcf96e167799757fca07a6bad0fb2"
|
||||
integrity sha512-P9AXdAPlsCgslpP9pRxYPqkNYV7Xq8300/aZDpO35j1fJm/ncize8iGswzYlcvFw5DQUx4eVk+KvfXdL0rehNg==
|
||||
dependencies:
|
||||
semver "^6.3.0"
|
||||
vscode-languageserver-protocol "3.16.0-next.4"
|
||||
minimatch "^3.0.4"
|
||||
semver "^7.3.4"
|
||||
vscode-languageserver-protocol "3.16.0"
|
||||
|
||||
vscode-languageserver-protocol@3.16.0-next.4:
|
||||
version "3.16.0-next.4"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0-next.4.tgz#8f8b1b831d4dfd9b26aa1ba3d2a32c427a91c99f"
|
||||
integrity sha512-6GmPUp2MhJy2H1CTWp2B40Pa9BeC9glrXWmQWVG6A/0V9UbcAjVC9m56znm2GL32iyLDIprTBe8gBvvvcjbpaQ==
|
||||
vscode-languageserver-protocol@3.16.0:
|
||||
version "3.16.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz#34135b61a9091db972188a07d337406a3cdbe821"
|
||||
integrity sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==
|
||||
dependencies:
|
||||
vscode-jsonrpc "6.0.0-next.2"
|
||||
vscode-languageserver-types "3.16.0-next.2"
|
||||
vscode-jsonrpc "6.0.0"
|
||||
vscode-languageserver-types "3.16.0"
|
||||
|
||||
vscode-languageserver-types@3.16.0-next.2:
|
||||
version "3.16.0-next.2"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0-next.2.tgz#940bd15c992295a65eae8ab6b8568a1e8daa3083"
|
||||
integrity sha512-QjXB7CKIfFzKbiCJC4OWC8xUncLsxo19FzGVp/ADFvvi87PlmBSCAtZI5xwGjF5qE0xkLf0jjKUn3DzmpDP52Q==
|
||||
vscode-languageserver-types@3.16.0:
|
||||
version "3.16.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247"
|
||||
integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==
|
||||
|
||||
vscode-nls@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
|
||||
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
|
||||
|
||||
yallist@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
|
||||
|
||||
zone.js@0.7.6:
|
||||
version "0.7.6"
|
||||
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.7.6.tgz#fbbc39d3e0261d0986f1ba06306eb3aeb0d22009"
|
||||
|
Reference in New Issue
Block a user