@volar/vscode 1.4.0-alpha.2 → 1.4.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.d.ts +3 -1
- package/out/index.js +63 -3
- package/package.json +4 -4
- package/out/features/showReferences.d.ts +0 -3
- package/out/features/showReferences.js +0 -25
package/out/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export { activate as activateFindFileReferences } from './features/fileReference
|
|
|
6
6
|
export { activate as activateReloadProjects } from './features/reloadProject';
|
|
7
7
|
export { activate as activateServerStats } from './features/serverStatus';
|
|
8
8
|
export { activate as activateTsConfigStatusItem } from './features/tsconfig';
|
|
9
|
-
export { activate as activateShowReferences } from './features/showReferences';
|
|
10
9
|
export { activate as activateServerSys } from './features/serverSys';
|
|
11
10
|
export { activate as activateTsVersionStatusItem, getTsdk } from './features/tsVersion';
|
|
12
11
|
export declare function takeOverModeActive(context: vscode.ExtensionContext): boolean;
|
|
12
|
+
import * as lsp from 'vscode-languageclient';
|
|
13
|
+
export declare const middleware: lsp.Middleware;
|
|
14
|
+
export declare function parseServerCommand(command: vscode.Command): vscode.Command;
|
package/out/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.parseServerCommand = exports.middleware = exports.takeOverModeActive = exports.getTsdk = exports.activateTsVersionStatusItem = exports.activateServerSys = exports.activateTsConfigStatusItem = exports.activateServerStats = exports.activateReloadProjects = exports.activateFindFileReferences = exports.activateWriteVirtualFiles = exports.activateShowVirtualFiles = exports.activateAutoInsertion = void 0;
|
|
3
3
|
const vscode = require("vscode");
|
|
4
4
|
var autoInsertion_1 = require("./features/autoInsertion");
|
|
5
5
|
Object.defineProperty(exports, "activateAutoInsertion", { enumerable: true, get: function () { return autoInsertion_1.activate; } });
|
|
@@ -15,8 +15,6 @@ var serverStatus_1 = require("./features/serverStatus");
|
|
|
15
15
|
Object.defineProperty(exports, "activateServerStats", { enumerable: true, get: function () { return serverStatus_1.activate; } });
|
|
16
16
|
var tsconfig_1 = require("./features/tsconfig");
|
|
17
17
|
Object.defineProperty(exports, "activateTsConfigStatusItem", { enumerable: true, get: function () { return tsconfig_1.activate; } });
|
|
18
|
-
var showReferences_1 = require("./features/showReferences");
|
|
19
|
-
Object.defineProperty(exports, "activateShowReferences", { enumerable: true, get: function () { return showReferences_1.activate; } });
|
|
20
18
|
var serverSys_1 = require("./features/serverSys");
|
|
21
19
|
Object.defineProperty(exports, "activateServerSys", { enumerable: true, get: function () { return serverSys_1.activate; } });
|
|
22
20
|
var tsVersion_1 = require("./features/tsVersion");
|
|
@@ -29,4 +27,66 @@ function takeOverModeActive(context) {
|
|
|
29
27
|
return false;
|
|
30
28
|
}
|
|
31
29
|
exports.takeOverModeActive = takeOverModeActive;
|
|
30
|
+
exports.middleware = {
|
|
31
|
+
async provideCodeActions(document, range, context, token, next) {
|
|
32
|
+
let actions = await next(document, range, context, token);
|
|
33
|
+
actions = actions?.map(action => {
|
|
34
|
+
if (!(action instanceof vscode.CodeAction)) {
|
|
35
|
+
return parseServerCommand(action);
|
|
36
|
+
}
|
|
37
|
+
if (action.command) {
|
|
38
|
+
action.command = parseServerCommand(action.command);
|
|
39
|
+
}
|
|
40
|
+
return action;
|
|
41
|
+
});
|
|
42
|
+
return actions;
|
|
43
|
+
},
|
|
44
|
+
async resolveCodeAction(item, token, next) {
|
|
45
|
+
const action = await next(item, token);
|
|
46
|
+
if (action?.command) {
|
|
47
|
+
action.command = parseServerCommand(action.command);
|
|
48
|
+
}
|
|
49
|
+
return action;
|
|
50
|
+
},
|
|
51
|
+
async provideCodeLenses(document, token, next) {
|
|
52
|
+
let codeLenses = await next(document, token);
|
|
53
|
+
codeLenses = codeLenses?.map(action => {
|
|
54
|
+
if (action.command) {
|
|
55
|
+
action.command = parseServerCommand(action.command);
|
|
56
|
+
}
|
|
57
|
+
return action;
|
|
58
|
+
});
|
|
59
|
+
return codeLenses;
|
|
60
|
+
},
|
|
61
|
+
async resolveCodeLens(item, token, next) {
|
|
62
|
+
const codeLens = await next(item, token);
|
|
63
|
+
if (codeLens?.command) {
|
|
64
|
+
codeLens.command = parseServerCommand(codeLens.command);
|
|
65
|
+
}
|
|
66
|
+
return codeLens;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
function parseServerCommand(command) {
|
|
70
|
+
if (command.command === 'editor.action.rename' && command.arguments) {
|
|
71
|
+
return {
|
|
72
|
+
...command,
|
|
73
|
+
arguments: [[
|
|
74
|
+
vscode.Uri.parse(command.arguments[0]),
|
|
75
|
+
new vscode.Position(command.arguments[1].line, command.arguments[1].character),
|
|
76
|
+
]],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else if (command.command === 'editor.action.showReferences' && command.arguments) {
|
|
80
|
+
return {
|
|
81
|
+
...command,
|
|
82
|
+
arguments: [
|
|
83
|
+
vscode.Uri.parse(command.arguments[0]),
|
|
84
|
+
new vscode.Position(command.arguments[1].line, command.arguments[1].character),
|
|
85
|
+
command.arguments[2].map((ref) => new vscode.Location(vscode.Uri.parse(ref.uri), new vscode.Range(ref.range.start.line, ref.range.start.character, ref.range.end.line, ref.range.end.character))),
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return command;
|
|
90
|
+
}
|
|
91
|
+
exports.parseServerCommand = parseServerCommand;
|
|
32
92
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/vscode",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.3",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/vscode"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-server": "1.4.0-alpha.
|
|
17
|
-
"@volar/source-map": "1.4.0-alpha.
|
|
16
|
+
"@volar/language-server": "1.4.0-alpha.3",
|
|
17
|
+
"@volar/source-map": "1.4.0-alpha.3",
|
|
18
18
|
"typesafe-path": "^0.2.2",
|
|
19
19
|
"vscode-nls": "^5.2.0"
|
|
20
20
|
},
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"@types/vscode": "*",
|
|
27
27
|
"vscode-languageclient": "*"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "033129d71b355a0f5bbf514c6887ed3a6e083c21"
|
|
30
30
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.activate = void 0;
|
|
3
|
-
const vscode = require("vscode");
|
|
4
|
-
const vscode_languageclient_1 = require("vscode-languageclient");
|
|
5
|
-
const language_server_1 = require("@volar/language-server");
|
|
6
|
-
async function activate(client) {
|
|
7
|
-
const subscriptions = [];
|
|
8
|
-
addHandle();
|
|
9
|
-
subscriptions.push(client.onDidChangeState(() => {
|
|
10
|
-
if (client.state === vscode_languageclient_1.State.Running) {
|
|
11
|
-
addHandle();
|
|
12
|
-
}
|
|
13
|
-
}));
|
|
14
|
-
return vscode.Disposable.from(...subscriptions);
|
|
15
|
-
function addHandle() {
|
|
16
|
-
subscriptions.push(client.onNotification(language_server_1.ShowReferencesNotification.type, params => {
|
|
17
|
-
const uri = params.textDocument.uri;
|
|
18
|
-
const pos = params.position;
|
|
19
|
-
const refs = params.references;
|
|
20
|
-
vscode.commands.executeCommand('editor.action.showReferences', vscode.Uri.parse(uri), new vscode.Position(pos.line, pos.character), refs.map(ref => new vscode.Location(vscode.Uri.parse(ref.uri), new vscode.Range(ref.range.start.line, ref.range.start.character, ref.range.end.line, ref.range.end.character))));
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.activate = activate;
|
|
25
|
-
//# sourceMappingURL=showReferences.js.map
|