Skip to content

Commit a0eeb3f

Browse files
committed
Merge branch 'lsp-3.16'
2 parents e10f4df + 8292d01 commit a0eeb3f

25 files changed

+626
-337
lines changed

.github/workflows/ci.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,8 @@ jobs:
7070
yarn --frozen-lockfile
7171
yarn compile
7272
73-
- name: Start xvfb
74-
if: matrix.os == 'ubuntu-latest'
75-
run: |
76-
set -e
77-
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
78-
disown -ar
79-
echo "Started xvfb"
80-
73+
# https://github.com/microsoft/vscode/issues/106569#issuecomment-717450642
8174
- name: Server and E2E test
82-
run: yarn test
83-
env:
84-
DISPLAY: :10
75+
uses: GabrielBB/[email protected]
76+
with:
77+
run: yarn test

client/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
TransportKind,
77
LanguageClientOptions,
88
DocumentFilter
9-
} from 'vscode-languageclient';
9+
} from 'vscode-languageclient/node';
1010
import { resolve } from 'path';
1111
import { existsSync } from 'fs';
1212

client/commands/doctorCommand.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import vscode from 'vscode';
2-
import { LanguageClient } from 'vscode-languageclient';
2+
import { LanguageClient } from 'vscode-languageclient/node';
33

4-
export function generateDoctorCommand (client: LanguageClient) {
4+
export function generateDoctorCommand(client: LanguageClient) {
55
return async () => {
66
if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document.fileName.endsWith('.vue')) {
7-
return vscode.window.showInformationMessage(
8-
'Failed to doctor. Make sure the current file is a .vue file.'
9-
);
7+
return vscode.window.showInformationMessage('Failed to doctor. Make sure the current file is a .vue file.');
108
}
119

1210
const fileName = vscode.window.activeTextEditor.document.fileName;
1311

14-
const result = await client.sendRequest('$/doctor', { fileName }) as string;
12+
const result = (await client.sendRequest('$/doctor', { fileName })) as string;
1513
const showText = result.slice(0, 1000) + '....';
1614
const action = await vscode.window.showInformationMessage(showText, { modal: true }, 'Ok', 'Copy');
1715
if (action === 'Copy') {

client/commands/virtualFileCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import vscode from 'vscode';
2-
import { LanguageClient } from 'vscode-languageclient';
2+
import { LanguageClient } from 'vscode-languageclient/node';
33

44
let fileName = '';
55
let virtualFileSource = '';

client/vueMain.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import vscode from 'vscode';
2-
import { LanguageClient } from 'vscode-languageclient';
2+
import { LanguageClient } from 'vscode-languageclient/node';
33
import { generateGrammarCommandHandler } from './commands/generateGrammarCommand';
44
import { registerLanguageConfigurations } from './languages';
55
import { initializeLanguageClient } from './client';
@@ -56,7 +56,7 @@ export async function activate(context: vscode.ExtensionContext) {
5656
registerCustomLSPCommands(context, client);
5757
registerRestartVLSCommand(context, client);
5858
})
59-
.catch(e => {
59+
.catch((e: Error) => {
6060
console.error(e.stack);
6161
console.log('Client initialization failed');
6262
});

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"Programming Languages"
5656
],
5757
"engines": {
58-
"vscode": "^1.47.0"
58+
"vscode": "^1.52.0"
5959
},
6060
"activationEvents": [
6161
"onLanguage:vue"
@@ -554,27 +554,27 @@
554554
"devDependencies": {
555555
"@rollup/plugin-commonjs": "^17.0.0",
556556
"@rollup/plugin-json": "^4.1.0",
557-
"@rollup/plugin-node-resolve": "^11.0.1",
557+
"@rollup/plugin-node-resolve": "^11.1.0",
558558
"@rollup/plugin-replace": "^2.3.3",
559559
"@types/glob": "^7.1.3",
560-
"@types/js-yaml": "^3.12.5",
561-
"@types/lodash": "^4.14.167",
560+
"@types/js-yaml": "^4.0.0",
561+
"@types/lodash": "^4.14.168",
562562
"@types/minimist": "^1.2.1",
563563
"@types/mocha": "^8.2.0",
564-
"@types/node": "^14.14.20",
564+
"@types/node": "^14.14.22",
565565
"@types/shelljs": "^0.8.8",
566-
"@types/vscode": "^1.47.0",
567-
"esbuild": "^0.8.32",
568-
"fs-extra": "^9.0.1",
566+
"@types/vscode": "^1.52.0",
567+
"esbuild": "^0.8.33",
568+
"fs-extra": "^9.1.0",
569569
"glob": "^7.1.6",
570-
"husky": "^4.3.7",
571-
"js-yaml": "^3.14.1",
570+
"husky": "^4.3.8",
571+
"js-yaml": "^4.0.0",
572572
"lint-staged": "^10.5.3",
573573
"minimist": "^1.2.5",
574574
"mocha": "^8.2.1",
575575
"npm-run-all": "^4.1.5",
576576
"prettier": "^2.2.1",
577-
"rollup": "^2.36.1",
577+
"rollup": "^2.37.1",
578578
"rollup-plugin-delete": "^2.0.0",
579579
"rollup-plugin-dts": "^2.0.1",
580580
"rollup-plugin-terser": "^7.0.2",
@@ -583,8 +583,8 @@
583583
"ts-node": "^9.1.1",
584584
"tslint": "^6.1.3",
585585
"typescript": "^4.1.3",
586-
"vscode-languageclient": "^6.1.3",
587-
"vscode-languageserver-types": "^3.15.1",
586+
"vscode-languageclient": "^7.0.0",
587+
"vscode-languageserver-types": "^3.16.0",
588588
"vscode-test": "^1.4.1"
589589
}
590590
}

scripts/build_grammar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import glob from 'glob';
2-
import { safeLoad } from 'js-yaml';
2+
import { load } from 'js-yaml';
33
import { writeFileSync, readFileSync } from 'fs';
44
import { parse } from 'path';
55
import { getGeneratedGrammar } from '../client/grammar';
@@ -9,7 +9,7 @@ glob('syntaxes/**/*.yaml', { nocase: true }, (_, files) => {
99
const pathData = parse(file);
1010
writeFileSync(
1111
pathData.dir + '/' + pathData.name + '.tmLanguage.json',
12-
JSON.stringify(safeLoad(readFileSync(file).toString()), null, 2)
12+
JSON.stringify(load(readFileSync(file).toString()), null, 2)
1313
);
1414
}
1515

server/package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"homepage": "https://github.com/vuejs/vetur/tree/master/server",
2424
"dependencies": {
25-
"eslint": "^7.17.0",
25+
"eslint": "^7.18.0",
2626
"eslint-plugin-vue": "^7.4.1",
2727
"prettier": "^2.2.1",
2828
"tslint": "6.1.3",
@@ -39,40 +39,40 @@
3939
"@types/eslint-visitor-keys": "^1.0.0",
4040
"@types/glob": "^7.1.3",
4141
"@types/js-beautify": "1.13.1",
42-
"@types/lodash": "^4.14.167",
42+
"@types/lodash": "^4.14.168",
4343
"@types/mocha": "^8.2.0",
44-
"@types/node": "^14.14.20",
44+
"@types/node": "^14.14.22",
4545
"@types/prettier": "^2.1.6",
4646
"@types/read-pkg-up": "^6.0.0",
4747
"@types/resolve": "1.17.1",
4848
"bootstrap-vue-helper-json": "^1.1.1",
4949
"codecov": "^3.8.1",
50-
"core-js": "^3.8.2",
50+
"core-js": "^3.8.3",
5151
"element-helper-json": "^2.0.6",
52-
"fast-glob": "^3.2.4",
52+
"fast-glob": "^3.2.5",
5353
"glob": "^7.1.6",
5454
"gridsome-helper-json": "^1.0.3",
55-
"js-beautify": "^1.13.1",
55+
"js-beautify": "^1.13.4",
5656
"lodash": "^4.17.20",
5757
"mocha": "^8.2.1",
5858
"nuxt-helper-json": "^1.0.0",
5959
"nyc": "^15.1.0",
6060
"parse-gitignore": "^1.0.1",
6161
"prettier-eslint": "^12.0.0",
6262
"prettier-tslint": "^0.4.2",
63-
"rollup": "^2.36.1",
63+
"rollup": "^2.37.1",
6464
"sass-formatter": "^0.5.2",
6565
"source-map-support": "^0.5.19",
6666
"stylus": "^0.54.8",
6767
"stylus-supremacy": "^2.14.5",
68-
"vscode-css-languageservice": "4.4.0",
69-
"vscode-emmet-helper": "2.0.9",
70-
"vscode-languageserver": "7.0.0-next.11",
68+
"vscode-css-languageservice": "5.0.2",
69+
"vscode-emmet-helper": "2.2.4-2",
70+
"vscode-languageserver": "7.0.0",
7171
"vscode-languageserver-textdocument": "^1.0.1",
72-
"vscode-languageserver-types": "3.16.0-next.5",
73-
"vscode-uri": "^2.1.2",
72+
"vscode-languageserver-types": "3.16.0",
73+
"vscode-uri": "^3.0.2",
7474
"vscode-web-custom-data": "^0.3.2",
75-
"vue-eslint-parser": "^7.3.0",
75+
"vue-eslint-parser": "^7.4.1",
7676
"vue-onsenui-helper-json": "^1.0.2"
7777
},
7878
"scripts": {

server/src/embeddedSupport/languageModes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { getCSSMode, getSCSSMode, getLESSMode, getPostCSSMode } from '../modes/s
3030
import { getJavascriptMode } from '../modes/script/javascript';
3131
import { VueHTMLMode } from '../modes/template';
3232
import { getStylusMode } from '../modes/style/stylus';
33-
import { DocumentContext, RefactorAction } from '../types';
33+
import { DocumentContext, CodeActionData } from '../types';
3434
import { VueInfoService } from '../services/vueInfoService';
3535
import { DependencyService } from '../services/dependencyService';
3636
import { nullMode } from '../modes/nullMode';
@@ -58,7 +58,7 @@ export interface LanguageMode {
5858
formatParams: FormattingOptions,
5959
context: CodeActionContext
6060
): CodeAction[];
61-
getRefactorEdits?(doc: TextDocument, args: RefactorAction): WorkspaceEdit;
61+
doCodeActionResolve?(document: TextDocument, action: CodeAction): CodeAction;
6262
doComplete?(document: TextDocument, position: Position): CompletionList;
6363
doResolve?(document: TextDocument, item: CompletionItem): CompletionItem;
6464
doHover?(document: TextDocument, position: Position): Hover;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import { CodeActionKind } from 'vscode-languageserver';
6+
7+
export interface TSCodeActionKind {
8+
kind: CodeActionKind;
9+
matches(refactor: { actionName: string }): boolean;
10+
}
11+
12+
/* tslint:disable:variable-name */
13+
const Extract_Function = Object.freeze<TSCodeActionKind>({
14+
kind: CodeActionKind.RefactorExtract + '.function',
15+
matches: refactor => refactor.actionName.startsWith('function_')
16+
});
17+
18+
const Extract_Constant = Object.freeze<TSCodeActionKind>({
19+
kind: CodeActionKind.RefactorExtract + '.constant',
20+
matches: refactor => refactor.actionName.startsWith('constant_')
21+
});
22+
23+
const Extract_Type = Object.freeze<TSCodeActionKind>({
24+
kind: CodeActionKind.RefactorExtract + '.type',
25+
matches: refactor => refactor.actionName.startsWith('Extract to type alias')
26+
});
27+
28+
const Extract_Interface = Object.freeze<TSCodeActionKind>({
29+
kind: CodeActionKind.RefactorExtract + '.interface',
30+
matches: refactor => refactor.actionName.startsWith('Extract to interface')
31+
});
32+
33+
const Move_NewFile = Object.freeze<TSCodeActionKind>({
34+
kind: CodeActionKind.Refactor + '.move' + '.newFile',
35+
matches: refactor => refactor.actionName.startsWith('Move to a new file')
36+
});
37+
38+
const Rewrite_Import = Object.freeze<TSCodeActionKind>({
39+
kind: CodeActionKind.RefactorRewrite + '.import',
40+
matches: refactor =>
41+
refactor.actionName.startsWith('Convert namespace import') ||
42+
refactor.actionName.startsWith('Convert named imports')
43+
});
44+
45+
const Rewrite_Export = Object.freeze<TSCodeActionKind>({
46+
kind: CodeActionKind.RefactorRewrite + '.export',
47+
matches: refactor =>
48+
refactor.actionName.startsWith('Convert default export') || refactor.actionName.startsWith('Convert named export')
49+
});
50+
51+
const Rewrite_Arrow_Braces = Object.freeze<TSCodeActionKind>({
52+
kind: CodeActionKind.RefactorRewrite + '.arrow' + '.braces',
53+
matches: refactor =>
54+
refactor.actionName.startsWith('Convert default export') || refactor.actionName.startsWith('Convert named export')
55+
});
56+
57+
const Rewrite_Parameters_ToDestructured = Object.freeze<TSCodeActionKind>({
58+
kind: CodeActionKind.RefactorRewrite + '.parameters' + '.toDestructured',
59+
matches: refactor => refactor.actionName.startsWith('Convert parameters to destructured object')
60+
});
61+
62+
const Rewrite_Property_GenerateAccessors = Object.freeze<TSCodeActionKind>({
63+
kind: CodeActionKind.RefactorRewrite + '.property' + '.generateAccessors',
64+
matches: refactor => refactor.actionName.startsWith("Generate 'get' and 'set' accessors")
65+
});
66+
/* tslint:enable:variable-name */
67+
68+
const allKnownCodeActionKinds = [
69+
Extract_Function,
70+
Extract_Constant,
71+
Extract_Type,
72+
Extract_Interface,
73+
Move_NewFile,
74+
Rewrite_Import,
75+
Rewrite_Export,
76+
Rewrite_Arrow_Braces,
77+
Rewrite_Parameters_ToDestructured,
78+
Rewrite_Property_GenerateAccessors
79+
];
80+
81+
export function getCodeActionKind(refactor: { actionName: string }): CodeActionKind {
82+
return allKnownCodeActionKinds.find(kind => kind.matches(refactor))?.kind ?? CodeActionKind.Refactor;
83+
}

0 commit comments

Comments
 (0)