@volar/test-utils 2.0.0-alpha.13 → 2.0.0-alpha.14
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 +13 -13
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import * as _ from '@volar/language-server/node';
|
|
3
4
|
import * as cp from 'child_process';
|
|
4
5
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
@@ -35,8 +36,7 @@ export declare function startLanguageServer(serverModule: string, cwd?: string |
|
|
|
35
36
|
sendDocumentLinkRequest(uri: string): Promise<_.DocumentLink[] | null>;
|
|
36
37
|
sendDocumentLinkResolveRequest(link: _.DocumentLink): Promise<_.DocumentLink>;
|
|
37
38
|
};
|
|
38
|
-
export declare function printSnapshots(sourceFile: _.SourceFile
|
|
39
|
+
export declare function printSnapshots(sourceFile: _.SourceFile): Generator<string, void, unknown>;
|
|
39
40
|
export declare function printSnapshot(sourceFile: {
|
|
40
|
-
fileName: string;
|
|
41
41
|
snapshot: _.SourceFile['snapshot'];
|
|
42
|
-
}, file: _.
|
|
42
|
+
}, file: _.VirtualCode): Generator<string, void, unknown>;
|
package/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const _ = require("@volar/language-server/node");
|
|
|
5
5
|
const assert = require("assert");
|
|
6
6
|
const cp = require("child_process");
|
|
7
7
|
const fs = require("fs");
|
|
8
|
-
const path = require("path");
|
|
9
8
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
10
9
|
const vscode_uri_1 = require("vscode-uri");
|
|
11
10
|
const language_core_1 = require("@volar/language-core");
|
|
@@ -19,9 +18,9 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
19
18
|
const openedDocuments = new Map();
|
|
20
19
|
let untitledCounter = 0;
|
|
21
20
|
connection.listen();
|
|
22
|
-
connection.onClose(
|
|
23
|
-
connection.onUnhandledNotification(
|
|
24
|
-
connection.onError(
|
|
21
|
+
connection.onClose(e => console.log(e));
|
|
22
|
+
connection.onUnhandledNotification(e => console.log(e));
|
|
23
|
+
connection.onError(e => console.log(e));
|
|
25
24
|
connection.onDispose(() => {
|
|
26
25
|
childProcess.kill();
|
|
27
26
|
});
|
|
@@ -221,18 +220,20 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
221
220
|
};
|
|
222
221
|
}
|
|
223
222
|
exports.startLanguageServer = startLanguageServer;
|
|
224
|
-
function* printSnapshots(sourceFile
|
|
225
|
-
if (sourceFile.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
function* printSnapshots(sourceFile) {
|
|
224
|
+
if (sourceFile.generated) {
|
|
225
|
+
let lastId = 0;
|
|
226
|
+
for (const file of (0, language_core_1.forEachEmbeddedCode)(sourceFile.generated.code)) {
|
|
227
|
+
const id = lastId++;
|
|
228
|
+
yield `#${id}`;
|
|
229
|
+
for (const line of printSnapshot(sourceFile, file)) {
|
|
229
230
|
yield ' ' + line;
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
235
|
exports.printSnapshots = printSnapshots;
|
|
235
|
-
function* printSnapshot(sourceFile, file
|
|
236
|
+
function* printSnapshot(sourceFile, file) {
|
|
236
237
|
const sourceCode = sourceFile.snapshot.getText(0, sourceFile.snapshot.getLength());
|
|
237
238
|
const sourceFileDocument = vscode_languageserver_textdocument_1.TextDocument.create('', '', 0, sourceCode);
|
|
238
239
|
const virtualCode = file.snapshot.getText(0, file.snapshot.getLength());
|
|
@@ -269,7 +270,6 @@ function* printSnapshot(sourceFile, file, root = process.cwd()) {
|
|
|
269
270
|
for (const log of logs.reverse()) {
|
|
270
271
|
const sourcePosition = sourceFileDocument.positionAt(log.sourceOffset);
|
|
271
272
|
const spanText = log.length === 0 ? '^' : '~'.repeat(log.length);
|
|
272
|
-
const sourceFilePath = path.relative(root, log.mapping.source ?? sourceFile.fileName);
|
|
273
273
|
const prefix = ' '.repeat(lineHead.length);
|
|
274
274
|
const sourceLineEnd = sourceFileDocument.offsetAt({ line: sourcePosition.line + 1, character: 0 }) - 1;
|
|
275
275
|
const sourceLine = sourceFileDocument.getText().substring(sourceFileDocument.offsetAt({ line: sourcePosition.line, character: 0 }), sourceLineEnd + 1);
|
|
@@ -285,7 +285,7 @@ function* printSnapshot(sourceFile, file, root = process.cwd()) {
|
|
|
285
285
|
' '.repeat(log.lineOffset),
|
|
286
286
|
sourceLineHead,
|
|
287
287
|
'(exact match)',
|
|
288
|
-
`(${
|
|
288
|
+
`(${log.mapping.source
|
|
289
289
|
+ ':' + (sourcePosition.line + 1)
|
|
290
290
|
+ ':' + (sourcePosition.character + 1)})`,
|
|
291
291
|
].join(' ');
|
|
@@ -296,7 +296,7 @@ function* printSnapshot(sourceFile, file, root = process.cwd()) {
|
|
|
296
296
|
' '.repeat(log.lineOffset),
|
|
297
297
|
sourceLineHead,
|
|
298
298
|
normalizeLogText(sourceLine),
|
|
299
|
-
`(${
|
|
299
|
+
`(${log.mapping.source
|
|
300
300
|
+ ':' + (sourcePosition.line + 1)
|
|
301
301
|
+ ':' + (sourcePosition.character + 1)})`,
|
|
302
302
|
].join(' ');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/test-utils",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
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.0.0-alpha.
|
|
19
|
-
"@volar/language-server": "2.0.0-alpha.
|
|
18
|
+
"@volar/language-core": "2.0.0-alpha.14",
|
|
19
|
+
"@volar/language-server": "2.0.0-alpha.14",
|
|
20
20
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
21
21
|
"vscode-uri": "^3.0.8"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "83eb6a4a4475a3680f14fb3808e48ec4dbe62cc1"
|
|
24
24
|
}
|