@volar/test-utils 2.3.0-alpha.9 → 2.3.1
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 +1 -2
- package/index.js +6 -7
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import * as _ from '@volar/language-server/node';
|
|
3
2
|
import * as cp from 'child_process';
|
|
4
3
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
@@ -7,7 +6,7 @@ export type LanguageServerHandle = ReturnType<typeof startLanguageServer>;
|
|
|
7
6
|
export declare function startLanguageServer(serverModule: string, cwd?: string | URL): {
|
|
8
7
|
process: cp.ChildProcess;
|
|
9
8
|
connection: _.ProtocolConnection;
|
|
10
|
-
initialize(rootUri: string, initializationOptions: _._InitializeParams[
|
|
9
|
+
initialize(rootUri: string, initializationOptions: _._InitializeParams["initializationOptions"], capabilities?: _.ClientCapabilities, locale?: string): Promise<_.InitializeResult<any>>;
|
|
11
10
|
shutdown(): Promise<void>;
|
|
12
11
|
openTextDocument(fileName: string, languageId: string): Promise<TextDocument>;
|
|
13
12
|
openUntitledDocument(content: string, languageId: string): Promise<TextDocument>;
|
package/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.startLanguageServer = startLanguageServer;
|
|
4
|
+
exports.printSnapshots = printSnapshots;
|
|
5
|
+
exports.printSnapshot = printSnapshot;
|
|
6
|
+
const language_core_1 = require("@volar/language-core");
|
|
4
7
|
const _ = require("@volar/language-server/node");
|
|
5
8
|
const assert = require("assert");
|
|
6
9
|
const cp = require("child_process");
|
|
7
10
|
const fs = require("fs");
|
|
8
11
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
9
12
|
const vscode_uri_1 = require("vscode-uri");
|
|
10
|
-
const language_core_1 = require("@volar/language-core");
|
|
11
13
|
function startLanguageServer(serverModule, cwd) {
|
|
12
14
|
const childProcess = cp.fork(serverModule, ['--stdio', `--clientProcessId=${process.pid.toString()}`], {
|
|
13
15
|
execArgv: ['--nolazy'],
|
|
@@ -302,7 +304,6 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
302
304
|
return result;
|
|
303
305
|
}
|
|
304
306
|
}
|
|
305
|
-
exports.startLanguageServer = startLanguageServer;
|
|
306
307
|
function* printSnapshots(sourceScript) {
|
|
307
308
|
if (sourceScript.generated) {
|
|
308
309
|
let lastId = 0;
|
|
@@ -315,7 +316,6 @@ function* printSnapshots(sourceScript) {
|
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
}
|
|
318
|
-
exports.printSnapshots = printSnapshots;
|
|
319
319
|
function* printSnapshot(sourceScript, file) {
|
|
320
320
|
const sourceCode = sourceScript.snapshot.getText(0, sourceScript.snapshot.getLength());
|
|
321
321
|
const sourceFileDocument = vscode_languageserver_textdocument_1.TextDocument.create('', '', 0, sourceCode);
|
|
@@ -325,14 +325,14 @@ function* printSnapshot(sourceScript, file) {
|
|
|
325
325
|
virtualCodeLines[i] += '\n';
|
|
326
326
|
}
|
|
327
327
|
let lineOffset = 0;
|
|
328
|
-
const map =
|
|
328
|
+
const map = (0, language_core_1.defaultMapperFactory)(file.mappings);
|
|
329
329
|
for (let i = 0; i < virtualCodeLines.length; i++) {
|
|
330
330
|
const line = virtualCodeLines[i];
|
|
331
331
|
const lineHead = `[${i + 1}]`;
|
|
332
332
|
yield [lineHead, normalizeLogText(line)].join(' ');
|
|
333
333
|
const logs = [];
|
|
334
334
|
for (let offset = 0; offset < line.length; offset++) {
|
|
335
|
-
for (const [sourceOffset, mapping] of map.
|
|
335
|
+
for (const [sourceOffset, mapping] of map.toSourceLocation(lineOffset + offset)) {
|
|
336
336
|
let log = logs.find(log => log.mapping === mapping && log.lineOffset + log.length + 1 === offset);
|
|
337
337
|
if (log) {
|
|
338
338
|
log.length++;
|
|
@@ -392,7 +392,6 @@ function* printSnapshot(sourceScript, file) {
|
|
|
392
392
|
lineOffset += line.length;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
exports.printSnapshot = printSnapshot;
|
|
396
395
|
function normalizeLogText(text) {
|
|
397
396
|
return text
|
|
398
397
|
.replace(/\t/g, '→')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/test-utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"@types/node": "latest"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "2.3.
|
|
19
|
-
"@volar/language-server": "2.3.
|
|
18
|
+
"@volar/language-core": "2.3.1",
|
|
19
|
+
"@volar/language-server": "2.3.1",
|
|
20
20
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
21
21
|
"vscode-uri": "^3.0.8"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "51742317a2950abd97e1a1a266b2c137bede4ad3"
|
|
24
24
|
}
|