@volar/language-service 1.4.0-alpha.11 → 1.4.0-alpha.12
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.
|
@@ -6,7 +6,6 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const referencesCodeLendsEnabled = await context.configurationHost?.getConfiguration('volar.codeLens.references') ?? true;
|
|
10
9
|
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], async (plugin, document) => {
|
|
11
10
|
if (token.isCancellationRequested)
|
|
12
11
|
return;
|
|
@@ -22,19 +21,17 @@ function register(context) {
|
|
|
22
21
|
pluginId,
|
|
23
22
|
};
|
|
24
23
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
codeLens
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
];
|
|
37
|
-
}
|
|
24
|
+
const ranges = await plugin.provideReferencesCodeLensRanges?.(document, token);
|
|
25
|
+
const referencesCodeLens = ranges?.map(range => vscode.CodeLens.create(range, {
|
|
26
|
+
kind: 'references',
|
|
27
|
+
uri,
|
|
28
|
+
range,
|
|
29
|
+
pluginId,
|
|
30
|
+
}));
|
|
31
|
+
codeLens = [
|
|
32
|
+
...codeLens ?? [],
|
|
33
|
+
...referencesCodeLens ?? [],
|
|
34
|
+
];
|
|
38
35
|
return codeLens;
|
|
39
36
|
}, (data, map) => data.map(codeLens => {
|
|
40
37
|
if (!map)
|
|
@@ -4,9 +4,10 @@ exports.register = void 0;
|
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
|
+
const validation_1 = require("./validation");
|
|
7
8
|
function register(context) {
|
|
8
|
-
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
9
|
-
|
|
9
|
+
return async (uri, position, token = vscode.CancellationToken.None) => {
|
|
10
|
+
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => {
|
|
10
11
|
if (token.isCancellationRequested)
|
|
11
12
|
return;
|
|
12
13
|
return plugin.provideHover?.(document, position, token);
|
|
@@ -19,9 +20,37 @@ function register(context) {
|
|
|
19
20
|
return item;
|
|
20
21
|
}
|
|
21
22
|
}, hovers => ({
|
|
22
|
-
contents:
|
|
23
|
+
contents: {
|
|
24
|
+
kind: vscode.MarkupKind.Markdown,
|
|
25
|
+
value: hovers.map(getHoverTexts).flat().join('\n\n---\n\n'),
|
|
26
|
+
},
|
|
23
27
|
range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range ?? hovers[0].range,
|
|
24
28
|
}));
|
|
29
|
+
const markups = validation_1.errorMarkups[uri];
|
|
30
|
+
if (markups) {
|
|
31
|
+
for (const errorAndMarkup of markups) {
|
|
32
|
+
if ((0, common_1.isInsideRange)(errorAndMarkup.error.range, { start: position, end: position })) {
|
|
33
|
+
hover ??= {
|
|
34
|
+
contents: {
|
|
35
|
+
kind: vscode.MarkupKind.Markdown,
|
|
36
|
+
value: '',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
hover.range = errorAndMarkup.error.range;
|
|
40
|
+
if (!vscode.MarkupContent.is(hover.contents)) {
|
|
41
|
+
hover.contents = {
|
|
42
|
+
kind: vscode.MarkupKind.Markdown,
|
|
43
|
+
value: hover.contents,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (hover.contents.value) {
|
|
47
|
+
hover.contents.value += '\n\n---\n\n';
|
|
48
|
+
}
|
|
49
|
+
hover.contents.value += errorAndMarkup.markup.value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return hover;
|
|
25
54
|
};
|
|
26
55
|
}
|
|
27
56
|
exports.register = register;
|
|
@@ -14,4 +14,8 @@ export interface PluginDiagnosticData {
|
|
|
14
14
|
ruleFixIndex: number;
|
|
15
15
|
documentUri: string;
|
|
16
16
|
}
|
|
17
|
+
export declare const errorMarkups: Record<string, {
|
|
18
|
+
error: vscode.Diagnostic;
|
|
19
|
+
markup: vscode.MarkupContent;
|
|
20
|
+
}[]>;
|
|
17
21
|
export declare function register(context: LanguageServicePluginContext): (uri: string, mode: 'all' | 'semantic' | 'syntactic', token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = exports.updateRange = void 0;
|
|
3
|
+
exports.register = exports.errorMarkups = exports.updateRange = void 0;
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
const common_1 = require("../utils/common");
|
|
6
6
|
const dedupe = require("../utils/dedupe");
|
|
@@ -77,6 +77,7 @@ function updatePosition(position, change, isEnd) {
|
|
|
77
77
|
}
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
|
+
exports.errorMarkups = {};
|
|
80
81
|
function register(context) {
|
|
81
82
|
const lastResponses = new Map();
|
|
82
83
|
const cacheMaps = {
|
|
@@ -126,26 +127,37 @@ function register(context) {
|
|
|
126
127
|
}
|
|
127
128
|
if (mode === 'all' || mode === 'syntactic') {
|
|
128
129
|
await lintWorker('onFormat', cacheMaps.format_rules, lastResponse.format_rules);
|
|
129
|
-
doResponse();
|
|
130
|
+
await doResponse();
|
|
130
131
|
await lintWorker('onSyntax', cacheMaps.syntax_rules, lastResponse.syntax_rules);
|
|
131
|
-
doResponse();
|
|
132
|
+
await doResponse();
|
|
132
133
|
await worker('provideSyntacticDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
|
|
133
|
-
doResponse();
|
|
134
|
+
await doResponse();
|
|
134
135
|
}
|
|
135
136
|
if (mode === 'all' || mode === 'semantic') {
|
|
136
137
|
await lintWorker('onSemantic', cacheMaps.semantic_rules, lastResponse.semantic_rules);
|
|
137
|
-
doResponse();
|
|
138
|
+
await doResponse();
|
|
138
139
|
await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
|
|
139
140
|
}
|
|
140
|
-
return collectErrors();
|
|
141
|
-
function doResponse() {
|
|
141
|
+
return await collectErrors();
|
|
142
|
+
async function doResponse() {
|
|
142
143
|
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
143
|
-
response?.(collectErrors());
|
|
144
|
+
response?.(await collectErrors());
|
|
144
145
|
errorsUpdated = false;
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
function collectErrors() {
|
|
148
|
-
|
|
148
|
+
async function collectErrors() {
|
|
149
|
+
const errors = Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
150
|
+
exports.errorMarkups[uri] = [];
|
|
151
|
+
for (const error of errors) {
|
|
152
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
153
|
+
const markup = await plugin.provideDiagnosticMarkupContent?.(error, token);
|
|
154
|
+
if (markup) {
|
|
155
|
+
exports.errorMarkups[uri].push({ error, markup });
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return errors;
|
|
149
161
|
}
|
|
150
162
|
async function lintWorker(api, cacheMap, cache) {
|
|
151
163
|
const result = await (0, featureWorkers_1.ruleWorker)(context, api, uri, file => api === 'onFormat' ? !!file.capabilities.documentFormatting : !!file.capabilities.diagnostic, async (ruleName, rule, ruleCtx) => {
|
package/out/types.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export interface LanguageServicePluginInstance {
|
|
|
114
114
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
115
115
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
116
116
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
117
|
+
provideDiagnosticMarkupContent?(diagnostic: vscode.Diagnostic, token: vscode.CancellationToken): NullableResult<vscode.MarkupContent>;
|
|
117
118
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
118
119
|
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
119
120
|
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.12",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.0-alpha.
|
|
17
|
-
"@volar/source-map": "1.4.0-alpha.
|
|
16
|
+
"@volar/language-core": "1.4.0-alpha.12",
|
|
17
|
+
"@volar/source-map": "1.4.0-alpha.12",
|
|
18
18
|
"typescript-auto-import-cache": "^0.2.1",
|
|
19
19
|
"vscode-html-languageservice": "^5.0.4",
|
|
20
20
|
"vscode-json-languageservice": "^5.2.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "5ae44d90936045b92ad9debcfb9ae952bb311fb8"
|
|
26
26
|
}
|