@volar/test-utils 2.4.30 → 3.0.0-alpha.0
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/index.d.ts +3 -3
- package/index.js +41 -8
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type LanguageServerHandle = ReturnType<typeof startLanguageServer>;
|
|
|
6
6
|
export declare function startLanguageServer(serverModule: string, cwd?: string | URL): {
|
|
7
7
|
process: cp.ChildProcess;
|
|
8
8
|
connection: _.ProtocolConnection;
|
|
9
|
-
initialize(rootUri: string | _.WorkspaceFolder[], initializationOptions: _._InitializeParams[
|
|
9
|
+
initialize(rootUri: string | _.WorkspaceFolder[], initializationOptions: _._InitializeParams['initializationOptions'], capabilities?: _.ClientCapabilities, locale?: string): Promise<_.InitializeResult<any>>;
|
|
10
10
|
shutdown(): Promise<void>;
|
|
11
11
|
openTextDocument(fileName: string, languageId: string): Promise<TextDocument>;
|
|
12
12
|
openUntitledDocument(languageId: string, content: string): Promise<TextDocument>;
|
|
@@ -26,8 +26,8 @@ export declare function startLanguageServer(serverModule: string, cwd?: string |
|
|
|
26
26
|
sendFoldingRangesRequest(uri: string): Promise<_.FoldingRange[] | null>;
|
|
27
27
|
sendDocumentSymbolRequest(uri: string): Promise<_.DocumentSymbol[] | _.SymbolInformation[] | null>;
|
|
28
28
|
sendDocumentColorRequest(uri: string): Promise<_.ColorInformation[]>;
|
|
29
|
-
sendDefinitionRequest(uri: string, position: _.Position): Promise<_.
|
|
30
|
-
sendTypeDefinitionRequest(uri: string, position: _.Position): Promise<_.
|
|
29
|
+
sendDefinitionRequest(uri: string, position: _.Position): Promise<_.LocationLink[] | _.Definition | null>;
|
|
30
|
+
sendTypeDefinitionRequest(uri: string, position: _.Position): Promise<_.LocationLink[] | _.Definition | null>;
|
|
31
31
|
sendReferencesRequest(uri: string, position: _.Position, context: _.ReferenceContext): Promise<_.Location[] | null>;
|
|
32
32
|
sendSignatureHelpRequest(uri: string, position: _.Position): Promise<_.SignatureHelp | null>;
|
|
33
33
|
sendSelectionRangesRequest(uri: string, positions: _.Position[]): Promise<_.SelectionRange[] | null>;
|
package/index.js
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.startLanguageServer = startLanguageServer;
|
|
4
37
|
exports.printSnapshots = printSnapshots;
|
|
5
38
|
exports.printSnapshot = printSnapshot;
|
|
6
39
|
const language_core_1 = require("@volar/language-core");
|
|
7
|
-
const _ = require("@volar/language-server/node");
|
|
8
|
-
const
|
|
9
|
-
const cp = require("child_process");
|
|
10
|
-
const fs = require("fs");
|
|
40
|
+
const _ = __importStar(require("@volar/language-server/node"));
|
|
41
|
+
const assert_1 = require("assert");
|
|
42
|
+
const cp = __importStar(require("child_process"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
11
44
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
12
45
|
const vscode_uri_1 = require("vscode-uri");
|
|
13
46
|
function startLanguageServer(serverModule, cwd) {
|
|
@@ -117,7 +150,7 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
117
150
|
return document;
|
|
118
151
|
},
|
|
119
152
|
closeTextDocument(uri) {
|
|
120
|
-
|
|
153
|
+
(0, assert_1.ok)(openedDocuments.has(uri));
|
|
121
154
|
openedDocuments.delete(uri);
|
|
122
155
|
return connection.sendNotification(_.DidCloseTextDocumentNotification.type, {
|
|
123
156
|
textDocument: { uri },
|
|
@@ -125,7 +158,7 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
125
158
|
},
|
|
126
159
|
async updateTextDocument(uri, edits) {
|
|
127
160
|
let document = openedDocuments.get(uri);
|
|
128
|
-
|
|
161
|
+
(0, assert_1.ok)(document);
|
|
129
162
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
130
163
|
document = vscode_languageserver_textdocument_1.TextDocument.create(uri, document.languageId, document.version + 1, newText);
|
|
131
164
|
documentVersions.set(uri, document.version);
|
|
@@ -154,7 +187,7 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
154
187
|
position,
|
|
155
188
|
});
|
|
156
189
|
// @volar/language-server only returns CompletionList
|
|
157
|
-
|
|
190
|
+
(0, assert_1.ok)(!Array.isArray(result));
|
|
158
191
|
return result;
|
|
159
192
|
},
|
|
160
193
|
sendCompletionResolveRequest(item) {
|
|
@@ -347,7 +380,7 @@ function* printSnapshot(sourceScript, file) {
|
|
|
347
380
|
yield [lineHead, normalizeLogText(line)].join(' ');
|
|
348
381
|
const logs = [];
|
|
349
382
|
for (let offset = 0; offset < line.length; offset++) {
|
|
350
|
-
for (const
|
|
383
|
+
for (const { position: sourceOffset, segment: mapping } of map.virtualToOriginalPositions(lineOffset + offset)) {
|
|
351
384
|
let log = logs.find(log => log.mapping === mapping && log.lineOffset + log.length + 1 === offset);
|
|
352
385
|
if (log) {
|
|
353
386
|
log.length++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/test-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"directory": "packages/test-utils"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "
|
|
16
|
-
"@volar/language-server": "
|
|
15
|
+
"@volar/language-core": "3.0.0-alpha.0",
|
|
16
|
+
"@volar/language-server": "3.0.0-alpha.0",
|
|
17
17
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
18
18
|
"vscode-uri": "^3.0.8"
|
|
19
19
|
}
|