@marko/language-server 0.12.14 → 0.12.17
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/dist/index.js +405 -160
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +407 -165
- package/dist/index.mjs.map +3 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -13,7 +13,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
}
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
|
+
mod
|
|
19
|
+
));
|
|
17
20
|
|
|
18
21
|
// src/index.ts
|
|
19
22
|
var import_node = require("vscode-languageserver/node");
|
|
@@ -280,12 +283,14 @@ function parse(source) {
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
program.body.length = i + 1;
|
|
283
|
-
program.static.push(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
program.static.push(
|
|
287
|
+
curParent = {
|
|
288
|
+
type: 20 /* Statement */,
|
|
289
|
+
parent: program,
|
|
290
|
+
start: range.start,
|
|
291
|
+
end: UNFINISHED
|
|
292
|
+
}
|
|
293
|
+
);
|
|
289
294
|
return curBodyType = import_htmljs_parser.TagType.statement;
|
|
290
295
|
}
|
|
291
296
|
default:
|
|
@@ -412,15 +417,18 @@ function parse(source) {
|
|
|
412
417
|
start: range.start,
|
|
413
418
|
end: range.end
|
|
414
419
|
};
|
|
415
|
-
pushAttr(
|
|
416
|
-
type: 8 /* AttrNamed */,
|
|
420
|
+
pushAttr(
|
|
417
421
|
parent,
|
|
418
|
-
name
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
curAttr = name.parent = {
|
|
423
|
+
type: 8 /* AttrNamed */,
|
|
424
|
+
parent,
|
|
425
|
+
name,
|
|
426
|
+
value: void 0,
|
|
427
|
+
args: void 0,
|
|
428
|
+
start: range.start,
|
|
429
|
+
end: range.end
|
|
430
|
+
}
|
|
431
|
+
);
|
|
424
432
|
},
|
|
425
433
|
onAttrArgs(range) {
|
|
426
434
|
curAttr.args = {
|
|
@@ -580,7 +588,11 @@ function loadCompilerInfo(dir) {
|
|
|
580
588
|
let compiler = builtinCompiler;
|
|
581
589
|
if (pkg && /^5\./.test(pkg.version)) {
|
|
582
590
|
try {
|
|
583
|
-
let checkTranslator = [].concat(
|
|
591
|
+
let checkTranslator = [].concat(
|
|
592
|
+
Object.keys(pkg.dependencies),
|
|
593
|
+
Object.keys(pkg.peerDependencies),
|
|
594
|
+
Object.keys(pkg.devDependencies)
|
|
595
|
+
).find((name) => /^marko$|^(@\/marko\/|marko-)translator-/.test(name));
|
|
584
596
|
if (checkTranslator === "marko" || !checkTranslator) {
|
|
585
597
|
checkTranslator = require((0, import_resolve_from.default)(dir, "@marko/compiler/config")).translator;
|
|
586
598
|
}
|
|
@@ -661,10 +673,13 @@ ${closingTagStr}`
|
|
|
661
673
|
label: closingTagStr,
|
|
662
674
|
kind: import_vscode_languageserver.CompletionItemKind.Class,
|
|
663
675
|
insertTextFormat: import_vscode_languageserver.InsertTextFormat.Snippet,
|
|
664
|
-
textEdit: import_vscode_languageserver.TextEdit.replace(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
676
|
+
textEdit: import_vscode_languageserver.TextEdit.replace(
|
|
677
|
+
parsed.locationAt({
|
|
678
|
+
start,
|
|
679
|
+
end
|
|
680
|
+
}),
|
|
681
|
+
closingTagStr
|
|
682
|
+
)
|
|
668
683
|
}
|
|
669
684
|
];
|
|
670
685
|
}
|
|
@@ -685,7 +700,9 @@ function getTagNameCompletion({
|
|
|
685
700
|
let label = tag.isNestedTag ? `@${tag.name}` : tag.name;
|
|
686
701
|
const fileForTag = tag.template || tag.renderer || tag.filePath;
|
|
687
702
|
const fileURIForTag = import_vscode_uri2.URI.file(fileForTag).toString();
|
|
688
|
-
const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(
|
|
703
|
+
const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(
|
|
704
|
+
fileForTag
|
|
705
|
+
);
|
|
689
706
|
const nodeModuleName = nodeModuleMatch && nodeModuleMatch[1];
|
|
690
707
|
const isCoreTag = /^@?marko[/-]/.test(tag.taglibId) || nodeModuleName === "marko";
|
|
691
708
|
const documentation = {
|
|
@@ -748,12 +765,14 @@ function OpenTagName({
|
|
|
748
765
|
for (const key in nestedTags) {
|
|
749
766
|
if (key !== "*") {
|
|
750
767
|
const tag2 = nestedTags[key];
|
|
751
|
-
result.push(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
768
|
+
result.push(
|
|
769
|
+
getTagNameCompletion({
|
|
770
|
+
tag: tag2,
|
|
771
|
+
range,
|
|
772
|
+
importer,
|
|
773
|
+
showAutoComplete: true
|
|
774
|
+
})
|
|
775
|
+
);
|
|
757
776
|
}
|
|
758
777
|
}
|
|
759
778
|
}
|
|
@@ -761,12 +780,14 @@ function OpenTagName({
|
|
|
761
780
|
const skipStatements = !(tag.concise && tag.parent.type === 0 /* Program */);
|
|
762
781
|
for (const tag2 of lookup.getTagsSorted()) {
|
|
763
782
|
if (!(tag2.name === "*" || tag2.isNestedTag || skipStatements && ((_a = tag2.parseOptions) == null ? void 0 : _a.statement) || tag2.name[0] === "_" && /^@?marko[/-]|[\\/]node_modules[\\/]/.test(tag2.filePath))) {
|
|
764
|
-
result.push(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
783
|
+
result.push(
|
|
784
|
+
getTagNameCompletion({
|
|
785
|
+
tag: tag2,
|
|
786
|
+
range,
|
|
787
|
+
importer,
|
|
788
|
+
showAutoComplete: true
|
|
789
|
+
})
|
|
790
|
+
);
|
|
770
791
|
}
|
|
771
792
|
}
|
|
772
793
|
}
|
|
@@ -805,10 +826,12 @@ function AttrName({
|
|
|
805
826
|
}
|
|
806
827
|
}
|
|
807
828
|
const completions = [];
|
|
808
|
-
const attrNameLoc = parsed.locationAt(
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
829
|
+
const attrNameLoc = parsed.locationAt(
|
|
830
|
+
hasModifier ? {
|
|
831
|
+
start: node.start,
|
|
832
|
+
end: node.start + name.length
|
|
833
|
+
} : node
|
|
834
|
+
);
|
|
812
835
|
const tagName = node.parent.parent.nameText || "";
|
|
813
836
|
const tagDef = tagName && lookup.getTag(tagName);
|
|
814
837
|
const nestedTagAttrs = {};
|
|
@@ -942,7 +965,11 @@ async function readDirectory(uri) {
|
|
|
942
965
|
try {
|
|
943
966
|
const entries = await import_promises.default.readdir((0, import_url.fileURLToPath)(uri));
|
|
944
967
|
const base = uri.at(-1) === "/" ? uri : `${uri}/`;
|
|
945
|
-
return (await Promise.all(
|
|
968
|
+
return (await Promise.all(
|
|
969
|
+
entries.map(
|
|
970
|
+
async (entry) => [entry, (await stat(new URL(entry, base).toString())).type]
|
|
971
|
+
)
|
|
972
|
+
)).filter(([, type]) => type !== import_vscode_css_languageservice.FileType.Unknown);
|
|
946
973
|
} catch {
|
|
947
974
|
return [];
|
|
948
975
|
}
|
|
@@ -986,22 +1013,27 @@ async function AttrValue({
|
|
|
986
1013
|
if (uri) {
|
|
987
1014
|
const result = [];
|
|
988
1015
|
const curFile = req === "." ? import_path3.default.basename(document.uri) : void 0;
|
|
989
|
-
const replaceRange = import_vscode_languageserver4.Range.create(
|
|
1016
|
+
const replaceRange = import_vscode_languageserver4.Range.create(
|
|
1017
|
+
document.positionAt(start + segmentStart + 1),
|
|
1018
|
+
document.positionAt(start + rawValue.length)
|
|
1019
|
+
);
|
|
990
1020
|
for (const [entry, type] of await file_system_default.readDirectory(uri)) {
|
|
991
1021
|
if (entry[0] !== "." && entry !== curFile) {
|
|
992
|
-
result.push(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1022
|
+
result.push(
|
|
1023
|
+
type === import_vscode_css_languageservice.FileType.Directory ? {
|
|
1024
|
+
label: `${entry}/`,
|
|
1025
|
+
kind: import_vscode_languageserver4.CompletionItemKind.Folder,
|
|
1026
|
+
textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, `${entry}/`),
|
|
1027
|
+
command: {
|
|
1028
|
+
title: "Suggest",
|
|
1029
|
+
command: "editor.action.triggerSuggest"
|
|
1030
|
+
}
|
|
1031
|
+
} : {
|
|
1032
|
+
label: entry,
|
|
1033
|
+
kind: import_vscode_languageserver4.CompletionItemKind.File,
|
|
1034
|
+
textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, entry)
|
|
999
1035
|
}
|
|
1000
|
-
|
|
1001
|
-
label: entry,
|
|
1002
|
-
kind: import_vscode_languageserver4.CompletionItemKind.File,
|
|
1003
|
-
textEdit: import_vscode_languageserver4.TextEdit.replace(replaceRange, entry)
|
|
1004
|
-
});
|
|
1036
|
+
);
|
|
1005
1037
|
}
|
|
1006
1038
|
}
|
|
1007
1039
|
return result;
|
|
@@ -1061,20 +1093,23 @@ var doComplete = async (doc, params) => {
|
|
|
1061
1093
|
const parsed = parse2(doc);
|
|
1062
1094
|
const offset = doc.offsetAt(params.position);
|
|
1063
1095
|
const node = parsed.nodeAt(offset);
|
|
1064
|
-
return import_vscode_languageserver6.CompletionList.create(
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1096
|
+
return import_vscode_languageserver6.CompletionList.create(
|
|
1097
|
+
await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
|
|
1098
|
+
document: doc,
|
|
1099
|
+
params,
|
|
1100
|
+
parsed,
|
|
1101
|
+
offset,
|
|
1102
|
+
node,
|
|
1103
|
+
code: doc.getText(),
|
|
1104
|
+
...getCompilerInfo(doc)
|
|
1105
|
+
})) || [],
|
|
1106
|
+
true
|
|
1107
|
+
);
|
|
1073
1108
|
};
|
|
1074
1109
|
|
|
1075
1110
|
// src/service/marko/validate.ts
|
|
1076
1111
|
var import_vscode_languageserver7 = require("vscode-languageserver");
|
|
1077
|
-
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
1112
|
+
var markoErrorRegExp = /^(.+?)\.marko(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
1078
1113
|
var doValidate = (doc) => {
|
|
1079
1114
|
const fsPath = getDocFile(doc);
|
|
1080
1115
|
const diagnostics = [];
|
|
@@ -1085,15 +1120,33 @@ var doValidate = (doc) => {
|
|
|
1085
1120
|
translator,
|
|
1086
1121
|
code: false,
|
|
1087
1122
|
output: "source",
|
|
1088
|
-
sourceMaps: false
|
|
1123
|
+
sourceMaps: false,
|
|
1124
|
+
babelConfig: {
|
|
1125
|
+
caller: {
|
|
1126
|
+
name: "@marko/language-server",
|
|
1127
|
+
supportsStaticESM: true,
|
|
1128
|
+
supportsDynamicImport: true,
|
|
1129
|
+
supportsTopLevelAwait: true,
|
|
1130
|
+
supportsExportNamespaceFrom: true
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1089
1133
|
});
|
|
1090
1134
|
} catch (e) {
|
|
1091
1135
|
let match;
|
|
1092
1136
|
while (match = markoErrorRegExp.exec(e.message)) {
|
|
1093
|
-
const [,
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1137
|
+
const [, , rawLine, rawCol, message] = match;
|
|
1138
|
+
const pos = {
|
|
1139
|
+
line: (parseInt(rawLine, 10) || 1) - 1,
|
|
1140
|
+
character: (parseInt(rawCol, 10) || 1) - 1
|
|
1141
|
+
};
|
|
1142
|
+
diagnostics.push({
|
|
1143
|
+
range: { start: pos, end: pos },
|
|
1144
|
+
source: "marko",
|
|
1145
|
+
code: void 0,
|
|
1146
|
+
tags: void 0,
|
|
1147
|
+
severity: import_vscode_languageserver7.DiagnosticSeverity.Error,
|
|
1148
|
+
message
|
|
1149
|
+
});
|
|
1097
1150
|
}
|
|
1098
1151
|
}
|
|
1099
1152
|
return diagnostics;
|
|
@@ -1104,7 +1157,10 @@ var import_fs = __toESM(require("fs"));
|
|
|
1104
1157
|
var import_vscode_uri3 = require("vscode-uri");
|
|
1105
1158
|
var import_vscode_languageserver8 = require("vscode-languageserver");
|
|
1106
1159
|
var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
|
|
1107
|
-
var START_OF_FILE = import_vscode_languageserver8.Range.create(
|
|
1160
|
+
var START_OF_FILE = import_vscode_languageserver8.Range.create(
|
|
1161
|
+
import_vscode_languageserver8.Position.create(0, 0),
|
|
1162
|
+
import_vscode_languageserver8.Position.create(0, 0)
|
|
1163
|
+
);
|
|
1108
1164
|
function createTextDocument(filename) {
|
|
1109
1165
|
const uri = import_vscode_uri3.URI.file(filename).toString();
|
|
1110
1166
|
const content = import_fs.default.readFileSync(filename, "utf-8");
|
|
@@ -1210,13 +1266,23 @@ function OpenTagName3({
|
|
|
1210
1266
|
}
|
|
1211
1267
|
if (/\/marko(?:-tag)?\.json$/.test(tagEntryFile)) {
|
|
1212
1268
|
const tagDefDoc = createTextDocument(tagEntryFile);
|
|
1213
|
-
const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(
|
|
1269
|
+
const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(
|
|
1270
|
+
tagDefDoc.getText()
|
|
1271
|
+
);
|
|
1214
1272
|
if (match && match.index) {
|
|
1215
|
-
range = import_vscode_languageserver9.Range.create(
|
|
1273
|
+
range = import_vscode_languageserver9.Range.create(
|
|
1274
|
+
tagDefDoc.positionAt(match.index),
|
|
1275
|
+
tagDefDoc.positionAt(match.index + match[0].length)
|
|
1276
|
+
);
|
|
1216
1277
|
}
|
|
1217
1278
|
}
|
|
1218
1279
|
return [
|
|
1219
|
-
import_vscode_languageserver9.LocationLink.create(
|
|
1280
|
+
import_vscode_languageserver9.LocationLink.create(
|
|
1281
|
+
import_vscode_uri4.URI.file(tagEntryFile).toString(),
|
|
1282
|
+
range,
|
|
1283
|
+
range,
|
|
1284
|
+
parsed.locationAt(node)
|
|
1285
|
+
)
|
|
1220
1286
|
];
|
|
1221
1287
|
}
|
|
1222
1288
|
|
|
@@ -1244,13 +1310,23 @@ function AttrName2({
|
|
|
1244
1310
|
}
|
|
1245
1311
|
if (/\/marko(?:-tag)?\.json$/.test(attrEntryFile)) {
|
|
1246
1312
|
const tagDefDoc = createTextDocument(attrEntryFile);
|
|
1247
|
-
const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(
|
|
1313
|
+
const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(
|
|
1314
|
+
tagDefDoc.getText()
|
|
1315
|
+
);
|
|
1248
1316
|
if (match && match.index) {
|
|
1249
|
-
range = import_vscode_languageserver10.Range.create(
|
|
1317
|
+
range = import_vscode_languageserver10.Range.create(
|
|
1318
|
+
tagDefDoc.positionAt(match.index),
|
|
1319
|
+
tagDefDoc.positionAt(match.index + match[0].length)
|
|
1320
|
+
);
|
|
1250
1321
|
}
|
|
1251
1322
|
}
|
|
1252
1323
|
return [
|
|
1253
|
-
import_vscode_languageserver10.LocationLink.create(
|
|
1324
|
+
import_vscode_languageserver10.LocationLink.create(
|
|
1325
|
+
import_vscode_uri5.URI.file(attrEntryFile).toString(),
|
|
1326
|
+
range,
|
|
1327
|
+
range,
|
|
1328
|
+
parsed.locationAt(node)
|
|
1329
|
+
)
|
|
1254
1330
|
];
|
|
1255
1331
|
}
|
|
1256
1332
|
|
|
@@ -1310,9 +1386,17 @@ function extractDocumentLinks(doc, parsed, lookup) {
|
|
|
1310
1386
|
if (node.attrs && node.nameText) {
|
|
1311
1387
|
for (const attr of node.attrs) {
|
|
1312
1388
|
if (isDocumentLinkAttr(doc, node, attr)) {
|
|
1313
|
-
const resolved = resolveUrl(
|
|
1389
|
+
const resolved = resolveUrl(
|
|
1390
|
+
read(attr.value.value).slice(1, -1),
|
|
1391
|
+
doc.uri
|
|
1392
|
+
);
|
|
1314
1393
|
if (resolved) {
|
|
1315
|
-
links.push(
|
|
1394
|
+
links.push(
|
|
1395
|
+
import_vscode_languageserver11.DocumentLink.create(
|
|
1396
|
+
parsed.locationAt(attr.value.value),
|
|
1397
|
+
resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)
|
|
1398
|
+
)
|
|
1399
|
+
);
|
|
1316
1400
|
}
|
|
1317
1401
|
}
|
|
1318
1402
|
}
|
|
@@ -1335,10 +1419,15 @@ function extractDocumentLinks(doc, parsed, lookup) {
|
|
|
1335
1419
|
const tagDef = lookup.getTag(tagName);
|
|
1336
1420
|
const fileForTag = tagDef && (tagDef.template || tagDef.renderer);
|
|
1337
1421
|
if (fileForTag) {
|
|
1338
|
-
links.push(
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1422
|
+
links.push(
|
|
1423
|
+
import_vscode_languageserver11.DocumentLink.create(
|
|
1424
|
+
parsed.locationAt({
|
|
1425
|
+
start: item.start + match.index,
|
|
1426
|
+
end: item.start + match.index + length
|
|
1427
|
+
}),
|
|
1428
|
+
fileForTag
|
|
1429
|
+
)
|
|
1430
|
+
);
|
|
1342
1431
|
}
|
|
1343
1432
|
}
|
|
1344
1433
|
}
|
|
@@ -1373,7 +1462,14 @@ function extractDocumentSymbols(doc, parsed, lookup) {
|
|
|
1373
1462
|
switch (node.type) {
|
|
1374
1463
|
case 1 /* Tag */:
|
|
1375
1464
|
case 14 /* AttrTag */:
|
|
1376
|
-
symbols.push(
|
|
1465
|
+
symbols.push(
|
|
1466
|
+
import_vscode_languageserver12.SymbolInformation.create(
|
|
1467
|
+
(node.type === 14 /* AttrTag */ ? (_a = node.nameText) == null ? void 0 : _a.slice(node.nameText.indexOf("@")) : node.nameText) || "<${...}>",
|
|
1468
|
+
node.nameText && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html) && import_vscode_languageserver12.SymbolKind.Property || import_vscode_languageserver12.SymbolKind.Class,
|
|
1469
|
+
parsed.locationAt(node),
|
|
1470
|
+
doc.uri
|
|
1471
|
+
)
|
|
1472
|
+
);
|
|
1377
1473
|
if (node.body) {
|
|
1378
1474
|
for (const child of node.body) {
|
|
1379
1475
|
visit(child);
|
|
@@ -1410,7 +1506,10 @@ var format2 = async (doc, params, cancel) => {
|
|
|
1410
1506
|
if (cancel.isCancellationRequested)
|
|
1411
1507
|
return;
|
|
1412
1508
|
return [
|
|
1413
|
-
import_vscode_languageserver13.TextEdit.replace(
|
|
1509
|
+
import_vscode_languageserver13.TextEdit.replace(
|
|
1510
|
+
import_vscode_languageserver13.Range.create(doc.positionAt(0), doc.positionAt(text.length)),
|
|
1511
|
+
prettier.format(text, options)
|
|
1512
|
+
)
|
|
1414
1513
|
];
|
|
1415
1514
|
} catch (e) {
|
|
1416
1515
|
displayError(e);
|
|
@@ -1618,12 +1717,21 @@ var StyleSheetService = {
|
|
|
1618
1717
|
if (generatedOffset === void 0)
|
|
1619
1718
|
continue;
|
|
1620
1719
|
const { service: service2, virtualDoc } = info;
|
|
1621
|
-
const result = await service2.doComplete2(
|
|
1720
|
+
const result = await service2.doComplete2(
|
|
1721
|
+
virtualDoc,
|
|
1722
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1723
|
+
info.parsed,
|
|
1724
|
+
{ resolveReference: resolveUrl }
|
|
1725
|
+
);
|
|
1622
1726
|
if (result.itemDefaults) {
|
|
1623
1727
|
const { editRange } = result.itemDefaults;
|
|
1624
1728
|
if (editRange) {
|
|
1625
1729
|
if ("start" in editRange) {
|
|
1626
|
-
result.itemDefaults.editRange = getSourceRange(
|
|
1730
|
+
result.itemDefaults.editRange = getSourceRange(
|
|
1731
|
+
doc,
|
|
1732
|
+
info,
|
|
1733
|
+
editRange
|
|
1734
|
+
);
|
|
1627
1735
|
} else {
|
|
1628
1736
|
editRange.insert = getSourceRange(doc, info, editRange.insert);
|
|
1629
1737
|
editRange.replace = getSourceRange(doc, info, editRange.replace);
|
|
@@ -1635,7 +1743,11 @@ var StyleSheetService = {
|
|
|
1635
1743
|
item.textEdit = getSourceInsertReplaceEdit(doc, info, item.textEdit);
|
|
1636
1744
|
}
|
|
1637
1745
|
if (item.additionalTextEdits) {
|
|
1638
|
-
item.additionalTextEdits = getSourceEdits(
|
|
1746
|
+
item.additionalTextEdits = getSourceEdits(
|
|
1747
|
+
doc,
|
|
1748
|
+
info,
|
|
1749
|
+
item.additionalTextEdits
|
|
1750
|
+
);
|
|
1639
1751
|
}
|
|
1640
1752
|
}
|
|
1641
1753
|
return result;
|
|
@@ -1651,7 +1763,11 @@ var StyleSheetService = {
|
|
|
1651
1763
|
if (generatedOffset === void 0)
|
|
1652
1764
|
continue;
|
|
1653
1765
|
const { service: service2, virtualDoc } = info;
|
|
1654
|
-
const result = service2.findDefinition(
|
|
1766
|
+
const result = service2.findDefinition(
|
|
1767
|
+
virtualDoc,
|
|
1768
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1769
|
+
info.parsed
|
|
1770
|
+
);
|
|
1655
1771
|
if (result) {
|
|
1656
1772
|
const range = getSourceRange(doc, info, result.range);
|
|
1657
1773
|
if (range) {
|
|
@@ -1674,7 +1790,11 @@ var StyleSheetService = {
|
|
|
1674
1790
|
continue;
|
|
1675
1791
|
const { service: service2, virtualDoc } = info;
|
|
1676
1792
|
const result = [];
|
|
1677
|
-
for (const location of service2.findReferences(
|
|
1793
|
+
for (const location of service2.findReferences(
|
|
1794
|
+
virtualDoc,
|
|
1795
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1796
|
+
info.parsed
|
|
1797
|
+
)) {
|
|
1678
1798
|
const range = getSourceRange(doc, info, location.range);
|
|
1679
1799
|
if (range) {
|
|
1680
1800
|
result.push({
|
|
@@ -1692,7 +1812,10 @@ var StyleSheetService = {
|
|
|
1692
1812
|
for (const ext in infoByExt) {
|
|
1693
1813
|
const info = infoByExt[ext];
|
|
1694
1814
|
const { service: service2, virtualDoc } = info;
|
|
1695
|
-
for (const symbol of service2.findDocumentSymbols(
|
|
1815
|
+
for (const symbol of service2.findDocumentSymbols(
|
|
1816
|
+
virtualDoc,
|
|
1817
|
+
info.parsed
|
|
1818
|
+
)) {
|
|
1696
1819
|
if (symbol.location.uri === doc.uri) {
|
|
1697
1820
|
const range = getSourceRange(doc, info, symbol.location.range);
|
|
1698
1821
|
if (range) {
|
|
@@ -1718,7 +1841,11 @@ var StyleSheetService = {
|
|
|
1718
1841
|
for (const ext in infoByExt) {
|
|
1719
1842
|
const info = infoByExt[ext];
|
|
1720
1843
|
const { service: service2, virtualDoc } = info;
|
|
1721
|
-
for (const link of await service2.findDocumentLinks2(
|
|
1844
|
+
for (const link of await service2.findDocumentLinks2(
|
|
1845
|
+
virtualDoc,
|
|
1846
|
+
info.parsed,
|
|
1847
|
+
{ resolveReference: resolveUrl }
|
|
1848
|
+
)) {
|
|
1722
1849
|
const range = getSourceRange(doc, info, link.range);
|
|
1723
1850
|
if (range) {
|
|
1724
1851
|
result.push({
|
|
@@ -1742,7 +1869,11 @@ var StyleSheetService = {
|
|
|
1742
1869
|
continue;
|
|
1743
1870
|
const { service: service2, virtualDoc } = info;
|
|
1744
1871
|
const result = [];
|
|
1745
|
-
for (const highlight of service2.findDocumentHighlights(
|
|
1872
|
+
for (const highlight of service2.findDocumentHighlights(
|
|
1873
|
+
virtualDoc,
|
|
1874
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1875
|
+
info.parsed
|
|
1876
|
+
)) {
|
|
1746
1877
|
const range = getSourceRange(doc, info, highlight.range);
|
|
1747
1878
|
if (range) {
|
|
1748
1879
|
result.push({
|
|
@@ -1760,7 +1891,10 @@ var StyleSheetService = {
|
|
|
1760
1891
|
for (const ext in infoByExt) {
|
|
1761
1892
|
const info = infoByExt[ext];
|
|
1762
1893
|
const { service: service2, virtualDoc } = info;
|
|
1763
|
-
for (const colorInfo of service2.findDocumentColors(
|
|
1894
|
+
for (const colorInfo of service2.findDocumentColors(
|
|
1895
|
+
virtualDoc,
|
|
1896
|
+
info.parsed
|
|
1897
|
+
)) {
|
|
1764
1898
|
const range = getSourceRange(doc, info, colorInfo.range);
|
|
1765
1899
|
if (range) {
|
|
1766
1900
|
result.push({
|
|
@@ -1780,12 +1914,22 @@ var StyleSheetService = {
|
|
|
1780
1914
|
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1781
1915
|
if (generatedOffsetStart === void 0)
|
|
1782
1916
|
continue;
|
|
1783
|
-
const generatedOffsetEnd = info.generatedOffsetAt(
|
|
1917
|
+
const generatedOffsetEnd = info.generatedOffsetAt(
|
|
1918
|
+
doc.offsetAt(params.range.end)
|
|
1919
|
+
);
|
|
1784
1920
|
if (generatedOffsetEnd === void 0)
|
|
1785
1921
|
continue;
|
|
1786
1922
|
const { service: service2, virtualDoc } = info;
|
|
1787
1923
|
const result = [];
|
|
1788
|
-
for (const colorPresentation of service2.getColorPresentations(
|
|
1924
|
+
for (const colorPresentation of service2.getColorPresentations(
|
|
1925
|
+
virtualDoc,
|
|
1926
|
+
info.parsed,
|
|
1927
|
+
params.color,
|
|
1928
|
+
import_vscode_languageserver14.Range.create(
|
|
1929
|
+
virtualDoc.positionAt(generatedOffsetStart),
|
|
1930
|
+
virtualDoc.positionAt(generatedOffsetEnd)
|
|
1931
|
+
)
|
|
1932
|
+
)) {
|
|
1789
1933
|
const textEdit = colorPresentation.textEdit && getSourceEdit(doc, info, colorPresentation.textEdit);
|
|
1790
1934
|
const additionalTextEdits = colorPresentation.additionalTextEdits && getSourceEdits(doc, info, colorPresentation.additionalTextEdits);
|
|
1791
1935
|
if (textEdit || additionalTextEdits) {
|
|
@@ -1808,7 +1952,11 @@ var StyleSheetService = {
|
|
|
1808
1952
|
if (generatedOffset === void 0)
|
|
1809
1953
|
continue;
|
|
1810
1954
|
const { service: service2, virtualDoc } = info;
|
|
1811
|
-
const result = service2.doHover(
|
|
1955
|
+
const result = service2.doHover(
|
|
1956
|
+
virtualDoc,
|
|
1957
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1958
|
+
info.parsed
|
|
1959
|
+
);
|
|
1812
1960
|
if (result) {
|
|
1813
1961
|
if (result.range) {
|
|
1814
1962
|
const range = getSourceRange(doc, info, result.range);
|
|
@@ -1833,7 +1981,12 @@ var StyleSheetService = {
|
|
|
1833
1981
|
if (generatedOffset === void 0)
|
|
1834
1982
|
continue;
|
|
1835
1983
|
const { service: service2, virtualDoc } = info;
|
|
1836
|
-
const result = service2.doRename(
|
|
1984
|
+
const result = service2.doRename(
|
|
1985
|
+
virtualDoc,
|
|
1986
|
+
virtualDoc.positionAt(generatedOffset),
|
|
1987
|
+
params.newName,
|
|
1988
|
+
info.parsed
|
|
1989
|
+
);
|
|
1837
1990
|
if (result.changes) {
|
|
1838
1991
|
for (const uri in result.changes) {
|
|
1839
1992
|
if (uri === doc.uri) {
|
|
@@ -1862,11 +2015,21 @@ var StyleSheetService = {
|
|
|
1862
2015
|
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1863
2016
|
if (generatedOffsetStart === void 0)
|
|
1864
2017
|
continue;
|
|
1865
|
-
const generatedOffsetEnd = info.generatedOffsetAt(
|
|
2018
|
+
const generatedOffsetEnd = info.generatedOffsetAt(
|
|
2019
|
+
doc.offsetAt(params.range.end)
|
|
2020
|
+
);
|
|
1866
2021
|
if (generatedOffsetEnd === void 0)
|
|
1867
2022
|
continue;
|
|
1868
2023
|
const { service: service2, virtualDoc } = info;
|
|
1869
|
-
const result = service2.doCodeActions(
|
|
2024
|
+
const result = service2.doCodeActions(
|
|
2025
|
+
virtualDoc,
|
|
2026
|
+
import_vscode_languageserver14.Range.create(
|
|
2027
|
+
virtualDoc.positionAt(generatedOffsetStart),
|
|
2028
|
+
virtualDoc.positionAt(generatedOffsetEnd)
|
|
2029
|
+
),
|
|
2030
|
+
params.context,
|
|
2031
|
+
info.parsed
|
|
2032
|
+
);
|
|
1870
2033
|
for (const command of result) {
|
|
1871
2034
|
const edits = (_a = command.arguments) == null ? void 0 : _a[2];
|
|
1872
2035
|
if (edits && Array.isArray(edits) && isTextEdit(edits[0])) {
|
|
@@ -1881,7 +2044,10 @@ var StyleSheetService = {
|
|
|
1881
2044
|
const result = [];
|
|
1882
2045
|
for (const ext in infoByExt) {
|
|
1883
2046
|
const info = infoByExt[ext];
|
|
1884
|
-
for (const diag of info.service.doValidation(
|
|
2047
|
+
for (const diag of info.service.doValidation(
|
|
2048
|
+
info.virtualDoc,
|
|
2049
|
+
info.parsed
|
|
2050
|
+
)) {
|
|
1885
2051
|
const range = getSourceRange(doc, info, diag.range);
|
|
1886
2052
|
if (range) {
|
|
1887
2053
|
diag.range = range;
|
|
@@ -1953,7 +2119,11 @@ function getStyleSheetInfo(doc) {
|
|
|
1953
2119
|
const parsed = parse2(doc);
|
|
1954
2120
|
let cached = cache3.get(parsed);
|
|
1955
2121
|
if (!cached) {
|
|
1956
|
-
const results = extractStyleSheets(
|
|
2122
|
+
const results = extractStyleSheets(
|
|
2123
|
+
doc.getText(),
|
|
2124
|
+
parsed.program,
|
|
2125
|
+
getCompilerInfo(doc).lookup
|
|
2126
|
+
);
|
|
1957
2127
|
cached = {};
|
|
1958
2128
|
for (const ext in results) {
|
|
1959
2129
|
const service2 = (_a = services[ext]) == null ? void 0 : _a.call(services, {
|
|
@@ -1963,7 +2133,12 @@ function getStyleSheetInfo(doc) {
|
|
|
1963
2133
|
if (!service2)
|
|
1964
2134
|
continue;
|
|
1965
2135
|
const { generated, sourceOffsetAt, generatedOffsetAt } = results[ext];
|
|
1966
|
-
const virtualDoc = import_vscode_languageserver_textdocument2.TextDocument.create(
|
|
2136
|
+
const virtualDoc = import_vscode_languageserver_textdocument2.TextDocument.create(
|
|
2137
|
+
doc.uri,
|
|
2138
|
+
"css",
|
|
2139
|
+
doc.version,
|
|
2140
|
+
generated
|
|
2141
|
+
);
|
|
1967
2142
|
cached[ext] = {
|
|
1968
2143
|
service: service2,
|
|
1969
2144
|
virtualDoc,
|
|
@@ -1993,10 +2168,12 @@ var service = {
|
|
|
1993
2168
|
let items;
|
|
1994
2169
|
let isIncomplete = false;
|
|
1995
2170
|
try {
|
|
1996
|
-
for (const pending of plugins.map(
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2171
|
+
for (const pending of plugins.map(
|
|
2172
|
+
(plugin) => {
|
|
2173
|
+
var _a;
|
|
2174
|
+
return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2175
|
+
}
|
|
2176
|
+
)) {
|
|
2000
2177
|
const cur = await pending;
|
|
2001
2178
|
if (cancel.isCancellationRequested)
|
|
2002
2179
|
return;
|
|
@@ -2022,10 +2199,12 @@ var service = {
|
|
|
2022
2199
|
async findDefinition(doc, params, cancel) {
|
|
2023
2200
|
let result;
|
|
2024
2201
|
try {
|
|
2025
|
-
for (const pending of plugins.map(
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2202
|
+
for (const pending of plugins.map(
|
|
2203
|
+
(plugin) => {
|
|
2204
|
+
var _a;
|
|
2205
|
+
return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2206
|
+
}
|
|
2207
|
+
)) {
|
|
2029
2208
|
const cur = await pending;
|
|
2030
2209
|
if (cancel.isCancellationRequested)
|
|
2031
2210
|
return;
|
|
@@ -2040,10 +2219,12 @@ var service = {
|
|
|
2040
2219
|
async findReferences(doc, params, cancel) {
|
|
2041
2220
|
let result;
|
|
2042
2221
|
try {
|
|
2043
|
-
for (const pending of plugins.map(
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2222
|
+
for (const pending of plugins.map(
|
|
2223
|
+
(plugin) => {
|
|
2224
|
+
var _a;
|
|
2225
|
+
return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2226
|
+
}
|
|
2227
|
+
)) {
|
|
2047
2228
|
const cur = await pending;
|
|
2048
2229
|
if (cancel.isCancellationRequested)
|
|
2049
2230
|
return;
|
|
@@ -2058,10 +2239,12 @@ var service = {
|
|
|
2058
2239
|
async findDocumentSymbols(doc, params, cancel) {
|
|
2059
2240
|
let result;
|
|
2060
2241
|
try {
|
|
2061
|
-
for (const pending of plugins.map(
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2242
|
+
for (const pending of plugins.map(
|
|
2243
|
+
(plugin) => {
|
|
2244
|
+
var _a;
|
|
2245
|
+
return (_a = plugin.findDocumentSymbols) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2246
|
+
}
|
|
2247
|
+
)) {
|
|
2065
2248
|
const cur = await pending;
|
|
2066
2249
|
if (cancel.isCancellationRequested)
|
|
2067
2250
|
return;
|
|
@@ -2076,10 +2259,12 @@ var service = {
|
|
|
2076
2259
|
async findDocumentLinks(doc, params, cancel) {
|
|
2077
2260
|
let result;
|
|
2078
2261
|
try {
|
|
2079
|
-
for (const pending of plugins.map(
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2262
|
+
for (const pending of plugins.map(
|
|
2263
|
+
(plugin) => {
|
|
2264
|
+
var _a;
|
|
2265
|
+
return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2266
|
+
}
|
|
2267
|
+
)) {
|
|
2083
2268
|
const cur = await pending;
|
|
2084
2269
|
if (cancel.isCancellationRequested)
|
|
2085
2270
|
return;
|
|
@@ -2094,10 +2279,12 @@ var service = {
|
|
|
2094
2279
|
async findDocumentHighlights(doc, params, cancel) {
|
|
2095
2280
|
let result;
|
|
2096
2281
|
try {
|
|
2097
|
-
for (const pending of plugins.map(
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2282
|
+
for (const pending of plugins.map(
|
|
2283
|
+
(plugin) => {
|
|
2284
|
+
var _a;
|
|
2285
|
+
return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2286
|
+
}
|
|
2287
|
+
)) {
|
|
2101
2288
|
const cur = await pending;
|
|
2102
2289
|
if (cancel.isCancellationRequested)
|
|
2103
2290
|
return;
|
|
@@ -2112,10 +2299,12 @@ var service = {
|
|
|
2112
2299
|
async findDocumentColors(doc, params, cancel) {
|
|
2113
2300
|
let result;
|
|
2114
2301
|
try {
|
|
2115
|
-
for (const pending of plugins.map(
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2302
|
+
for (const pending of plugins.map(
|
|
2303
|
+
(plugin) => {
|
|
2304
|
+
var _a;
|
|
2305
|
+
return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2306
|
+
}
|
|
2307
|
+
)) {
|
|
2119
2308
|
const cur = await pending;
|
|
2120
2309
|
if (cancel.isCancellationRequested)
|
|
2121
2310
|
return;
|
|
@@ -2130,10 +2319,12 @@ var service = {
|
|
|
2130
2319
|
async getColorPresentations(doc, params, cancel) {
|
|
2131
2320
|
let result;
|
|
2132
2321
|
try {
|
|
2133
|
-
for (const pending of plugins.map(
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2322
|
+
for (const pending of plugins.map(
|
|
2323
|
+
(plugin) => {
|
|
2324
|
+
var _a;
|
|
2325
|
+
return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2326
|
+
}
|
|
2327
|
+
)) {
|
|
2137
2328
|
const cur = await pending;
|
|
2138
2329
|
if (cancel.isCancellationRequested)
|
|
2139
2330
|
return;
|
|
@@ -2164,10 +2355,12 @@ var service = {
|
|
|
2164
2355
|
let changeAnnotations;
|
|
2165
2356
|
let documentChanges;
|
|
2166
2357
|
try {
|
|
2167
|
-
for (const pending of plugins.map(
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2358
|
+
for (const pending of plugins.map(
|
|
2359
|
+
(plugin) => {
|
|
2360
|
+
var _a;
|
|
2361
|
+
return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2362
|
+
}
|
|
2363
|
+
)) {
|
|
2171
2364
|
const cur = await pending;
|
|
2172
2365
|
if (cancel.isCancellationRequested)
|
|
2173
2366
|
return;
|
|
@@ -2207,10 +2400,12 @@ var service = {
|
|
|
2207
2400
|
async doCodeActions(doc, params, cancel) {
|
|
2208
2401
|
let result;
|
|
2209
2402
|
try {
|
|
2210
|
-
for (const pending of plugins.map(
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2403
|
+
for (const pending of plugins.map(
|
|
2404
|
+
(plugin) => {
|
|
2405
|
+
var _a;
|
|
2406
|
+
return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2407
|
+
}
|
|
2408
|
+
)) {
|
|
2214
2409
|
const cur = await pending;
|
|
2215
2410
|
if (cancel.isCancellationRequested)
|
|
2216
2411
|
return;
|
|
@@ -2308,40 +2503,88 @@ documents.onDidChangeContent(({ document }) => {
|
|
|
2308
2503
|
clearCompilerCache(document);
|
|
2309
2504
|
});
|
|
2310
2505
|
connection2.onCompletion(async (params, cancel) => {
|
|
2311
|
-
return await service.doComplete(
|
|
2506
|
+
return await service.doComplete(
|
|
2507
|
+
documents.get(params.textDocument.uri),
|
|
2508
|
+
params,
|
|
2509
|
+
cancel
|
|
2510
|
+
) || null;
|
|
2312
2511
|
});
|
|
2313
2512
|
connection2.onDefinition(async (params, cancel) => {
|
|
2314
|
-
return await service.findDefinition(
|
|
2513
|
+
return await service.findDefinition(
|
|
2514
|
+
documents.get(params.textDocument.uri),
|
|
2515
|
+
params,
|
|
2516
|
+
cancel
|
|
2517
|
+
) || null;
|
|
2315
2518
|
});
|
|
2316
2519
|
connection2.onReferences(async (params, cancel) => {
|
|
2317
|
-
return await service.findReferences(
|
|
2520
|
+
return await service.findReferences(
|
|
2521
|
+
documents.get(params.textDocument.uri),
|
|
2522
|
+
params,
|
|
2523
|
+
cancel
|
|
2524
|
+
) || null;
|
|
2318
2525
|
});
|
|
2319
2526
|
connection2.onDocumentLinks(async (params, cancel) => {
|
|
2320
|
-
return await service.findDocumentLinks(
|
|
2527
|
+
return await service.findDocumentLinks(
|
|
2528
|
+
documents.get(params.textDocument.uri),
|
|
2529
|
+
params,
|
|
2530
|
+
cancel
|
|
2531
|
+
) || null;
|
|
2321
2532
|
});
|
|
2322
2533
|
connection2.onDocumentSymbol(async (params, cancel) => {
|
|
2323
|
-
return await service.findDocumentSymbols(
|
|
2534
|
+
return await service.findDocumentSymbols(
|
|
2535
|
+
documents.get(params.textDocument.uri),
|
|
2536
|
+
params,
|
|
2537
|
+
cancel
|
|
2538
|
+
) || null;
|
|
2324
2539
|
});
|
|
2325
2540
|
connection2.onDocumentHighlight(async (params, cancel) => {
|
|
2326
|
-
return await service.findDocumentHighlights(
|
|
2541
|
+
return await service.findDocumentHighlights(
|
|
2542
|
+
documents.get(params.textDocument.uri),
|
|
2543
|
+
params,
|
|
2544
|
+
cancel
|
|
2545
|
+
) || null;
|
|
2327
2546
|
});
|
|
2328
2547
|
connection2.onDocumentColor(async (params, cancel) => {
|
|
2329
|
-
return await service.findDocumentColors(
|
|
2548
|
+
return await service.findDocumentColors(
|
|
2549
|
+
documents.get(params.textDocument.uri),
|
|
2550
|
+
params,
|
|
2551
|
+
cancel
|
|
2552
|
+
) || null;
|
|
2330
2553
|
});
|
|
2331
2554
|
connection2.onColorPresentation(async (params, cancel) => {
|
|
2332
|
-
return await service.getColorPresentations(
|
|
2555
|
+
return await service.getColorPresentations(
|
|
2556
|
+
documents.get(params.textDocument.uri),
|
|
2557
|
+
params,
|
|
2558
|
+
cancel
|
|
2559
|
+
) || null;
|
|
2333
2560
|
});
|
|
2334
2561
|
connection2.onHover(async (params, cancel) => {
|
|
2335
|
-
return await service.doHover(
|
|
2562
|
+
return await service.doHover(
|
|
2563
|
+
documents.get(params.textDocument.uri),
|
|
2564
|
+
params,
|
|
2565
|
+
cancel
|
|
2566
|
+
) || null;
|
|
2336
2567
|
});
|
|
2337
2568
|
connection2.onRenameRequest(async (params, cancel) => {
|
|
2338
|
-
return await service.doRename(
|
|
2569
|
+
return await service.doRename(
|
|
2570
|
+
documents.get(params.textDocument.uri),
|
|
2571
|
+
params,
|
|
2572
|
+
cancel
|
|
2573
|
+
) || null;
|
|
2339
2574
|
});
|
|
2340
2575
|
connection2.onCodeAction(async (params, cancel) => {
|
|
2341
|
-
return await service.doCodeActions(
|
|
2576
|
+
return await service.doCodeActions(
|
|
2577
|
+
documents.get(params.textDocument.uri),
|
|
2578
|
+
params,
|
|
2579
|
+
cancel
|
|
2580
|
+
) || null;
|
|
2342
2581
|
});
|
|
2343
2582
|
connection2.onDocumentFormatting(async (params, cancel) => {
|
|
2344
|
-
return await service.format(
|
|
2583
|
+
return await service.format(
|
|
2584
|
+
documents.get(params.textDocument.uri),
|
|
2585
|
+
params,
|
|
2586
|
+
cancel
|
|
2587
|
+
) || null;
|
|
2345
2588
|
});
|
|
2346
2589
|
function validateDocs() {
|
|
2347
2590
|
queueDiagnostic();
|
|
@@ -2353,15 +2596,17 @@ function validateDocs() {
|
|
|
2353
2596
|
function queueDiagnostic() {
|
|
2354
2597
|
clearTimeout(diagnosticTimeout);
|
|
2355
2598
|
const id = diagnosticTimeout = setTimeout(async () => {
|
|
2356
|
-
const results = await Promise.all(
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2599
|
+
const results = await Promise.all(
|
|
2600
|
+
documents.all().map(async (doc) => {
|
|
2601
|
+
if (!pendingDiags.delete(doc))
|
|
2602
|
+
return;
|
|
2603
|
+
const prevDiag = prevDiags.get(doc) || [];
|
|
2604
|
+
const nextDiag = await service.doValidate(doc) || [];
|
|
2605
|
+
if ((0, import_util2.isDeepStrictEqual)(prevDiag, nextDiag))
|
|
2606
|
+
return;
|
|
2607
|
+
return [doc, nextDiag];
|
|
2608
|
+
})
|
|
2609
|
+
);
|
|
2365
2610
|
if (id === diagnosticTimeout) {
|
|
2366
2611
|
for (const result of results) {
|
|
2367
2612
|
if (result) {
|