@volar/language-service 2.4.22 → 2.4.24
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 -1
- package/index.js +1 -1
- package/lib/features/provideAutoInsertSnippet.d.ts +1 -1
- package/lib/features/provideCodeActions.d.ts +1 -1
- package/lib/features/provideCodeLenses.d.ts +1 -1
- package/lib/features/provideColorPresentations.d.ts +1 -1
- package/lib/features/provideCompletionItems.js +7 -3
- package/lib/features/provideDefinition.js +8 -3
- package/lib/features/provideDiagnostics.d.ts +1 -1
- package/lib/features/provideDiagnostics.js +3 -1
- package/lib/features/provideDocumentColors.d.ts +1 -1
- package/lib/features/provideDocumentDropEdits.d.ts +1 -1
- package/lib/features/provideDocumentFormattingEdits.js +8 -3
- package/lib/features/provideDocumentHighlights.js +4 -1
- package/lib/features/provideDocumentLinks.d.ts +1 -1
- package/lib/features/provideDocumentSemanticTokens.d.ts +1 -1
- package/lib/features/provideDocumentSemanticTokens.js +9 -5
- package/lib/features/provideDocumentSymbols.d.ts +1 -1
- package/lib/features/provideFileRenameEdits.d.ts +1 -1
- package/lib/features/provideFoldingRanges.d.ts +1 -1
- package/lib/features/provideHover.d.ts +1 -1
- package/lib/features/provideHover.js +2 -1
- package/lib/features/provideInlayHints.d.ts +2 -2
- package/lib/features/provideInlayHints.js +1 -1
- package/lib/features/provideInlineValue.d.ts +1 -1
- package/lib/features/provideLinkedEditingRanges.d.ts +1 -1
- package/lib/features/provideMoniker.d.ts +1 -1
- package/lib/features/provideReferences.js +4 -1
- package/lib/features/provideRenameEdits.js +4 -2
- package/lib/features/provideRenameRange.d.ts +1 -1
- package/lib/features/provideSelectionRanges.d.ts +1 -1
- package/lib/features/provideSelectionRanges.js +2 -1
- package/lib/features/provideSignatureHelp.d.ts +1 -1
- package/lib/features/provideWorkspaceDiagnostics.js +2 -2
- package/lib/features/resolveCodeLens.js +2 -1
- package/lib/features/resolveCompletionItem.js +0 -4
- package/lib/languageService.d.ts +2 -2
- package/lib/languageService.js +3 -2
- package/lib/types.d.ts +2 -2
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/dedupe.js +1 -1
- package/lib/utils/transform.js +23 -19
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@volar/language-core';
|
|
2
|
-
export * from './lib/languageService';
|
|
3
2
|
export { mergeWorkspaceEdits } from './lib/features/provideRenameEdits';
|
|
3
|
+
export * from './lib/languageService';
|
|
4
4
|
export * from './lib/types';
|
|
5
5
|
export * from './lib/utils/transform';
|
|
6
6
|
export * from './lib/utils/uriMap';
|
package/index.js
CHANGED
|
@@ -16,9 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.mergeWorkspaceEdits = void 0;
|
|
18
18
|
__exportStar(require("@volar/language-core"), exports);
|
|
19
|
-
__exportStar(require("./lib/languageService"), exports);
|
|
20
19
|
var provideRenameEdits_1 = require("./lib/features/provideRenameEdits");
|
|
21
20
|
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return provideRenameEdits_1.mergeWorkspaceEdits; } });
|
|
21
|
+
__exportStar(require("./lib/languageService"), exports);
|
|
22
22
|
__exportStar(require("./lib/types"), exports);
|
|
23
23
|
__exportStar(require("./lib/utils/transform"), exports);
|
|
24
24
|
__exportStar(require("./lib/utils/uriMap"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, selection: vscode.Position, change: {
|
|
5
5
|
rangeOffset: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
@@ -8,7 +8,9 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
8
8
|
const transform_1 = require("../utils/transform");
|
|
9
9
|
function register(context) {
|
|
10
10
|
let lastResult;
|
|
11
|
-
return async (uri, position, completionContext = {
|
|
11
|
+
return async (uri, position, completionContext = {
|
|
12
|
+
triggerKind: 1,
|
|
13
|
+
}, token = cancellation_1.NoneCancellationToken) => {
|
|
12
14
|
let langaugeIdAndSnapshot;
|
|
13
15
|
let sourceScript;
|
|
14
16
|
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
@@ -123,10 +125,12 @@ function register(context) {
|
|
|
123
125
|
if (plugin[1].isAdditionalCompletion && !isFirstMapping) {
|
|
124
126
|
continue;
|
|
125
127
|
}
|
|
126
|
-
if (completionContext?.triggerCharacter
|
|
128
|
+
if (completionContext?.triggerCharacter
|
|
129
|
+
&& !plugin[0].capabilities.completionProvider?.triggerCharacters?.includes(completionContext.triggerCharacter)) {
|
|
127
130
|
continue;
|
|
128
131
|
}
|
|
129
|
-
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional)
|
|
132
|
+
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional)
|
|
133
|
+
|| plugin[1].isAdditionalCompletion;
|
|
130
134
|
if (mainCompletionUri && (!isAdditional || mainCompletionUri !== document.uri)) {
|
|
131
135
|
continue;
|
|
132
136
|
}
|
|
@@ -27,7 +27,10 @@ function register(context, apiName, isValidPosition) {
|
|
|
27
27
|
const definitions = await api?.(document, position, token) ?? [];
|
|
28
28
|
for (const definition of definitions) {
|
|
29
29
|
let foundMirrorPosition = false;
|
|
30
|
-
recursiveChecker.add({
|
|
30
|
+
recursiveChecker.add({
|
|
31
|
+
uri: definition.targetUri,
|
|
32
|
+
range: { start: definition.targetRange.start, end: definition.targetRange.start },
|
|
33
|
+
});
|
|
31
34
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(definition.targetUri));
|
|
32
35
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
33
36
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
@@ -115,8 +118,10 @@ function toSourcePositionPreferSurroundedPosition(docs, mappedRange, position) {
|
|
|
115
118
|
if (!result) {
|
|
116
119
|
result = range;
|
|
117
120
|
}
|
|
118
|
-
if ((range.start.line < position.line
|
|
119
|
-
|
|
121
|
+
if ((range.start.line < position.line
|
|
122
|
+
|| (range.start.line === position.line && range.start.character <= position.character))
|
|
123
|
+
&& (range.end.line > position.line
|
|
124
|
+
|| (range.end.line === position.line && range.end.character >= position.character))) {
|
|
120
125
|
return range;
|
|
121
126
|
}
|
|
122
127
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
|
-
import { DocumentsAndMap } from '../utils/featureWorkers';
|
|
4
|
+
import { type DocumentsAndMap } from '../utils/featureWorkers';
|
|
5
5
|
export interface ServiceDiagnosticData {
|
|
6
6
|
uri: string;
|
|
7
7
|
version: number;
|
|
@@ -205,7 +205,9 @@ function updatePosition(position, change, isEnd) {
|
|
|
205
205
|
position.character = change.newEnd.character + position.character - change.range.end.character;
|
|
206
206
|
}
|
|
207
207
|
else {
|
|
208
|
-
if (isEnd
|
|
208
|
+
if (isEnd
|
|
209
|
+
? change.range.end.character < position.character
|
|
210
|
+
: change.range.end.character <= position.character) {
|
|
209
211
|
position.character += characterDiff;
|
|
210
212
|
}
|
|
211
213
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { DataTransferItem, LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, dataTransfer: Map<string, DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("../types").DocumentDropEdit | undefined>;
|
|
@@ -20,7 +20,8 @@ function register(context) {
|
|
|
20
20
|
};
|
|
21
21
|
if (!sourceScript.generated) {
|
|
22
22
|
return onTypeParams
|
|
23
|
-
? (await tryFormat(document, document, sourceScript, undefined, 0, onTypeParams.position, onTypeParams.ch))
|
|
23
|
+
? (await tryFormat(document, document, sourceScript, undefined, 0, onTypeParams.position, onTypeParams.ch))
|
|
24
|
+
?.edits
|
|
24
25
|
: (await tryFormat(document, document, sourceScript, undefined, 0, range, undefined))?.edits;
|
|
25
26
|
}
|
|
26
27
|
const embeddedRanges = new Map(); // TODO: Formatting of upper-level virtual code may cause offset of lower-level selection range
|
|
@@ -35,7 +36,9 @@ function register(context) {
|
|
|
35
36
|
embeddedRange.start = 0;
|
|
36
37
|
}
|
|
37
38
|
const lastMapping = map.mappings[map.mappings.length - 1];
|
|
38
|
-
if (embeddedRange.end
|
|
39
|
+
if (embeddedRange.end
|
|
40
|
+
=== lastMapping.generatedOffsets[lastMapping.generatedOffsets.length - 1]
|
|
41
|
+
+ (lastMapping.generatedLengths ?? lastMapping.lengths)[lastMapping.lengths.length - 1]) {
|
|
39
42
|
embeddedRange.end = code.snapshot.getLength();
|
|
40
43
|
}
|
|
41
44
|
embeddedRanges.set(code.id, embeddedRange);
|
|
@@ -151,7 +154,9 @@ function register(context) {
|
|
|
151
154
|
if (context.disabledServicePlugins.has(plugin[1])) {
|
|
152
155
|
continue;
|
|
153
156
|
}
|
|
154
|
-
codeOptions =
|
|
157
|
+
codeOptions =
|
|
158
|
+
await plugin[1].resolveEmbeddedCodeFormattingOptions?.(sourceScript, virtualCode, codeOptions, token)
|
|
159
|
+
?? codeOptions;
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
for (const plugin of context.plugins) {
|
|
@@ -27,7 +27,10 @@ function register(context) {
|
|
|
27
27
|
const references = await plugin[1].provideDocumentHighlights(document, position, token) ?? [];
|
|
28
28
|
for (const reference of references) {
|
|
29
29
|
let foundMirrorPosition = false;
|
|
30
|
-
recursiveChecker.add({
|
|
30
|
+
recursiveChecker.add({
|
|
31
|
+
uri: document.uri,
|
|
32
|
+
range: { start: reference.range.start, end: reference.range.start },
|
|
33
|
+
});
|
|
31
34
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
|
32
35
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
33
36
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, _reportProgress?: (tokens: vscode.SemanticTokens) => void, // TODO
|
|
5
5
|
token?: vscode.CancellationToken) => Promise<vscode.SemanticTokens | undefined>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
|
|
6
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
|
+
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
|
|
8
8
|
function register(context) {
|
|
9
9
|
return async (uri, range, legend, _reportProgress, // TODO
|
|
10
10
|
token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -43,13 +43,17 @@ function register(context) {
|
|
|
43
43
|
end: { line: _token[0], character: _token[1] + _token[2] },
|
|
44
44
|
}, language_core_1.isSemanticTokensEnabled);
|
|
45
45
|
if (range) {
|
|
46
|
-
return [
|
|
46
|
+
return [
|
|
47
|
+
range.start.line,
|
|
48
|
+
range.start.character,
|
|
49
|
+
range.end.character - range.start.character,
|
|
50
|
+
_token[3],
|
|
51
|
+
_token[4],
|
|
52
|
+
];
|
|
47
53
|
}
|
|
48
54
|
})
|
|
49
55
|
.filter(token => !!token);
|
|
50
|
-
}, tokens => tokens.flat()
|
|
51
|
-
// tokens => reportProgress?.(buildTokens(tokens)), // TODO: this has no effect with LSP
|
|
52
|
-
);
|
|
56
|
+
}, tokens => tokens.flat());
|
|
53
57
|
if (tokens) {
|
|
54
58
|
return buildTokens(tokens);
|
|
55
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { URI } from 'vscode-uri';
|
|
1
|
+
import { type URI } from 'vscode-uri';
|
|
2
2
|
import type { LanguageServiceContext } from '../types';
|
|
3
3
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (oldUri: URI, newUri: URI, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { URI } from 'vscode-uri';
|
|
1
|
+
import { type URI } from 'vscode-uri';
|
|
2
2
|
import type { LanguageServiceContext } from '../types';
|
|
3
3
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: _.CancellationToken) => Promise<_.FoldingRange[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
@@ -25,7 +25,8 @@ function register(context) {
|
|
|
25
25
|
kind: 'markdown',
|
|
26
26
|
value: hovers.map(getHoverTexts).flat().join('\n\n---\n\n'),
|
|
27
27
|
},
|
|
28
|
-
range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range
|
|
28
|
+
range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range
|
|
29
|
+
?? hovers[0].range,
|
|
29
30
|
}));
|
|
30
31
|
const markups = provideDiagnostics_1.errorMarkups.get(uri);
|
|
31
32
|
if (markups) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface InlayHintData {
|
|
5
5
|
uri: string;
|
|
6
6
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
7
7
|
pluginIndex: number;
|
|
8
8
|
}
|
|
9
|
-
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined
|
|
9
|
+
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined> | undefined;
|
|
@@ -6,7 +6,7 @@ const cancellation_1 = require("../utils/cancellation");
|
|
|
6
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
7
|
const transform_1 = require("../utils/transform");
|
|
8
8
|
function register(context) {
|
|
9
|
-
return
|
|
9
|
+
return (uri, range, token = cancellation_1.NoneCancellationToken) => {
|
|
10
10
|
const sourceScript = context.language.scripts.get(uri);
|
|
11
11
|
if (!sourceScript) {
|
|
12
12
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, ivContext: vscode.InlineValueContext, token?: vscode.CancellationToken) => Promise<vscode.InlineValue[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Moniker[] | undefined>;
|
|
@@ -27,7 +27,10 @@ function register(context) {
|
|
|
27
27
|
const references = await plugin[1].provideReferences(document, position, referenceContext, token) ?? [];
|
|
28
28
|
for (const reference of references) {
|
|
29
29
|
let foundMirrorPosition = false;
|
|
30
|
-
recursiveChecker.add({
|
|
30
|
+
recursiveChecker.add({
|
|
31
|
+
uri: reference.uri,
|
|
32
|
+
range: { start: reference.range.start, end: reference.range.start },
|
|
33
|
+
});
|
|
31
34
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
|
|
32
35
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
33
36
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
@@ -21,7 +21,6 @@ function register(context) {
|
|
|
21
21
|
newName: (0, language_core_1.resolveRenameNewName)(newName, _data),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
;
|
|
25
24
|
}, async (plugin, document, params) => {
|
|
26
25
|
if (token.isCancellationRequested) {
|
|
27
26
|
return;
|
|
@@ -50,7 +49,10 @@ function register(context) {
|
|
|
50
49
|
const textEdits = workspaceEdit.changes[editUri];
|
|
51
50
|
for (const textEdit of textEdits) {
|
|
52
51
|
let foundMirrorPosition = false;
|
|
53
|
-
recursiveChecker.add({
|
|
52
|
+
recursiveChecker.add({
|
|
53
|
+
uri: editUri,
|
|
54
|
+
range: { start: textEdit.range.start, end: textEdit.range.start },
|
|
55
|
+
});
|
|
54
56
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(editUri));
|
|
55
57
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
56
58
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
|
|
5
5
|
range: vscode.Range;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
|
@@ -53,7 +53,8 @@ function register(context) {
|
|
|
53
53
|
for (let j = 1; j < pluginResults.length; j++) {
|
|
54
54
|
let top = pluginResults[j - 1];
|
|
55
55
|
const parent = pluginResults[j];
|
|
56
|
-
while (top.parent && (0, common_1.isInsideRange)(parent.range, top.parent.range)
|
|
56
|
+
while (top.parent && (0, common_1.isInsideRange)(parent.range, top.parent.range)
|
|
57
|
+
&& !(0, common_1.isEqualRange)(parent.range, top.parent.range)) {
|
|
57
58
|
top = top.parent;
|
|
58
59
|
}
|
|
59
60
|
if (top) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
2
|
+
import { type URI } from 'vscode-uri';
|
|
3
3
|
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
@@ -44,7 +44,7 @@ function register(context) {
|
|
|
44
44
|
...item,
|
|
45
45
|
items: item.items
|
|
46
46
|
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, docs))
|
|
47
|
-
.filter(error => !!error)
|
|
47
|
+
.filter(error => !!error),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -56,7 +56,7 @@ function register(context) {
|
|
|
56
56
|
...item,
|
|
57
57
|
items: item.items
|
|
58
58
|
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, undefined))
|
|
59
|
-
.filter(error => !!error)
|
|
59
|
+
.filter(error => !!error),
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -19,7 +19,8 @@ function register(context) {
|
|
|
19
19
|
// item.range already transformed in codeLens request
|
|
20
20
|
}
|
|
21
21
|
else if (data?.kind === 'references') {
|
|
22
|
-
const references = await findReferences(vscode_uri_1.URI.parse(data.sourceFileUri), item.range.start, { includeDeclaration: false }, token)
|
|
22
|
+
const references = await findReferences(vscode_uri_1.URI.parse(data.sourceFileUri), item.range.start, { includeDeclaration: false }, token)
|
|
23
|
+
?? [];
|
|
23
24
|
item.command = context.commands.showReferences.create(data.sourceFileUri, item.range.start, references);
|
|
24
25
|
}
|
|
25
26
|
delete item.data;
|
|
@@ -33,10 +33,6 @@ function register(context) {
|
|
|
33
33
|
item = await plugin[1].resolveCompletionItem(item, token);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
// TODO: monkey fix import ts file icon
|
|
37
|
-
if (item.detail !== item.detail + '.ts') {
|
|
38
|
-
item.detail = item.detail;
|
|
39
|
-
}
|
|
40
36
|
delete item.data;
|
|
41
37
|
return item;
|
|
42
38
|
};
|
package/lib/languageService.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export declare function createLanguageService(language: Language<URI>, plugins:
|
|
|
64
64
|
text: string;
|
|
65
65
|
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
|
66
66
|
getDocumentDropEdits: (uri: URI, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
|
|
67
|
-
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined
|
|
67
|
+
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined> | undefined;
|
|
68
68
|
getMoniker: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Moniker[] | undefined>;
|
|
69
69
|
getInlineValue: (uri: URI, range: vscode.Range, ivContext: vscode.InlineValueContext, token?: vscode.CancellationToken) => Promise<vscode.InlineValue[] | undefined>;
|
|
70
70
|
resolveCodeAction: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
@@ -139,7 +139,7 @@ declare function createLanguageServiceBase(plugins: LanguageServicePlugin[], con
|
|
|
139
139
|
text: string;
|
|
140
140
|
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
|
141
141
|
getDocumentDropEdits: (uri: URI, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
|
|
142
|
-
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined
|
|
142
|
+
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined> | undefined;
|
|
143
143
|
getMoniker: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Moniker[] | undefined>;
|
|
144
144
|
getInlineValue: (uri: URI, range: vscode.Range, ivContext: vscode.InlineValueContext, token?: vscode.CancellationToken) => Promise<vscode.InlineValue[] | undefined>;
|
|
145
145
|
resolveCodeAction: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
package/lib/languageService.js
CHANGED
|
@@ -27,9 +27,9 @@ const fileRename = require("./features/provideFileRenameEdits");
|
|
|
27
27
|
const foldingRanges = require("./features/provideFoldingRanges");
|
|
28
28
|
const hover = require("./features/provideHover");
|
|
29
29
|
const inlayHints = require("./features/provideInlayHints");
|
|
30
|
-
const moniker = require("./features/provideMoniker");
|
|
31
30
|
const inlineValue = require("./features/provideInlineValue");
|
|
32
31
|
const linkedEditing = require("./features/provideLinkedEditingRanges");
|
|
32
|
+
const moniker = require("./features/provideMoniker");
|
|
33
33
|
const references = require("./features/provideReferences");
|
|
34
34
|
const rename = require("./features/provideRenameEdits");
|
|
35
35
|
const renamePrepare = require("./features/provideRenameRange");
|
|
@@ -164,7 +164,8 @@ function encodeEmbeddedDocumentUri(documentUri, embeddedContentId) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
function createLanguageServiceBase(plugins, context) {
|
|
167
|
-
const tokenModifiers = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenModifiers ?? [])
|
|
167
|
+
const tokenModifiers = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenModifiers ?? [])
|
|
168
|
+
.flat();
|
|
168
169
|
const tokenTypes = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenTypes ?? []).flat();
|
|
169
170
|
return {
|
|
170
171
|
semanticTokenLegend: {
|
package/lib/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Language, SourceScript, VirtualCode } from '@volar/language-core';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
2
3
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
4
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
import type * as ts from 'typescript';
|
|
5
|
-
import type { LanguageService } from './languageService';
|
|
6
5
|
import type { URI } from 'vscode-uri';
|
|
6
|
+
import type { LanguageService } from './languageService';
|
|
7
7
|
import type { UriMap } from './utils/uriMap';
|
|
8
8
|
export type * from 'vscode-languageserver-protocol';
|
|
9
9
|
export interface LanguageServiceEnvironment {
|
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.TextDocumentEdit | vscode.CreateFile | 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[];
|
package/lib/utils/dedupe.js
CHANGED
package/lib/utils/transform.js
CHANGED
|
@@ -86,28 +86,31 @@ function transformCompletionItem(item, getOtherRange, document, context) {
|
|
|
86
86
|
textEdit: item.textEdit
|
|
87
87
|
? transformTextEdit(item.textEdit, getOtherRange, document)
|
|
88
88
|
: undefined,
|
|
89
|
-
documentation: item.documentation
|
|
90
|
-
typeof item.documentation === 'string'
|
|
91
|
-
item.documentation
|
|
92
|
-
|
|
89
|
+
documentation: item.documentation
|
|
90
|
+
? typeof item.documentation === 'string'
|
|
91
|
+
? transformMarkdown(item.documentation, context)
|
|
92
|
+
: item.documentation.kind === 'markdown'
|
|
93
|
+
? { kind: 'markdown', value: transformMarkdown(item.documentation.value, context) }
|
|
93
94
|
: item.documentation
|
|
94
|
-
: undefined
|
|
95
|
+
: undefined,
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
function transformCompletionList(completionList, getOtherRange, document, context) {
|
|
98
99
|
return {
|
|
99
100
|
isIncomplete: completionList.isIncomplete,
|
|
100
|
-
itemDefaults: completionList.itemDefaults
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
?
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
itemDefaults: completionList.itemDefaults
|
|
102
|
+
? {
|
|
103
|
+
...completionList.itemDefaults,
|
|
104
|
+
editRange: completionList.itemDefaults.editRange
|
|
105
|
+
? 'replace' in completionList.itemDefaults.editRange
|
|
106
|
+
? {
|
|
107
|
+
insert: getOtherRange(completionList.itemDefaults.editRange.insert),
|
|
108
|
+
replace: getOtherRange(completionList.itemDefaults.editRange.replace),
|
|
109
|
+
}
|
|
110
|
+
: getOtherRange(completionList.itemDefaults.editRange)
|
|
111
|
+
: undefined,
|
|
112
|
+
}
|
|
113
|
+
: undefined,
|
|
111
114
|
items: completionList.items.map(item => transformCompletionItem(item, getOtherRange, document, context)),
|
|
112
115
|
};
|
|
113
116
|
}
|
|
@@ -203,7 +206,6 @@ function transformTextEdit(textEdit, getOtherRange, document) {
|
|
|
203
206
|
range,
|
|
204
207
|
};
|
|
205
208
|
}
|
|
206
|
-
;
|
|
207
209
|
const cover = tryRecoverTextEdit(getOtherRange, textEdit.range, textEdit.newText, document);
|
|
208
210
|
if (cover) {
|
|
209
211
|
return {
|
|
@@ -224,7 +226,9 @@ function transformTextEdit(textEdit, getOtherRange, document) {
|
|
|
224
226
|
};
|
|
225
227
|
}
|
|
226
228
|
const recoverInsert = tryRecoverTextEdit(getOtherRange, textEdit.insert, textEdit.newText, document);
|
|
227
|
-
const recoverReplace = recoverInsert
|
|
229
|
+
const recoverReplace = recoverInsert
|
|
230
|
+
? tryRecoverTextEdit(getOtherRange, textEdit.replace, textEdit.newText, document)
|
|
231
|
+
: undefined;
|
|
228
232
|
if (recoverInsert && recoverReplace && recoverInsert.newText === recoverReplace.newText) {
|
|
229
233
|
return {
|
|
230
234
|
...textEdit,
|
|
@@ -407,7 +411,7 @@ function transformWorkspaceEdit(edit, context, mode, versions = {}) {
|
|
|
407
411
|
sourceEdit = {
|
|
408
412
|
kind: 'rename',
|
|
409
413
|
oldUri: sourceScript.id.toString(),
|
|
410
|
-
newUri: tsDocEdit.newUri /* TODO: remove .ts?
|
|
414
|
+
newUri: tsDocEdit.newUri, /* TODO: remove .ts? */
|
|
411
415
|
options: tsDocEdit.options,
|
|
412
416
|
annotationId: tsDocEdit.annotationId,
|
|
413
417
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.24",
|
|
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.4.
|
|
15
|
+
"@volar/language-core": "2.4.24",
|
|
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": "a5c7cf5d1afa5c3780a48866d17680c223891e42"
|
|
21
21
|
}
|