@volar/language-service 1.3.0-alpha.2 → 1.4.0-alpha.0
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/out/baseLanguageService.d.ts +37 -41
- package/out/baseLanguageService.js +11 -8
- package/out/documentFeatures/colorPresentations.d.ts +1 -1
- package/out/documentFeatures/colorPresentations.js +9 -4
- package/out/documentFeatures/documentColors.d.ts +1 -1
- package/out/documentFeatures/documentColors.js +9 -4
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +8 -4
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.js +7 -2
- package/out/documentFeatures/format.d.ts +2 -2
- package/out/documentFeatures/format.js +12 -6
- package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +9 -4
- package/out/documentFeatures/selectionRanges.d.ts +1 -1
- package/out/documentFeatures/selectionRanges.js +9 -4
- package/out/documents.js +2 -2
- package/out/index.d.ts +2 -0
- package/out/index.js +41 -1
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/autoInsert.js +7 -2
- package/out/languageFeatures/callHierarchy.d.ts +3 -3
- package/out/languageFeatures/callHierarchy.js +15 -13
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +7 -7
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +7 -6
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +8 -6
- package/out/languageFeatures/codeLensResolve.d.ts +1 -1
- package/out/languageFeatures/codeLensResolve.js +7 -7
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +29 -23
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +4 -5
- package/out/languageFeatures/definition.d.ts +1 -1
- package/out/languageFeatures/definition.js +11 -12
- package/out/languageFeatures/documentHighlights.d.ts +1 -1
- package/out/languageFeatures/documentHighlights.js +11 -9
- package/out/languageFeatures/documentLinks.d.ts +1 -1
- package/out/languageFeatures/documentLinks.js +9 -4
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -2
- package/out/languageFeatures/documentSemanticTokens.js +29 -8
- package/out/languageFeatures/fileReferences.d.ts +1 -1
- package/out/languageFeatures/fileReferences.js +6 -4
- package/out/languageFeatures/fileRename.d.ts +2 -1
- package/out/languageFeatures/fileRename.js +5 -3
- package/out/languageFeatures/hover.d.ts +1 -1
- package/out/languageFeatures/hover.js +7 -2
- package/out/languageFeatures/inlayHints.d.ts +1 -1
- package/out/languageFeatures/inlayHints.js +7 -6
- package/out/languageFeatures/references.d.ts +1 -1
- package/out/languageFeatures/references.js +5 -3
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +7 -5
- package/out/languageFeatures/renamePrepare.d.ts +1 -1
- package/out/languageFeatures/renamePrepare.js +7 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.js +19 -2
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +21 -25
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +7 -5
- package/out/transformer/completionItem.js +2 -2
- package/out/transformer/documentSymbol.js +2 -2
- package/out/transformer/locationsLike.js +2 -2
- package/out/transformer/selectionRanges.js +2 -2
- package/out/types.d.ts +56 -80
- package/out/types.js +0 -1
- package/out/utils/SemanticTokensBuilder.d.ts +13 -0
- package/out/utils/SemanticTokensBuilder.js +42 -0
- package/out/utils/common.d.ts +3 -0
- package/out/utils/common.js +25 -1
- package/out/utils/featureWorkers.js +14 -22
- package/package.json +5 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { SemanticToken } from '@volar/language-service';
|
|
3
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
4
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend,
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
11
|
exports.register = void 0;
|
|
3
|
-
const shared = require("@volar/shared");
|
|
4
12
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
13
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
|
+
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
|
|
15
|
+
const common_1 = require("../utils/common");
|
|
6
16
|
function register(context) {
|
|
7
|
-
return (uri, range, legend,
|
|
17
|
+
return (uri, range, legend, token, reportProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
8
18
|
const document = context.getTextDocument(uri);
|
|
9
19
|
if (!document)
|
|
10
20
|
return;
|
|
@@ -15,9 +25,7 @@ function register(context) {
|
|
|
15
25
|
0,
|
|
16
26
|
document.getText().length,
|
|
17
27
|
];
|
|
18
|
-
|
|
19
|
-
if (cancelToken === null || cancelToken === void 0 ? void 0 : cancelToken.isCancellationRequested)
|
|
20
|
-
return;
|
|
28
|
+
const tokens = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, map) {
|
|
21
29
|
let range;
|
|
22
30
|
for (const mapping of map.map.mappings) {
|
|
23
31
|
if (mapping.data.semanticTokens
|
|
@@ -37,7 +45,9 @@ function register(context) {
|
|
|
37
45
|
}
|
|
38
46
|
}, (plugin, document, offsetRange) => {
|
|
39
47
|
var _a;
|
|
40
|
-
|
|
48
|
+
if (token === null || token === void 0 ? void 0 : token.isCancellationRequested)
|
|
49
|
+
return;
|
|
50
|
+
return (_a = plugin.provideDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend, token);
|
|
41
51
|
}, (tokens, map) => tokens.map(_token => {
|
|
42
52
|
if (!map)
|
|
43
53
|
return _token;
|
|
@@ -48,8 +58,19 @@ function register(context) {
|
|
|
48
58
|
if (range) {
|
|
49
59
|
return [range.start.line, range.start.character, _token[2], _token[3], _token[4]];
|
|
50
60
|
}
|
|
51
|
-
}).filter(
|
|
52
|
-
|
|
61
|
+
}).filter(common_1.notEmpty), tokens => tokens.flat(), tokens => reportProgress === null || reportProgress === void 0 ? void 0 : reportProgress(buildTokens(tokens)));
|
|
62
|
+
if (tokens) {
|
|
63
|
+
return buildTokens(tokens);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
53
66
|
}
|
|
54
67
|
exports.register = register;
|
|
68
|
+
function buildTokens(tokens) {
|
|
69
|
+
const builder = new SemanticTokensBuilder_1.SemanticTokensBuilder();
|
|
70
|
+
const sortedTokens = tokens.sort((a, b) => a[0] - b[0] === 0 ? a[1] - b[1] : a[0] - b[0]);
|
|
71
|
+
for (const token of sortedTokens) {
|
|
72
|
+
builder.push(...token);
|
|
73
|
+
}
|
|
74
|
+
return builder.build();
|
|
75
|
+
}
|
|
55
76
|
//# sourceMappingURL=documentSemanticTokens.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { NullableResult } from '@volar/language-service';
|
|
4
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string) => NullableResult<vscode.Location[]>;
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => NullableResult<vscode.Location[]>;
|
|
@@ -9,16 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
13
|
const dedupe = require("../utils/dedupe");
|
|
14
|
+
const common_1 = require("../utils/common");
|
|
15
15
|
function register(context) {
|
|
16
|
-
return (uri) => {
|
|
16
|
+
return (uri, token) => {
|
|
17
17
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, function* (_) {
|
|
18
18
|
yield _;
|
|
19
19
|
}, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b;
|
|
21
|
-
|
|
21
|
+
if (token.isCancellationRequested)
|
|
22
|
+
return;
|
|
23
|
+
return (_b = yield ((_a = plugin.provideFileReferences) === null || _a === void 0 ? void 0 : _a.call(plugin, document, token))) !== null && _b !== void 0 ? _b : [];
|
|
22
24
|
}), (data) => data.map(reference => {
|
|
23
25
|
if (!context.documents.hasVirtualFileByUri(reference.uri)) {
|
|
24
26
|
return reference;
|
|
@@ -31,7 +33,7 @@ function register(context) {
|
|
|
31
33
|
return reference;
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
}).filter(
|
|
36
|
+
}).filter(common_1.notEmpty), arr => dedupe.withLocations(arr.flat()));
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
exports.register = register;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { LanguageServicePluginContext } from '../types';
|
|
2
2
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
3
|
-
|
|
3
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (oldUri: string, newUri: string, token: vscode.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
|
|
@@ -13,7 +13,7 @@ const rename_1 = require("./rename");
|
|
|
13
13
|
const dedupe = require("../utils/dedupe");
|
|
14
14
|
const language_core_1 = require("@volar/language-core");
|
|
15
15
|
function register(context) {
|
|
16
|
-
return (oldUri, newUri) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return (oldUri, newUri, token) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a;
|
|
18
18
|
const rootFile = (_a = context.documents.getSourceByUri(oldUri)) === null || _a === void 0 ? void 0 : _a.root;
|
|
19
19
|
if (rootFile) {
|
|
@@ -30,9 +30,11 @@ function register(context) {
|
|
|
30
30
|
newUri += tsExt;
|
|
31
31
|
}
|
|
32
32
|
for (const plugin of Object.values(context.plugins)) {
|
|
33
|
-
if (!
|
|
33
|
+
if (!token.isCancellationRequested)
|
|
34
|
+
break;
|
|
35
|
+
if (!plugin.provideFileRenameEdits)
|
|
34
36
|
continue;
|
|
35
|
-
const workspaceEdit = yield plugin.
|
|
37
|
+
const workspaceEdit = yield plugin.provideFileRenameEdits(oldUri, newUri, token);
|
|
36
38
|
if (workspaceEdit) {
|
|
37
39
|
const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents, 'fileName');
|
|
38
40
|
if (result === null || result === void 0 ? void 0 : result.documentChanges) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
@@ -4,8 +4,13 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
4
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
5
|
const common_1 = require("../utils/common");
|
|
6
6
|
function register(context) {
|
|
7
|
-
return (uri, position) => {
|
|
8
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => {
|
|
7
|
+
return (uri, position, token) => {
|
|
8
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => {
|
|
9
|
+
var _a;
|
|
10
|
+
if (token.isCancellationRequested)
|
|
11
|
+
return;
|
|
12
|
+
return (_a = plugin.provideHover) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, token);
|
|
13
|
+
}, (item, map) => {
|
|
9
14
|
if (!map || !item.range)
|
|
10
15
|
return item;
|
|
11
16
|
const range = map.toSourceRange(item.range);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range) => Promise<vscode.InlayHint[] | undefined>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, token: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -9,13 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const transformer = require("../transformer");
|
|
14
13
|
const vscode = require("vscode-languageserver-protocol");
|
|
15
14
|
const common_1 = require("../utils/common");
|
|
16
15
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
17
16
|
function register(context) {
|
|
18
|
-
return (uri, range) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return (uri, range, token) => __awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
const document = context.getTextDocument(uri);
|
|
20
19
|
if (!document)
|
|
21
20
|
return;
|
|
@@ -48,18 +47,20 @@ function register(context) {
|
|
|
48
47
|
}
|
|
49
48
|
return [];
|
|
50
49
|
}, (plugin, document, arg) => {
|
|
51
|
-
var _a
|
|
52
|
-
|
|
50
|
+
var _a;
|
|
51
|
+
if (token.isCancellationRequested)
|
|
52
|
+
return;
|
|
53
|
+
return (_a = plugin.provideInlayHints) === null || _a === void 0 ? void 0 : _a.call(plugin, document, arg, token);
|
|
53
54
|
}, (inlayHints, map) => inlayHints.map((_inlayHint) => {
|
|
54
55
|
var _a;
|
|
55
56
|
if (!map)
|
|
56
57
|
return _inlayHint;
|
|
57
58
|
const position = map.toSourcePosition(_inlayHint.position);
|
|
58
|
-
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument)).filter(
|
|
59
|
+
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument)).filter(common_1.notEmpty);
|
|
59
60
|
if (position) {
|
|
60
61
|
return Object.assign(Object.assign({}, _inlayHint), { position, textEdits: edits });
|
|
61
62
|
}
|
|
62
|
-
}).filter(
|
|
63
|
+
}).filter(common_1.notEmpty), arr => arr.flat());
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
exports.register = register;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
@@ -12,8 +12,10 @@ exports.register = void 0;
|
|
|
12
12
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
13
13
|
const dedupe = require("../utils/dedupe");
|
|
14
14
|
function register(context) {
|
|
15
|
-
return (uri, position) => {
|
|
15
|
+
return (uri, position, token) => {
|
|
16
16
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (token.isCancellationRequested)
|
|
18
|
+
return;
|
|
17
19
|
const recursiveChecker = dedupe.createLocationSet();
|
|
18
20
|
const result = [];
|
|
19
21
|
yield withMirrors(document, position);
|
|
@@ -21,12 +23,12 @@ function register(context) {
|
|
|
21
23
|
function withMirrors(document, position) {
|
|
22
24
|
var _a, _b;
|
|
23
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (!plugin.
|
|
26
|
+
if (!plugin.provideReferences)
|
|
25
27
|
return;
|
|
26
28
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
27
29
|
return;
|
|
28
30
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
29
|
-
const references = (_a = yield plugin.
|
|
31
|
+
const references = (_a = yield plugin.provideReferences(document, position, token)) !== null && _a !== void 0 ? _a : [];
|
|
30
32
|
for (const reference of references) {
|
|
31
33
|
let foundMirrorPosition = false;
|
|
32
34
|
recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
import { DocumentsAndSourceMaps } from '../documents';
|
|
4
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, newName: string, token: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
5
|
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
|
6
6
|
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, documents: DocumentsAndSourceMaps, mode: 'fileName' | 'rename' | 'codeAction' | 'format', versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
|
|
@@ -13,7 +13,7 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
13
13
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
15
|
function register(context) {
|
|
16
|
-
return (uri, position, newName) => {
|
|
16
|
+
return (uri, position, newName, token) => {
|
|
17
17
|
let _data;
|
|
18
18
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, { position, newName }, function* (arg, map) {
|
|
19
19
|
for (const mapped of map.toGeneratedPositions(arg.position, data => {
|
|
@@ -28,19 +28,21 @@ function register(context) {
|
|
|
28
28
|
}
|
|
29
29
|
;
|
|
30
30
|
}, (plugin, document, arg) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (token.isCancellationRequested)
|
|
32
|
+
return;
|
|
31
33
|
const recursiveChecker = dedupe.createLocationSet();
|
|
32
34
|
let result;
|
|
33
35
|
yield withMirrors(document, arg.position, arg.newName);
|
|
34
36
|
return result;
|
|
35
37
|
function withMirrors(document, position, newName) {
|
|
36
|
-
var _a
|
|
38
|
+
var _a;
|
|
37
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
if (!
|
|
40
|
+
if (!plugin.provideRenameEdits)
|
|
39
41
|
return;
|
|
40
42
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
41
43
|
return;
|
|
42
44
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
43
|
-
const workspaceEdit = yield plugin.
|
|
45
|
+
const workspaceEdit = yield plugin.provideRenameEdits(document, position, newName, token);
|
|
44
46
|
if (!workspaceEdit)
|
|
45
47
|
return;
|
|
46
48
|
if (!result)
|
|
@@ -51,7 +53,7 @@ function register(context) {
|
|
|
51
53
|
for (const textEdit of textEdits) {
|
|
52
54
|
let foundMirrorPosition = false;
|
|
53
55
|
recursiveChecker.add({ uri: editUri, range: { start: textEdit.range.start, end: textEdit.range.start } });
|
|
54
|
-
const mirrorMap = (
|
|
56
|
+
const mirrorMap = (_a = context.documents.getMirrorMapByUri(editUri)) === null || _a === void 0 ? void 0 : _a[1];
|
|
55
57
|
if (mirrorMap) {
|
|
56
58
|
for (const mapped of mirrorMap.findMirrorPositions(textEdit.range.start)) {
|
|
57
59
|
if (!mapped[1].rename)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
@@ -3,8 +3,13 @@ exports.register = void 0;
|
|
|
3
3
|
const vscode = require("vscode-languageserver-protocol");
|
|
4
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
5
|
function register(context) {
|
|
6
|
-
return (uri, position) => {
|
|
7
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => {
|
|
6
|
+
return (uri, position, token) => {
|
|
7
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (token.isCancellationRequested)
|
|
10
|
+
return;
|
|
11
|
+
return (_a = plugin.provideRenameRange) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, token);
|
|
12
|
+
}, (item, map) => {
|
|
8
13
|
if (!map) {
|
|
9
14
|
return item;
|
|
10
15
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, signatureHelpContext
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, signatureHelpContext: vscode.SignatureHelpContext | undefined, token: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.register = void 0;
|
|
3
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
3
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
5
|
function register(context) {
|
|
5
|
-
return (uri, position, signatureHelpContext) => {
|
|
6
|
-
|
|
6
|
+
return (uri, position, signatureHelpContext, token) => {
|
|
7
|
+
signatureHelpContext !== null && signatureHelpContext !== void 0 ? signatureHelpContext : (signatureHelpContext = {
|
|
8
|
+
triggerKind: vscode.SignatureHelpTriggerKind.Invoked,
|
|
9
|
+
isRetrigger: false,
|
|
10
|
+
});
|
|
11
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
if (token.isCancellationRequested)
|
|
14
|
+
return;
|
|
15
|
+
if ((signatureHelpContext === null || signatureHelpContext === void 0 ? void 0 : signatureHelpContext.triggerKind) === vscode.SignatureHelpTriggerKind.TriggerCharacter
|
|
16
|
+
&& signatureHelpContext.triggerCharacter
|
|
17
|
+
&& !((_a = (signatureHelpContext.isRetrigger
|
|
18
|
+
? plugin.signatureHelpRetriggerCharacters
|
|
19
|
+
: plugin.signatureHelpTriggerCharacters)) === null || _a === void 0 ? void 0 : _a.includes(signatureHelpContext.triggerCharacter))) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return (_b = plugin.provideSignatureHelp) === null || _b === void 0 ? void 0 : _b.call(plugin, document, position, signatureHelpContext, token);
|
|
23
|
+
}, (data) => data);
|
|
7
24
|
};
|
|
8
25
|
}
|
|
9
26
|
exports.register = register;
|
|
@@ -14,4 +14,4 @@ export interface PluginDiagnosticData {
|
|
|
14
14
|
ruleFixIndex: number;
|
|
15
15
|
documentUri: string;
|
|
16
16
|
}
|
|
17
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, token
|
|
17
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken, mode: 'all' | 'semantic' | 'syntactic', response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = exports.updateRange = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const vscode = require("vscode-languageserver-protocol");
|
|
13
|
+
const common_1 = require("../utils/common");
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
15
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
16
16
|
function updateRange(range, change) {
|
|
@@ -89,14 +89,12 @@ function register(context) {
|
|
|
89
89
|
const lastResponses = new Map();
|
|
90
90
|
const cacheMaps = {
|
|
91
91
|
semantic: new Map(),
|
|
92
|
-
declaration: new Map(),
|
|
93
92
|
syntactic: new Map(),
|
|
94
|
-
suggestion: new Map(),
|
|
95
93
|
semantic_rules: new Map(),
|
|
96
94
|
syntax_rules: new Map(),
|
|
97
95
|
format_rules: new Map(),
|
|
98
96
|
};
|
|
99
|
-
return (uri, token, response) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
return (uri, token, mode, response) => __awaiter(this, void 0, void 0, function* () {
|
|
100
98
|
var _a;
|
|
101
99
|
const newDocument = context.getTextDocument(uri);
|
|
102
100
|
if (!newDocument) {
|
|
@@ -104,8 +102,6 @@ function register(context) {
|
|
|
104
102
|
}
|
|
105
103
|
const lastResponse = (_a = lastResponses.get(uri)) !== null && _a !== void 0 ? _a : lastResponses.set(uri, {
|
|
106
104
|
semantic: { errors: [] },
|
|
107
|
-
declaration: { errors: [] },
|
|
108
|
-
suggestion: { errors: [] },
|
|
109
105
|
syntactic: { errors: [] },
|
|
110
106
|
semantic_rules: { errors: [] },
|
|
111
107
|
syntax_rules: { errors: [] },
|
|
@@ -137,19 +133,19 @@ function register(context) {
|
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
if (mode === 'all' || mode === 'syntactic') {
|
|
137
|
+
yield lintWorker('onFormat', cacheMaps.format_rules, lastResponse.format_rules);
|
|
138
|
+
doResponse();
|
|
139
|
+
yield lintWorker('onSyntax', cacheMaps.syntax_rules, lastResponse.syntax_rules);
|
|
140
|
+
doResponse();
|
|
141
|
+
yield worker('provideSyntacticDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
|
|
142
|
+
doResponse();
|
|
143
|
+
}
|
|
144
|
+
if (mode === 'all' || mode === 'semantic') {
|
|
145
|
+
yield lintWorker('onSemantic', cacheMaps.semantic_rules, lastResponse.semantic_rules);
|
|
146
|
+
doResponse();
|
|
147
|
+
yield worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
|
|
148
|
+
}
|
|
153
149
|
return collectErrors();
|
|
154
150
|
function doResponse() {
|
|
155
151
|
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
@@ -167,7 +163,7 @@ function register(context) {
|
|
|
167
163
|
var _h, _j, _k, _l;
|
|
168
164
|
if (token) {
|
|
169
165
|
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
170
|
-
yield
|
|
166
|
+
yield (0, common_1.sleep)(5); // wait for LSP event polling
|
|
171
167
|
lastCheckCancelAt = Date.now();
|
|
172
168
|
}
|
|
173
169
|
if (token.isCancellationRequested) {
|
|
@@ -250,10 +246,10 @@ function register(context) {
|
|
|
250
246
|
yield arg;
|
|
251
247
|
}
|
|
252
248
|
}, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
var _a, _b, _c, _d
|
|
249
|
+
var _a, _b, _c, _d;
|
|
254
250
|
if (token) {
|
|
255
251
|
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
256
|
-
yield
|
|
252
|
+
yield (0, common_1.sleep)(5); // waiting LSP event polling
|
|
257
253
|
lastCheckCancelAt = Date.now();
|
|
258
254
|
}
|
|
259
255
|
if (token.isCancellationRequested) {
|
|
@@ -263,8 +259,8 @@ function register(context) {
|
|
|
263
259
|
const pluginId = Object.keys(context.plugins).find(key => context.plugins[key] === plugin);
|
|
264
260
|
const pluginCache = (_a = cacheMap.get(pluginId)) !== null && _a !== void 0 ? _a : cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
265
261
|
const cache = pluginCache.get(document.uri);
|
|
266
|
-
const tsProjectVersion =
|
|
267
|
-
if (api === '
|
|
262
|
+
const tsProjectVersion = api === 'provideSemanticDiagnostics' ? (_c = (_b = context.core.typescript.languageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
263
|
+
if (api === 'provideSemanticDiagnostics') {
|
|
268
264
|
if (cache && cache.documentVersion === document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
269
265
|
return cache.errors;
|
|
270
266
|
}
|
|
@@ -274,7 +270,7 @@ function register(context) {
|
|
|
274
270
|
return cache.errors;
|
|
275
271
|
}
|
|
276
272
|
}
|
|
277
|
-
const errors = yield ((
|
|
273
|
+
const errors = yield ((_d = plugin[api]) === null || _d === void 0 ? void 0 : _d.call(plugin, document, token));
|
|
278
274
|
errors === null || errors === void 0 ? void 0 : errors.forEach(error => {
|
|
279
275
|
error.data = {
|
|
280
276
|
uri,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (query: string) => Promise<vscode.WorkspaceSymbol[]>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (query: string, token: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
@@ -11,14 +11,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const transformer = require("../transformer");
|
|
13
13
|
const vscode = require("vscode-languageserver-protocol");
|
|
14
|
-
const
|
|
14
|
+
const common_1 = require("../utils/common");
|
|
15
15
|
function register(context) {
|
|
16
|
-
return (query) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return (query, token) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const symbolsList = [];
|
|
18
18
|
for (const plugin of Object.values(context.plugins)) {
|
|
19
|
-
if (
|
|
19
|
+
if (token.isCancellationRequested)
|
|
20
|
+
break;
|
|
21
|
+
if (!plugin.provideWorkspaceSymbols)
|
|
20
22
|
continue;
|
|
21
|
-
const embeddedSymbols = yield plugin.
|
|
23
|
+
const embeddedSymbols = yield plugin.provideWorkspaceSymbols(query, token);
|
|
22
24
|
if (!embeddedSymbols)
|
|
23
25
|
continue;
|
|
24
26
|
const symbols = embeddedSymbols.map(symbol => transformer.asWorkspaceSymbol(symbol, loc => {
|
|
@@ -33,7 +35,7 @@ function register(context) {
|
|
|
33
35
|
else {
|
|
34
36
|
return loc;
|
|
35
37
|
}
|
|
36
|
-
})).filter(
|
|
38
|
+
})).filter(common_1.notEmpty);
|
|
37
39
|
symbolsList.push(symbols);
|
|
38
40
|
}
|
|
39
41
|
return symbolsList.flat();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
|
+
const common_1 = require("../utils/common");
|
|
3
4
|
const textEdit_1 = require("./textEdit");
|
|
4
|
-
const shared = require("@volar/shared");
|
|
5
5
|
function transform(item, getOtherRange, document) {
|
|
6
6
|
var _a;
|
|
7
|
-
return Object.assign(Object.assign({}, item), { additionalTextEdits: (_a = item.additionalTextEdits) === null || _a === void 0 ? void 0 : _a.map(edit => (0, textEdit_1.transform)(edit, getOtherRange, document)).filter(
|
|
7
|
+
return Object.assign(Object.assign({}, item), { additionalTextEdits: (_a = item.additionalTextEdits) === null || _a === void 0 ? void 0 : _a.map(edit => (0, textEdit_1.transform)(edit, getOtherRange, document)).filter(common_1.notEmpty), textEdit: item.textEdit
|
|
8
8
|
? (0, textEdit_1.transform)(item.textEdit, getOtherRange, document)
|
|
9
9
|
: undefined });
|
|
10
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
|
-
const
|
|
3
|
+
const common_1 = require("../utils/common");
|
|
4
4
|
function transform(symbol, getOtherRange) {
|
|
5
5
|
var _a;
|
|
6
6
|
const range = getOtherRange(symbol.range);
|
|
@@ -12,7 +12,7 @@ function transform(symbol, getOtherRange) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
return Object.assign(Object.assign({}, symbol), { range,
|
|
15
|
-
selectionRange, children: (_a = symbol.children) === null || _a === void 0 ? void 0 : _a.map(child => transform(child, getOtherRange)).filter(
|
|
15
|
+
selectionRange, children: (_a = symbol.children) === null || _a === void 0 ? void 0 : _a.map(child => transform(child, getOtherRange)).filter(common_1.notEmpty) });
|
|
16
16
|
}
|
|
17
17
|
exports.transform = transform;
|
|
18
18
|
//# sourceMappingURL=documentSymbol.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
|
-
const
|
|
3
|
+
const common_1 = require("../utils/common");
|
|
4
4
|
const locationLike_1 = require("./locationLike");
|
|
5
5
|
function transform(locations, getOtherRange) {
|
|
6
6
|
return locations
|
|
7
7
|
.map(location => (0, locationLike_1.transform)(location, getOtherRange))
|
|
8
|
-
.filter(
|
|
8
|
+
.filter(common_1.notEmpty);
|
|
9
9
|
}
|
|
10
10
|
exports.transform = transform;
|
|
11
11
|
//# sourceMappingURL=locationsLike.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.transform = void 0;
|
|
3
|
-
const
|
|
3
|
+
const common_1 = require("../utils/common");
|
|
4
4
|
const selectionRange_1 = require("./selectionRange");
|
|
5
5
|
function transform(locations, getOtherRange) {
|
|
6
6
|
return locations
|
|
7
7
|
.map(location => (0, selectionRange_1.transform)(location, getOtherRange))
|
|
8
|
-
.filter(
|
|
8
|
+
.filter(common_1.notEmpty);
|
|
9
9
|
}
|
|
10
10
|
exports.transform = transform;
|
|
11
11
|
//# sourceMappingURL=selectionRanges.js.map
|