@volar/test-utils 2.0.4 → 2.1.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 +3 -1
- package/index.js +19 -3
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ 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, initializationOptions: _.
|
|
9
|
+
initialize<T = _.InitializationOptions & Record<string, unknown>>(rootUri: string, initializationOptions: T, capabilities?: _.ClientCapabilities, locale?: string): Promise<_.InitializeResult<any>>;
|
|
10
|
+
shutdown(): Promise<void>;
|
|
10
11
|
openTextDocument(fileName: string, languageId: string): Promise<TextDocument>;
|
|
11
12
|
openUntitledDocument(content: string, languageId: string): Promise<TextDocument>;
|
|
12
13
|
openInMemoryDocument(uri: string, languageId: string, content: string): Promise<TextDocument>;
|
|
@@ -16,6 +17,7 @@ export declare function startLanguageServer(serverModule: string, cwd?: string |
|
|
|
16
17
|
sendDocumentDiagnosticRequest(uri: string): Promise<_.DocumentDiagnosticReport>;
|
|
17
18
|
sendHoverRequest(uri: string, position: _.Position): Promise<_.Hover | null>;
|
|
18
19
|
sendDocumentFormattingRequest(uri: string, options: _.FormattingOptions): Promise<_.TextEdit[] | null>;
|
|
20
|
+
sendDocumentRangeFormattingRequestRequest(uri: string, range: _.Range, options: _.FormattingOptions): Promise<_.TextEdit[] | null>;
|
|
19
21
|
sendRenameRequest(uri: string, position: _.Position, newName: string): Promise<_.WorkspaceEdit | null>;
|
|
20
22
|
sendPrepareRenameRequest(uri: string, position: _.Position): Promise<_.PrepareRenameResult | null>;
|
|
21
23
|
sendFoldingRangesRequest(uri: string): Promise<_.FoldingRange[] | null>;
|
package/index.js
CHANGED
|
@@ -27,16 +27,21 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
27
27
|
return {
|
|
28
28
|
process: childProcess,
|
|
29
29
|
connection,
|
|
30
|
-
async initialize(rootUri, initializationOptions) {
|
|
30
|
+
async initialize(rootUri, initializationOptions, capabilities = {}, locale) {
|
|
31
31
|
const result = await connection.sendRequest(_.InitializeRequest.type, {
|
|
32
32
|
processId: childProcess.pid ?? null,
|
|
33
33
|
rootUri,
|
|
34
|
-
capabilities: {},
|
|
35
34
|
initializationOptions,
|
|
35
|
+
capabilities,
|
|
36
|
+
locale,
|
|
36
37
|
});
|
|
37
38
|
await connection.sendNotification(_.InitializedNotification.type, {});
|
|
38
39
|
return result;
|
|
39
40
|
},
|
|
41
|
+
async shutdown() {
|
|
42
|
+
await connection.sendRequest(_.ShutdownRequest.type);
|
|
43
|
+
openedDocuments.clear();
|
|
44
|
+
},
|
|
40
45
|
async openTextDocument(fileName, languageId) {
|
|
41
46
|
const uri = vscode_uri_1.URI.file(fileName).toString();
|
|
42
47
|
if (!openedDocuments.has(uri)) {
|
|
@@ -68,7 +73,11 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
68
73
|
return document;
|
|
69
74
|
},
|
|
70
75
|
async openInMemoryDocument(uri, languageId, content) {
|
|
71
|
-
const
|
|
76
|
+
const oldDocument = openedDocuments.get(uri);
|
|
77
|
+
if (oldDocument) {
|
|
78
|
+
await this.closeTextDocument(uri);
|
|
79
|
+
}
|
|
80
|
+
const document = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, (oldDocument?.version ?? 0) + 1, content);
|
|
72
81
|
openedDocuments.set(uri, document);
|
|
73
82
|
await connection.sendNotification(_.DidOpenTextDocumentNotification.type, {
|
|
74
83
|
textDocument: {
|
|
@@ -116,6 +125,13 @@ function startLanguageServer(serverModule, cwd) {
|
|
|
116
125
|
options,
|
|
117
126
|
});
|
|
118
127
|
},
|
|
128
|
+
sendDocumentRangeFormattingRequestRequest(uri, range, options) {
|
|
129
|
+
return connection.sendRequest(_.DocumentRangeFormattingRequest.type, {
|
|
130
|
+
textDocument: { uri },
|
|
131
|
+
range,
|
|
132
|
+
options,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
119
135
|
sendRenameRequest(uri, position, newName) {
|
|
120
136
|
return connection.sendRequest(_.RenameRequest.type, {
|
|
121
137
|
textDocument: { uri },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/test-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.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.
|
|
19
|
-
"@volar/language-server": "2.
|
|
18
|
+
"@volar/language-core": "2.1.1",
|
|
19
|
+
"@volar/language-server": "2.1.1",
|
|
20
20
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
21
21
|
"vscode-uri": "^3.0.8"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "e56916097fe7be2920aab6592a564a8e2ceafd14"
|
|
24
24
|
}
|