@volar/language-service 2.3.0-alpha.4 → 2.3.0-alpha.6
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/lib/documents.d.ts +2 -2
- package/lib/features/provideDiagnostics.js +1 -1
- package/lib/features/provideDocumentFormattingEdits.js +3 -12
- package/lib/features/provideDocumentSemanticTokens.js +5 -2
- package/lib/features/provideDocumentSymbols.js +1 -1
- package/lib/languageService.js +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/featureWorkers.d.ts +2 -2
- package/lib/utils/featureWorkers.js +1 -1
- package/package.json +3 -3
package/lib/documents.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export declare class SourceMapWithDocuments {
|
|
|
5
5
|
sourceDocument: TextDocument;
|
|
6
6
|
embeddedDocument: TextDocument;
|
|
7
7
|
map: SourceMap<CodeInformation>;
|
|
8
|
-
virtuaoCode?: VirtualCode | undefined;
|
|
9
|
-
constructor(sourceDocument: TextDocument, embeddedDocument: TextDocument, map: SourceMap<CodeInformation>, virtuaoCode?: VirtualCode | undefined);
|
|
8
|
+
virtuaoCode?: VirtualCode<unknown> | undefined;
|
|
9
|
+
constructor(sourceDocument: TextDocument, embeddedDocument: TextDocument, map: SourceMap<CodeInformation>, virtuaoCode?: VirtualCode<unknown> | undefined);
|
|
10
10
|
getSourceRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
|
|
11
11
|
getGeneratedRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
|
|
12
12
|
getSourceRanges(range: vscode.Range, filter?: (data: CodeInformation) => boolean): Generator<vscode.Range, void, unknown>;
|
|
@@ -137,7 +137,7 @@ function register(context) {
|
|
|
137
137
|
errorsUpdated = false;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
function collectErrors() {
|
|
141
141
|
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
142
142
|
}
|
|
143
143
|
async function worker(api, cacheMap, cache) {
|
|
@@ -8,7 +8,6 @@ const documents_1 = require("../documents");
|
|
|
8
8
|
const cancellation_1 = require("../utils/cancellation");
|
|
9
9
|
const common_1 = require("../utils/common");
|
|
10
10
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
11
|
-
const uriMap_1 = require("../utils/uriMap");
|
|
12
11
|
function register(context) {
|
|
13
12
|
let fakeVersion = 0;
|
|
14
13
|
return async (uri, options, range, onTypeParams, token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -179,17 +178,9 @@ function register(context) {
|
|
|
179
178
|
}
|
|
180
179
|
};
|
|
181
180
|
function createDocMap(virtualCode, documentUri, sourceLanguageId, _sourceSnapshot) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return [documentUri, _sourceSnapshot];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
if (mapOfMap.has(documentUri) && mapOfMap.get(documentUri)[0] === _sourceSnapshot) {
|
|
189
|
-
const map = mapOfMap.get(documentUri);
|
|
190
|
-
const version = fakeVersion++;
|
|
191
|
-
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1], virtualCode);
|
|
192
|
-
}
|
|
181
|
+
const map = new language_core_1.SourceMap(virtualCode.mappings);
|
|
182
|
+
const version = fakeVersion++;
|
|
183
|
+
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map, virtualCode);
|
|
193
184
|
}
|
|
194
185
|
}
|
|
195
186
|
exports.register = register;
|
|
@@ -7,7 +7,8 @@ const cancellation_1 = require("../utils/cancellation");
|
|
|
7
7
|
const common_1 = require("../utils/common");
|
|
8
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
9
|
function register(context) {
|
|
10
|
-
return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress
|
|
10
|
+
return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress // TODO
|
|
11
|
+
) => {
|
|
11
12
|
const sourceScript = context.language.scripts.get(uri);
|
|
12
13
|
if (!sourceScript) {
|
|
13
14
|
return;
|
|
@@ -47,7 +48,9 @@ function register(context) {
|
|
|
47
48
|
}
|
|
48
49
|
})
|
|
49
50
|
.filter(common_1.notEmpty);
|
|
50
|
-
}, tokens => tokens.flat()
|
|
51
|
+
}, tokens => tokens.flat()
|
|
52
|
+
// tokens => reportProgress?.(buildTokens(tokens)), // TODO: this has no effect with LSP
|
|
53
|
+
);
|
|
51
54
|
if (tokens) {
|
|
52
55
|
return buildTokens(tokens);
|
|
53
56
|
}
|
|
@@ -8,7 +8,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
8
8
|
const transform_1 = require("../utils/transform");
|
|
9
9
|
function register(context) {
|
|
10
10
|
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)),
|
|
11
|
+
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), (plugin, document) => {
|
|
12
12
|
if (token.isCancellationRequested) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
package/lib/languageService.js
CHANGED
|
@@ -60,7 +60,7 @@ function createLanguageService(language, plugins, env) {
|
|
|
60
60
|
return map.get(uri);
|
|
61
61
|
},
|
|
62
62
|
*getMaps(virtualCode) {
|
|
63
|
-
for (const [uri,
|
|
63
|
+
for (const [uri, snapshot, map] of context.language.maps.forEach(virtualCode)) {
|
|
64
64
|
if (!map2DocMap.has(map)) {
|
|
65
65
|
const embeddedUri = context.encodeEmbeddedDocumentUri(uri, virtualCode.id);
|
|
66
66
|
map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(uri, context.language.scripts.get(uri).languageId, snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
|
package/lib/types.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ export interface LanguageServiceContext {
|
|
|
49
49
|
};
|
|
50
50
|
documents: {
|
|
51
51
|
get(uri: URI, languageId: string, snapshot: ts.IScriptSnapshot): TextDocument;
|
|
52
|
-
getMaps(virtualCode: VirtualCode): Generator<SourceMapWithDocuments>;
|
|
53
|
-
getLinkedCodeMap(virtualCode: VirtualCode
|
|
52
|
+
getMaps(virtualCode: VirtualCode<URI>): Generator<SourceMapWithDocuments>;
|
|
53
|
+
getLinkedCodeMap(virtualCode: VirtualCode<URI>, documentUri: URI): LinkedCodeMapWithDocument | undefined;
|
|
54
54
|
};
|
|
55
55
|
plugins: [LanguageServicePlugin, LanguageServicePluginInstance][];
|
|
56
56
|
disabledEmbeddedDocumentUris: UriMap<boolean>;
|
package/lib/utils/dedupe.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function createLocationSet(): {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function withCodeAction<T extends vscode.CodeAction>(items: T[]): T[];
|
|
7
7
|
export declare function withTextEdits<T extends vscode.TextEdit>(items: T[]): T[];
|
|
8
|
-
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.
|
|
8
|
+
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.CreateFile | vscode.TextDocumentEdit | vscode.RenameFile | vscode.DeleteFile)[];
|
|
9
9
|
export declare function withDiagnostics<T extends vscode.Diagnostic>(items: T[]): T[];
|
|
10
10
|
export declare function withLocations<T extends vscode.Location>(items: T[]): T[];
|
|
11
11
|
export declare function withLocationLinks<T extends vscode.LocationLink>(items: T[]): T[];
|
|
@@ -6,5 +6,5 @@ import type { LanguageServicePlugin, LanguageServicePluginInstance, LanguageServ
|
|
|
6
6
|
export declare function documentFeatureWorker<T>(context: LanguageServiceContext, uri: URI, valid: (map: SourceMapWithDocuments) => boolean, worker: (plugin: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
|
|
7
7
|
export declare function languageFeatureWorker<T, K>(context: LanguageServiceContext, uri: URI, getRealDocParams: () => K, eachVirtualDocParams: (map: SourceMapWithDocuments) => Generator<K>, worker: (plugin: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument, params: K, map?: SourceMapWithDocuments) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
|
|
8
8
|
export declare function safeCall<T>(cb: () => Thenable<T> | T, errorMsg?: string): Promise<T | undefined>;
|
|
9
|
-
export declare function forEachEmbeddedDocument(context: LanguageServiceContext, sourceScriptId: URI, current: VirtualCode): Generator<SourceMapWithDocuments>;
|
|
10
|
-
export declare function getEmbeddedFilesByLevel(context: LanguageServiceContext, sourceFileUri: URI, rootFile: VirtualCode, level: number): VirtualCode[];
|
|
9
|
+
export declare function forEachEmbeddedDocument(context: LanguageServiceContext, sourceScriptId: URI, current: VirtualCode<URI>): Generator<SourceMapWithDocuments>;
|
|
10
|
+
export declare function getEmbeddedFilesByLevel(context: LanguageServiceContext, sourceFileUri: URI, rootFile: VirtualCode, level: number): VirtualCode<unknown>[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEmbeddedFilesByLevel = exports.forEachEmbeddedDocument = exports.safeCall = exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
|
|
4
|
-
|
|
4
|
+
function documentFeatureWorker(context, uri, valid, worker, transformResult, combineResult) {
|
|
5
5
|
return languageFeatureWorker(context, uri, () => void 0, function* (map) {
|
|
6
6
|
if (valid(map)) {
|
|
7
7
|
yield;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/language-service"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.3.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.3.0-alpha.6",
|
|
16
16
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
17
17
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
18
18
|
"vscode-uri": "^3.0.8"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "f3103e86be8d80cb36f66be4c054ef9a255c29b1"
|
|
21
21
|
}
|