@marko/language-server 0.12.11 → 0.12.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.
- package/dist/index.js +208 -178
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +188 -157
- package/dist/index.mjs.map +3 -3
- package/dist/service/marko/complete/Statement.d.ts +3 -0
- package/dist/service/marko/util/get-tag-name-completion.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -625,10 +625,10 @@ function display(type, data) {
|
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
// src/service/index.ts
|
|
628
|
-
var
|
|
628
|
+
var import_vscode_languageserver14 = require("vscode-languageserver");
|
|
629
629
|
|
|
630
630
|
// src/service/marko/complete/index.ts
|
|
631
|
-
var
|
|
631
|
+
var import_vscode_languageserver6 = require("vscode-languageserver");
|
|
632
632
|
|
|
633
633
|
// src/service/marko/complete/Tag.ts
|
|
634
634
|
var import_vscode_languageserver = require("vscode-languageserver");
|
|
@@ -670,71 +670,107 @@ ${closingTagStr}`
|
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
// src/service/marko/
|
|
673
|
+
// src/service/marko/util/get-tag-name-completion.ts
|
|
674
674
|
var import_path2 = __toESM(require("path"));
|
|
675
|
-
var import_vscode_uri2 = require("vscode-uri");
|
|
676
675
|
var import_vscode_languageserver2 = require("vscode-languageserver");
|
|
676
|
+
var import_vscode_uri2 = require("vscode-uri");
|
|
677
|
+
var deprecated = [import_vscode_languageserver2.CompletionItemTag.Deprecated];
|
|
678
|
+
function getTagNameCompletion({
|
|
679
|
+
tag,
|
|
680
|
+
range,
|
|
681
|
+
showAutoComplete,
|
|
682
|
+
importer
|
|
683
|
+
}) {
|
|
684
|
+
var _a;
|
|
685
|
+
let label = tag.isNestedTag ? `@${tag.name}` : tag.name;
|
|
686
|
+
const fileForTag = tag.template || tag.renderer || tag.filePath;
|
|
687
|
+
const fileURIForTag = import_vscode_uri2.URI.file(fileForTag).toString();
|
|
688
|
+
const nodeModuleMatch = /\/node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(fileForTag);
|
|
689
|
+
const nodeModuleName = nodeModuleMatch && nodeModuleMatch[1];
|
|
690
|
+
const isCoreTag = nodeModuleName === "marko";
|
|
691
|
+
const documentation = {
|
|
692
|
+
kind: import_vscode_languageserver2.MarkupKind.Markdown,
|
|
693
|
+
value: tag.html ? `Built in [<${tag.name}>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${tag.name}) HTML tag.` : nodeModuleName ? isCoreTag ? `Core Marko [<${tag.name}>](${fileURIForTag}) tag.` : `Custom Marko tag discovered from the ["${nodeModuleName}"](${fileURIForTag}) npm package.` : `Custom Marko tag discovered from:
|
|
694
|
+
|
|
695
|
+
[${importer ? import_path2.default.relative(importer, fileForTag) : fileForTag}](${fileURIForTag})`
|
|
696
|
+
};
|
|
697
|
+
if (tag.description) {
|
|
698
|
+
documentation.value += `
|
|
699
|
+
|
|
700
|
+
${tag.description}`;
|
|
701
|
+
}
|
|
702
|
+
const autocomplete = showAutoComplete ? (_a = tag.autocomplete) == null ? void 0 : _a[0] : void 0;
|
|
703
|
+
if (autocomplete) {
|
|
704
|
+
if (autocomplete.displayText) {
|
|
705
|
+
label = autocomplete.displayText;
|
|
706
|
+
}
|
|
707
|
+
if (autocomplete.description) {
|
|
708
|
+
documentation.value += `
|
|
709
|
+
|
|
710
|
+
${autocomplete.description}`;
|
|
711
|
+
}
|
|
712
|
+
if (autocomplete.descriptionMoreURL) {
|
|
713
|
+
documentation.value += `
|
|
714
|
+
|
|
715
|
+
[More Info](${autocomplete.descriptionMoreURL})`;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
label,
|
|
720
|
+
documentation,
|
|
721
|
+
tags: tag.deprecated ? deprecated : void 0,
|
|
722
|
+
insertTextFormat: autocomplete ? import_vscode_languageserver2.InsertTextFormat.Snippet : void 0,
|
|
723
|
+
kind: tag.html ? import_vscode_languageserver2.CompletionItemKind.Property : import_vscode_languageserver2.CompletionItemKind.Class,
|
|
724
|
+
textEdit: range && import_vscode_languageserver2.TextEdit.replace(range, (autocomplete == null ? void 0 : autocomplete.snippet) || label)
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/service/marko/complete/OpenTagName.ts
|
|
677
729
|
function OpenTagName({
|
|
678
730
|
document,
|
|
679
731
|
lookup,
|
|
680
732
|
parsed,
|
|
681
733
|
node
|
|
682
734
|
}) {
|
|
683
|
-
|
|
735
|
+
var _a;
|
|
736
|
+
const importer = getDocFile(document);
|
|
684
737
|
const tag = node.parent;
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
738
|
+
const range = parsed.locationAt(node);
|
|
739
|
+
const isAttrTag = tag.type === 14 /* AttrTag */;
|
|
740
|
+
const result = [];
|
|
741
|
+
if (isAttrTag) {
|
|
688
742
|
let parentTag = tag.owner;
|
|
689
743
|
while ((parentTag == null ? void 0 : parentTag.type) === 14 /* AttrTag */)
|
|
690
744
|
parentTag = parentTag.owner;
|
|
691
745
|
const parentTagDef = parentTag && parentTag.nameText && lookup.getTag(parentTag.nameText);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
kind: import_vscode_languageserver2.MarkupKind.Markdown,
|
|
705
|
-
value: it.html ? `Built in [<${it.name}>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${it.name}) HTML tag.` : nodeModuleName ? isCoreTag ? `Core Marko [<${it.name}>](${fileURIForTag}) tag.` : `Custom Marko tag discovered from the ["${nodeModuleName}"](${fileURIForTag}) npm package.` : `Custom Marko tag discovered from:
|
|
706
|
-
|
|
707
|
-
[${currentTemplateFilePath ? import_path2.default.relative(currentTemplateFilePath, fileForTag) : currentTemplateFilePath}](${fileURIForTag})`
|
|
708
|
-
};
|
|
709
|
-
if (it.description) {
|
|
710
|
-
documentation.value += `
|
|
711
|
-
|
|
712
|
-
${it.description}`;
|
|
713
|
-
}
|
|
714
|
-
const autocomplete = it.autocomplete && it.autocomplete[0];
|
|
715
|
-
if (autocomplete) {
|
|
716
|
-
if (autocomplete.displayText) {
|
|
717
|
-
label = autocomplete.displayText;
|
|
718
|
-
}
|
|
719
|
-
if (autocomplete.description) {
|
|
720
|
-
documentation.value += `
|
|
721
|
-
|
|
722
|
-
${autocomplete.description}`;
|
|
746
|
+
if (parentTagDef) {
|
|
747
|
+
const { nestedTags } = parentTagDef;
|
|
748
|
+
for (const key in nestedTags) {
|
|
749
|
+
if (key !== "*") {
|
|
750
|
+
const tag2 = nestedTags[key];
|
|
751
|
+
result.push(getTagNameCompletion({
|
|
752
|
+
tag: tag2,
|
|
753
|
+
range,
|
|
754
|
+
importer,
|
|
755
|
+
showAutoComplete: true
|
|
756
|
+
}));
|
|
757
|
+
}
|
|
723
758
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
759
|
+
}
|
|
760
|
+
} else {
|
|
761
|
+
const skipStatements = !(tag.concise && tag.parent.type === 0 /* Program */);
|
|
762
|
+
for (const tag2 of lookup.getTagsSorted()) {
|
|
763
|
+
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(getTagNameCompletion({
|
|
765
|
+
tag: tag2,
|
|
766
|
+
range,
|
|
767
|
+
importer,
|
|
768
|
+
showAutoComplete: true
|
|
769
|
+
}));
|
|
728
770
|
}
|
|
729
771
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
documentation,
|
|
733
|
-
kind: import_vscode_languageserver2.CompletionItemKind.Class,
|
|
734
|
-
insertTextFormat: import_vscode_languageserver2.InsertTextFormat.Snippet,
|
|
735
|
-
textEdit: import_vscode_languageserver2.TextEdit.replace(tagNameLocation, autocomplete && autocomplete.snippet || label)
|
|
736
|
-
};
|
|
737
|
-
});
|
|
772
|
+
}
|
|
773
|
+
return result;
|
|
738
774
|
}
|
|
739
775
|
|
|
740
776
|
// src/service/marko/complete/AttrName.ts
|
|
@@ -973,19 +1009,59 @@ async function AttrValue({
|
|
|
973
1009
|
}
|
|
974
1010
|
}
|
|
975
1011
|
|
|
1012
|
+
// src/service/marko/complete/Statement.ts
|
|
1013
|
+
var import_vscode_languageserver5 = require("vscode-languageserver");
|
|
1014
|
+
var importTagReg = /(['"])<((?:[^\1\\>]+|\\.)*)>?\1/g;
|
|
1015
|
+
function Statement({
|
|
1016
|
+
code,
|
|
1017
|
+
node,
|
|
1018
|
+
parsed,
|
|
1019
|
+
lookup,
|
|
1020
|
+
document
|
|
1021
|
+
}) {
|
|
1022
|
+
var _a;
|
|
1023
|
+
if (code[node.start] === "i") {
|
|
1024
|
+
importTagReg.lastIndex = 0;
|
|
1025
|
+
const value = parsed.read(node);
|
|
1026
|
+
const match = importTagReg.exec(value);
|
|
1027
|
+
if (match) {
|
|
1028
|
+
const importer = getDocFile(document);
|
|
1029
|
+
const [{ length }] = match;
|
|
1030
|
+
const range = parsed.locationAt({
|
|
1031
|
+
start: node.start + match.index + 1,
|
|
1032
|
+
end: node.start + match.index + length - 1
|
|
1033
|
+
});
|
|
1034
|
+
const result = [];
|
|
1035
|
+
for (const tag of lookup.getTagsSorted()) {
|
|
1036
|
+
if ((tag.template || tag.renderer) && !(tag.html || tag.parser || tag.translator || tag.isNestedTag || tag.name === "*" || ((_a = tag.parseOptions) == null ? void 0 : _a.statement) || /^@?marko[/-]/.test(tag.taglibId) || tag.name[0] === "_" && /[\\/]node_modules[\\/]/.test(tag.filePath))) {
|
|
1037
|
+
const completion = getTagNameCompletion({
|
|
1038
|
+
tag,
|
|
1039
|
+
importer
|
|
1040
|
+
});
|
|
1041
|
+
completion.label = `<${completion.label}>`;
|
|
1042
|
+
completion.textEdit = import_vscode_languageserver5.TextEdit.replace(range, completion.label);
|
|
1043
|
+
result.push(completion);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return result;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
976
1051
|
// src/service/marko/complete/index.ts
|
|
977
1052
|
var handlers = {
|
|
978
1053
|
Tag,
|
|
979
1054
|
OpenTagName,
|
|
980
1055
|
AttrName,
|
|
981
|
-
AttrValue
|
|
1056
|
+
AttrValue,
|
|
1057
|
+
Statement
|
|
982
1058
|
};
|
|
983
1059
|
var doComplete = async (doc, params) => {
|
|
984
1060
|
var _a;
|
|
985
1061
|
const parsed = parse2(doc);
|
|
986
1062
|
const offset = doc.offsetAt(params.position);
|
|
987
1063
|
const node = parsed.nodeAt(offset);
|
|
988
|
-
return
|
|
1064
|
+
return import_vscode_languageserver6.CompletionList.create(await ((_a = handlers[NodeType[node.type]]) == null ? void 0 : _a.call(handlers, {
|
|
989
1065
|
document: doc,
|
|
990
1066
|
params,
|
|
991
1067
|
parsed,
|
|
@@ -997,7 +1073,7 @@ var doComplete = async (doc, params) => {
|
|
|
997
1073
|
};
|
|
998
1074
|
|
|
999
1075
|
// src/service/marko/validate.ts
|
|
1000
|
-
var
|
|
1076
|
+
var import_vscode_languageserver7 = require("vscode-languageserver");
|
|
1001
1077
|
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
1002
1078
|
var doValidate = (doc) => {
|
|
1003
1079
|
const fsPath = getDocFile(doc);
|
|
@@ -1017,7 +1093,7 @@ var doValidate = (doc) => {
|
|
|
1017
1093
|
const [, fileName, rawLine, rawCol, msg] = match;
|
|
1018
1094
|
const line = (parseInt(rawLine, 10) || 1) - 1;
|
|
1019
1095
|
const col = (parseInt(rawCol, 10) || 1) - 1;
|
|
1020
|
-
diagnostics.push(
|
|
1096
|
+
diagnostics.push(import_vscode_languageserver7.Diagnostic.create(import_vscode_languageserver7.Range.create(line, col, line, col), msg, import_vscode_languageserver7.DiagnosticSeverity.Error, void 0, fileName));
|
|
1021
1097
|
}
|
|
1022
1098
|
}
|
|
1023
1099
|
return diagnostics;
|
|
@@ -1026,7 +1102,7 @@ var doValidate = (doc) => {
|
|
|
1026
1102
|
// src/service/marko/definition/OpenTagName.ts
|
|
1027
1103
|
var import_path4 = __toESM(require("path"));
|
|
1028
1104
|
var import_vscode_uri4 = require("vscode-uri");
|
|
1029
|
-
var
|
|
1105
|
+
var import_vscode_languageserver9 = require("vscode-languageserver");
|
|
1030
1106
|
|
|
1031
1107
|
// src/utils/regexp-builder.ts
|
|
1032
1108
|
function RegExpBuilder(strings, ...expressions) {
|
|
@@ -1055,9 +1131,9 @@ function escape(val) {
|
|
|
1055
1131
|
// src/utils/utils.ts
|
|
1056
1132
|
var import_fs = __toESM(require("fs"));
|
|
1057
1133
|
var import_vscode_uri3 = require("vscode-uri");
|
|
1058
|
-
var
|
|
1134
|
+
var import_vscode_languageserver8 = require("vscode-languageserver");
|
|
1059
1135
|
var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
|
|
1060
|
-
var START_OF_FILE =
|
|
1136
|
+
var START_OF_FILE = import_vscode_languageserver8.Range.create(import_vscode_languageserver8.Position.create(0, 0), import_vscode_languageserver8.Position.create(0, 0));
|
|
1061
1137
|
function createTextDocument(filename) {
|
|
1062
1138
|
const uri = import_vscode_uri3.URI.file(filename).toString();
|
|
1063
1139
|
const content = import_fs.default.readFileSync(filename, "utf-8");
|
|
@@ -1092,17 +1168,17 @@ function OpenTagName2({
|
|
|
1092
1168
|
const tagDefDoc = createTextDocument(tagEntryFile);
|
|
1093
1169
|
const match = RegExpBuilder`/"(?:<${tag.nameText}>|${tag.nameText})"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
|
|
1094
1170
|
if (match && match.index) {
|
|
1095
|
-
range =
|
|
1171
|
+
range = import_vscode_languageserver9.Range.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
|
|
1096
1172
|
}
|
|
1097
1173
|
}
|
|
1098
1174
|
return [
|
|
1099
|
-
|
|
1175
|
+
import_vscode_languageserver9.LocationLink.create(import_vscode_uri4.URI.file(tagEntryFile).toString(), range, range, parsed.locationAt(node))
|
|
1100
1176
|
];
|
|
1101
1177
|
}
|
|
1102
1178
|
|
|
1103
1179
|
// src/service/marko/definition/AttrName.ts
|
|
1104
1180
|
var import_vscode_uri5 = require("vscode-uri");
|
|
1105
|
-
var
|
|
1181
|
+
var import_vscode_languageserver10 = require("vscode-languageserver");
|
|
1106
1182
|
function AttrName2({
|
|
1107
1183
|
lookup,
|
|
1108
1184
|
parsed,
|
|
@@ -1126,11 +1202,11 @@ function AttrName2({
|
|
|
1126
1202
|
const tagDefDoc = createTextDocument(attrEntryFile);
|
|
1127
1203
|
const match = RegExpBuilder`/"@${attrName}"\s*:\s*[^\r\n,]+/g`.exec(tagDefDoc.getText());
|
|
1128
1204
|
if (match && match.index) {
|
|
1129
|
-
range =
|
|
1205
|
+
range = import_vscode_languageserver10.Range.create(tagDefDoc.positionAt(match.index), tagDefDoc.positionAt(match.index + match[0].length));
|
|
1130
1206
|
}
|
|
1131
1207
|
}
|
|
1132
1208
|
return [
|
|
1133
|
-
|
|
1209
|
+
import_vscode_languageserver10.LocationLink.create(import_vscode_uri5.URI.file(attrEntryFile).toString(), range, range, parsed.locationAt(node))
|
|
1134
1210
|
];
|
|
1135
1211
|
}
|
|
1136
1212
|
|
|
@@ -1156,9 +1232,9 @@ var findDefinition = async (doc, params) => {
|
|
|
1156
1232
|
};
|
|
1157
1233
|
|
|
1158
1234
|
// src/service/marko/document-links/extract.ts
|
|
1159
|
-
var
|
|
1235
|
+
var import_vscode_languageserver11 = require("vscode-languageserver");
|
|
1160
1236
|
var import_vscode_uri6 = require("vscode-uri");
|
|
1161
|
-
var
|
|
1237
|
+
var importTagReg2 = /(['"])<((?:[^\1\\>]+|\\.)*)>?\1/g;
|
|
1162
1238
|
function extractDocumentLinks(doc, parsed, lookup) {
|
|
1163
1239
|
if (import_vscode_uri6.URI.parse(doc.uri).scheme === "untitled") {
|
|
1164
1240
|
return [];
|
|
@@ -1173,7 +1249,7 @@ function extractDocumentLinks(doc, parsed, lookup) {
|
|
|
1173
1249
|
if (node.attrs && node.nameText) {
|
|
1174
1250
|
for (const attr of node.attrs) {
|
|
1175
1251
|
if (isDocumentLinkAttr(doc, node, attr)) {
|
|
1176
|
-
links.push(
|
|
1252
|
+
links.push(import_vscode_languageserver11.DocumentLink.create({
|
|
1177
1253
|
start: parsed.positionAt(attr.value.value.start),
|
|
1178
1254
|
end: parsed.positionAt(attr.value.value.end)
|
|
1179
1255
|
}, resolveUrl(read(attr.value.value).slice(1, -1), doc.uri)));
|
|
@@ -1190,15 +1266,15 @@ function extractDocumentLinks(doc, parsed, lookup) {
|
|
|
1190
1266
|
};
|
|
1191
1267
|
for (const item of program.static) {
|
|
1192
1268
|
if (item.type === 20 /* Statement */ && code[item.start] === "i") {
|
|
1193
|
-
|
|
1269
|
+
importTagReg2.lastIndex = 0;
|
|
1194
1270
|
const value = parsed.read(item);
|
|
1195
|
-
const match =
|
|
1271
|
+
const match = importTagReg2.exec(value);
|
|
1196
1272
|
if (match) {
|
|
1197
1273
|
const [{ length }, , tagName] = match;
|
|
1198
1274
|
const tagDef = lookup.getTag(tagName);
|
|
1199
1275
|
const fileForTag = tagDef && (tagDef.template || tagDef.renderer);
|
|
1200
1276
|
if (fileForTag) {
|
|
1201
|
-
links.push(
|
|
1277
|
+
links.push(import_vscode_languageserver11.DocumentLink.create({
|
|
1202
1278
|
start: parsed.positionAt(item.start + match.index),
|
|
1203
1279
|
end: parsed.positionAt(item.start + match.index + length)
|
|
1204
1280
|
}, fileForTag));
|
|
@@ -1225,7 +1301,7 @@ var findDocumentLinks = async (doc) => {
|
|
|
1225
1301
|
};
|
|
1226
1302
|
|
|
1227
1303
|
// src/service/marko/format.ts
|
|
1228
|
-
var
|
|
1304
|
+
var import_vscode_languageserver12 = require("vscode-languageserver");
|
|
1229
1305
|
var import_vscode_uri7 = require("vscode-uri");
|
|
1230
1306
|
var prettier = __toESM(require("prettier"));
|
|
1231
1307
|
var markoPrettier = __toESM(require("prettier-plugin-marko"));
|
|
@@ -1246,7 +1322,7 @@ var format2 = async (doc, params, cancel) => {
|
|
|
1246
1322
|
if (cancel.isCancellationRequested)
|
|
1247
1323
|
return;
|
|
1248
1324
|
return [
|
|
1249
|
-
|
|
1325
|
+
import_vscode_languageserver12.TextEdit.replace(import_vscode_languageserver12.Range.create(doc.positionAt(0), doc.positionAt(text.length)), prettier.format(text, options))
|
|
1250
1326
|
];
|
|
1251
1327
|
} catch (e) {
|
|
1252
1328
|
displayError(e);
|
|
@@ -1263,7 +1339,7 @@ var marko_default = {
|
|
|
1263
1339
|
};
|
|
1264
1340
|
|
|
1265
1341
|
// src/service/stylesheet/index.ts
|
|
1266
|
-
var
|
|
1342
|
+
var import_vscode_languageserver13 = require("vscode-languageserver");
|
|
1267
1343
|
var import_vscode_css_languageservice2 = require("vscode-css-languageservice");
|
|
1268
1344
|
var import_vscode_languageserver_textdocument2 = require("vscode-languageserver-textdocument");
|
|
1269
1345
|
|
|
@@ -1467,7 +1543,7 @@ var StyleSheetService = {
|
|
|
1467
1543
|
}
|
|
1468
1544
|
return result;
|
|
1469
1545
|
}
|
|
1470
|
-
return
|
|
1546
|
+
return import_vscode_languageserver13.CompletionList.create([], true);
|
|
1471
1547
|
},
|
|
1472
1548
|
findDefinition(doc, params) {
|
|
1473
1549
|
const infoByExt = getStyleSheetInfo(doc);
|
|
@@ -1586,7 +1662,7 @@ var StyleSheetService = {
|
|
|
1586
1662
|
continue;
|
|
1587
1663
|
const { service: service2, virtualDoc } = info;
|
|
1588
1664
|
const result = [];
|
|
1589
|
-
for (const colorPresentation of service2.getColorPresentations(virtualDoc, info.parsed, params.color,
|
|
1665
|
+
for (const colorPresentation of service2.getColorPresentations(virtualDoc, info.parsed, params.color, import_vscode_languageserver13.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)))) {
|
|
1590
1666
|
const textEdit = colorPresentation.textEdit && getSourceEdit(doc, info, colorPresentation.textEdit);
|
|
1591
1667
|
const additionalTextEdits = colorPresentation.additionalTextEdits && getSourceEdits(doc, info, colorPresentation.additionalTextEdits);
|
|
1592
1668
|
if (textEdit || additionalTextEdits) {
|
|
@@ -1644,7 +1720,7 @@ var StyleSheetService = {
|
|
|
1644
1720
|
}
|
|
1645
1721
|
if (result.documentChanges) {
|
|
1646
1722
|
for (const change of result.documentChanges) {
|
|
1647
|
-
if (
|
|
1723
|
+
if (import_vscode_languageserver13.TextDocumentEdit.is(change)) {
|
|
1648
1724
|
if (change.textDocument.uri === doc.uri) {
|
|
1649
1725
|
change.edits = getSourceEdits(doc, info, change.edits) || [];
|
|
1650
1726
|
}
|
|
@@ -1667,7 +1743,7 @@ var StyleSheetService = {
|
|
|
1667
1743
|
if (generatedOffsetEnd === void 0)
|
|
1668
1744
|
continue;
|
|
1669
1745
|
const { service: service2, virtualDoc } = info;
|
|
1670
|
-
const result = service2.doCodeActions(virtualDoc,
|
|
1746
|
+
const result = service2.doCodeActions(virtualDoc, import_vscode_languageserver13.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)), params.context, info.parsed);
|
|
1671
1747
|
for (const command of result) {
|
|
1672
1748
|
const edits = (_a = command.arguments) == null ? void 0 : _a[2];
|
|
1673
1749
|
if (edits && Array.isArray(edits) && isTextEdit(edits[0])) {
|
|
@@ -1791,51 +1867,47 @@ var service = {
|
|
|
1791
1867
|
}));
|
|
1792
1868
|
},
|
|
1793
1869
|
async doComplete(doc, params, cancel) {
|
|
1794
|
-
|
|
1870
|
+
let items;
|
|
1871
|
+
let isIncomplete = false;
|
|
1795
1872
|
try {
|
|
1796
|
-
const
|
|
1873
|
+
for (const pending of plugins.map((plugin) => {
|
|
1797
1874
|
var _a;
|
|
1798
1875
|
return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1799
|
-
})
|
|
1800
|
-
for (const pending of requests) {
|
|
1876
|
+
})) {
|
|
1801
1877
|
const cur = await pending;
|
|
1802
1878
|
if (cancel.isCancellationRequested)
|
|
1803
1879
|
return;
|
|
1804
1880
|
if (cur) {
|
|
1805
|
-
let
|
|
1881
|
+
let curItems;
|
|
1806
1882
|
if (Array.isArray(cur)) {
|
|
1807
|
-
|
|
1883
|
+
curItems = cur;
|
|
1808
1884
|
} else {
|
|
1809
|
-
|
|
1810
|
-
|
|
1885
|
+
curItems = cur.items;
|
|
1886
|
+
isIncomplete || (isIncomplete = cur.isIncomplete);
|
|
1811
1887
|
}
|
|
1812
|
-
|
|
1888
|
+
items = items ? items.concat(curItems) : curItems;
|
|
1813
1889
|
}
|
|
1814
1890
|
}
|
|
1815
1891
|
} catch (err) {
|
|
1816
|
-
|
|
1892
|
+
isIncomplete = true;
|
|
1817
1893
|
displayError(err);
|
|
1818
1894
|
}
|
|
1819
|
-
|
|
1895
|
+
if (items) {
|
|
1896
|
+
return import_vscode_languageserver14.CompletionList.create(items, isIncomplete);
|
|
1897
|
+
}
|
|
1820
1898
|
},
|
|
1821
1899
|
async findDefinition(doc, params, cancel) {
|
|
1822
|
-
|
|
1900
|
+
let result;
|
|
1823
1901
|
try {
|
|
1824
|
-
const
|
|
1902
|
+
for (const pending of plugins.map((plugin) => {
|
|
1825
1903
|
var _a;
|
|
1826
1904
|
return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1827
|
-
})
|
|
1828
|
-
for (const pending of requests) {
|
|
1905
|
+
})) {
|
|
1829
1906
|
const cur = await pending;
|
|
1830
1907
|
if (cancel.isCancellationRequested)
|
|
1831
1908
|
return;
|
|
1832
|
-
if (cur)
|
|
1833
|
-
|
|
1834
|
-
result.push(...cur);
|
|
1835
|
-
} else {
|
|
1836
|
-
result.push(cur);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1909
|
+
if (cur)
|
|
1910
|
+
result = (result || []).concat(cur);
|
|
1839
1911
|
}
|
|
1840
1912
|
} catch (err) {
|
|
1841
1913
|
displayError(err);
|
|
@@ -1845,21 +1917,15 @@ var service = {
|
|
|
1845
1917
|
async findReferences(doc, params, cancel) {
|
|
1846
1918
|
let result;
|
|
1847
1919
|
try {
|
|
1848
|
-
const
|
|
1920
|
+
for (const pending of plugins.map((plugin) => {
|
|
1849
1921
|
var _a;
|
|
1850
1922
|
return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1851
|
-
})
|
|
1852
|
-
for (const pending of requests) {
|
|
1923
|
+
})) {
|
|
1853
1924
|
const cur = await pending;
|
|
1854
1925
|
if (cancel.isCancellationRequested)
|
|
1855
1926
|
return;
|
|
1856
|
-
if (cur)
|
|
1857
|
-
|
|
1858
|
-
result.push(...cur);
|
|
1859
|
-
} else {
|
|
1860
|
-
result = cur;
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1927
|
+
if (cur)
|
|
1928
|
+
result = result ? result.concat(cur) : cur;
|
|
1863
1929
|
}
|
|
1864
1930
|
} catch (err) {
|
|
1865
1931
|
displayError(err);
|
|
@@ -1869,21 +1935,15 @@ var service = {
|
|
|
1869
1935
|
async findDocumentLinks(doc, params, cancel) {
|
|
1870
1936
|
let result;
|
|
1871
1937
|
try {
|
|
1872
|
-
const
|
|
1938
|
+
for (const pending of plugins.map((plugin) => {
|
|
1873
1939
|
var _a;
|
|
1874
1940
|
return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1875
|
-
})
|
|
1876
|
-
for (const pending of requests) {
|
|
1941
|
+
})) {
|
|
1877
1942
|
const cur = await pending;
|
|
1878
1943
|
if (cancel.isCancellationRequested)
|
|
1879
1944
|
return;
|
|
1880
|
-
if (cur)
|
|
1881
|
-
|
|
1882
|
-
result.push(...cur);
|
|
1883
|
-
} else {
|
|
1884
|
-
result = cur;
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1945
|
+
if (cur)
|
|
1946
|
+
result = result ? result.concat(cur) : cur;
|
|
1887
1947
|
}
|
|
1888
1948
|
} catch (err) {
|
|
1889
1949
|
displayError(err);
|
|
@@ -1893,21 +1953,15 @@ var service = {
|
|
|
1893
1953
|
async findDocumentHighlights(doc, params, cancel) {
|
|
1894
1954
|
let result;
|
|
1895
1955
|
try {
|
|
1896
|
-
const
|
|
1956
|
+
for (const pending of plugins.map((plugin) => {
|
|
1897
1957
|
var _a;
|
|
1898
1958
|
return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1899
|
-
})
|
|
1900
|
-
for (const pending of requests) {
|
|
1959
|
+
})) {
|
|
1901
1960
|
const cur = await pending;
|
|
1902
1961
|
if (cancel.isCancellationRequested)
|
|
1903
1962
|
return;
|
|
1904
|
-
if (cur)
|
|
1905
|
-
|
|
1906
|
-
result.push(...cur);
|
|
1907
|
-
} else {
|
|
1908
|
-
result = cur;
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1963
|
+
if (cur)
|
|
1964
|
+
result = result ? result.concat(cur) : cur;
|
|
1911
1965
|
}
|
|
1912
1966
|
} catch (err) {
|
|
1913
1967
|
displayError(err);
|
|
@@ -1917,21 +1971,15 @@ var service = {
|
|
|
1917
1971
|
async findDocumentColors(doc, params, cancel) {
|
|
1918
1972
|
let result;
|
|
1919
1973
|
try {
|
|
1920
|
-
const
|
|
1974
|
+
for (const pending of plugins.map((plugin) => {
|
|
1921
1975
|
var _a;
|
|
1922
1976
|
return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1923
|
-
})
|
|
1924
|
-
for (const pending of requests) {
|
|
1977
|
+
})) {
|
|
1925
1978
|
const cur = await pending;
|
|
1926
1979
|
if (cancel.isCancellationRequested)
|
|
1927
1980
|
return;
|
|
1928
|
-
if (cur)
|
|
1929
|
-
|
|
1930
|
-
result.push(...cur);
|
|
1931
|
-
} else {
|
|
1932
|
-
result = cur;
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1981
|
+
if (cur)
|
|
1982
|
+
result = result ? result.concat(cur) : cur;
|
|
1935
1983
|
}
|
|
1936
1984
|
} catch (err) {
|
|
1937
1985
|
displayError(err);
|
|
@@ -1941,21 +1989,15 @@ var service = {
|
|
|
1941
1989
|
async getColorPresentations(doc, params, cancel) {
|
|
1942
1990
|
let result;
|
|
1943
1991
|
try {
|
|
1944
|
-
const
|
|
1992
|
+
for (const pending of plugins.map((plugin) => {
|
|
1945
1993
|
var _a;
|
|
1946
1994
|
return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1947
|
-
})
|
|
1948
|
-
for (const pending of requests) {
|
|
1995
|
+
})) {
|
|
1949
1996
|
const cur = await pending;
|
|
1950
1997
|
if (cancel.isCancellationRequested)
|
|
1951
1998
|
return;
|
|
1952
|
-
if (cur)
|
|
1953
|
-
|
|
1954
|
-
result.push(...cur);
|
|
1955
|
-
} else {
|
|
1956
|
-
result = cur;
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1999
|
+
if (cur)
|
|
2000
|
+
result = result ? result.concat(cur) : cur;
|
|
1959
2001
|
}
|
|
1960
2002
|
} catch (err) {
|
|
1961
2003
|
displayError(err);
|
|
@@ -1981,41 +2023,32 @@ var service = {
|
|
|
1981
2023
|
let changeAnnotations;
|
|
1982
2024
|
let documentChanges;
|
|
1983
2025
|
try {
|
|
1984
|
-
const
|
|
2026
|
+
for (const pending of plugins.map((plugin) => {
|
|
1985
2027
|
var _a;
|
|
1986
2028
|
return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1987
|
-
})
|
|
1988
|
-
for (const pending of requests) {
|
|
2029
|
+
})) {
|
|
1989
2030
|
const cur = await pending;
|
|
1990
2031
|
if (cancel.isCancellationRequested)
|
|
1991
2032
|
return;
|
|
1992
2033
|
if (cur) {
|
|
1993
2034
|
if (cur.changes) {
|
|
1994
2035
|
if (changes) {
|
|
2036
|
+
changes = { ...changes };
|
|
1995
2037
|
for (const uri in cur.changes) {
|
|
1996
|
-
|
|
1997
|
-
changes[uri].push(...cur.changes[uri]);
|
|
1998
|
-
} else {
|
|
1999
|
-
changes[uri] = cur.changes[uri];
|
|
2000
|
-
}
|
|
2038
|
+
changes[uri] = changes[uri] ? changes[uri].concat(cur.changes[uri]) : cur.changes[uri];
|
|
2001
2039
|
}
|
|
2002
2040
|
} else {
|
|
2003
2041
|
changes = cur.changes;
|
|
2004
2042
|
}
|
|
2005
2043
|
}
|
|
2006
2044
|
if (cur.changeAnnotations) {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
}
|
|
2045
|
+
changeAnnotations = changeAnnotations ? {
|
|
2046
|
+
...changeAnnotations,
|
|
2047
|
+
...cur.changeAnnotations
|
|
2048
|
+
} : cur.changeAnnotations;
|
|
2012
2049
|
}
|
|
2013
2050
|
if (cur.documentChanges) {
|
|
2014
|
-
|
|
2015
|
-
documentChanges.push(...cur.documentChanges);
|
|
2016
|
-
} else {
|
|
2017
|
-
documentChanges = cur.documentChanges;
|
|
2018
|
-
}
|
|
2051
|
+
documentChanges = documentChanges ? documentChanges.concat(cur.documentChanges) : cur.documentChanges;
|
|
2019
2052
|
}
|
|
2020
2053
|
}
|
|
2021
2054
|
}
|
|
@@ -2031,19 +2064,17 @@ var service = {
|
|
|
2031
2064
|
}
|
|
2032
2065
|
},
|
|
2033
2066
|
async doCodeActions(doc, params, cancel) {
|
|
2034
|
-
|
|
2067
|
+
let result;
|
|
2035
2068
|
try {
|
|
2036
|
-
const
|
|
2069
|
+
for (const pending of plugins.map((plugin) => {
|
|
2037
2070
|
var _a;
|
|
2038
2071
|
return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
2039
|
-
})
|
|
2040
|
-
for (const pending of requests) {
|
|
2072
|
+
})) {
|
|
2041
2073
|
const cur = await pending;
|
|
2042
2074
|
if (cancel.isCancellationRequested)
|
|
2043
2075
|
return;
|
|
2044
|
-
if (cur)
|
|
2045
|
-
result.
|
|
2046
|
-
}
|
|
2076
|
+
if (cur)
|
|
2077
|
+
result = result ? result.concat(cur) : cur;
|
|
2047
2078
|
}
|
|
2048
2079
|
} catch (err) {
|
|
2049
2080
|
displayError(err);
|
|
@@ -2051,16 +2082,15 @@ var service = {
|
|
|
2051
2082
|
return result;
|
|
2052
2083
|
},
|
|
2053
2084
|
async doValidate(doc) {
|
|
2054
|
-
|
|
2085
|
+
let result;
|
|
2055
2086
|
try {
|
|
2056
|
-
const
|
|
2087
|
+
for (const pending of plugins.map((plugin) => {
|
|
2057
2088
|
var _a;
|
|
2058
2089
|
return (_a = plugin.doValidate) == null ? void 0 : _a.call(plugin, doc);
|
|
2059
|
-
})
|
|
2060
|
-
for (const pending of requests) {
|
|
2090
|
+
})) {
|
|
2061
2091
|
const cur = await pending;
|
|
2062
2092
|
if (cur)
|
|
2063
|
-
result.
|
|
2093
|
+
result = result ? result.concat(cur) : cur;
|
|
2064
2094
|
}
|
|
2065
2095
|
} catch (err) {
|
|
2066
2096
|
displayError(err);
|