@marko/language-server 1.2.0 → 1.3.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/dist/index.js +94 -186
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +95 -188
- package/dist/index.mjs.map +2 -2
- package/package.json +14 -15
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
3
|
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
6
|
});
|
|
8
7
|
|
|
@@ -111,12 +110,10 @@ function getAllOpen() {
|
|
|
111
110
|
}
|
|
112
111
|
function get(uri) {
|
|
113
112
|
const doc = docs.get(uri);
|
|
114
|
-
if (doc)
|
|
115
|
-
return doc;
|
|
113
|
+
if (doc) return doc;
|
|
116
114
|
const { fsPath, scheme } = URI2.parse(uri);
|
|
117
115
|
if (scheme === "file") {
|
|
118
|
-
if (fileExists.get(uri) === false)
|
|
119
|
-
return void 0;
|
|
116
|
+
if (fileExists.get(uri) === false) return void 0;
|
|
120
117
|
try {
|
|
121
118
|
const newDoc = TextDocument.create(
|
|
122
119
|
uri,
|
|
@@ -134,8 +131,7 @@ function get(uri) {
|
|
|
134
131
|
}
|
|
135
132
|
function exists(uri) {
|
|
136
133
|
const cached = fileExists.get(uri);
|
|
137
|
-
if (cached !== void 0)
|
|
138
|
-
return cached;
|
|
134
|
+
if (cached !== void 0) return cached;
|
|
139
135
|
const { fsPath, scheme } = URI2.parse(uri);
|
|
140
136
|
if (scheme === "file") {
|
|
141
137
|
try {
|
|
@@ -284,8 +280,7 @@ function display(type, data) {
|
|
|
284
280
|
const msg = typeof data === "string" ? data : inspect(data, { colors: false });
|
|
285
281
|
const previousMessages = previousMessagesByType.get(type);
|
|
286
282
|
if (previousMessages) {
|
|
287
|
-
if (previousMessages.includes(msg))
|
|
288
|
-
return;
|
|
283
|
+
if (previousMessages.includes(msg)) return;
|
|
289
284
|
previousMessages.push(msg);
|
|
290
285
|
if (previousMessages.length > 3) {
|
|
291
286
|
previousMessages.unshift();
|
|
@@ -887,8 +882,7 @@ var HTMLService = {
|
|
|
887
882
|
commands: {
|
|
888
883
|
"$/showHtmlOutput": async (uri) => {
|
|
889
884
|
const doc = get(uri);
|
|
890
|
-
if (!doc)
|
|
891
|
-
return;
|
|
885
|
+
if (!doc) return;
|
|
892
886
|
const { extracted } = extract(doc);
|
|
893
887
|
return {
|
|
894
888
|
language: "html",
|
|
@@ -918,8 +912,7 @@ var HTMLService = {
|
|
|
918
912
|
return violations.flatMap((result) => {
|
|
919
913
|
var _a;
|
|
920
914
|
const { element } = result;
|
|
921
|
-
if (!element)
|
|
922
|
-
return [];
|
|
915
|
+
if (!element) return [];
|
|
923
916
|
const ruleId = result.ruleId;
|
|
924
917
|
if (element.dataset.markoNodeId) {
|
|
925
918
|
const details = nodeDetails[element.dataset.markoNodeId];
|
|
@@ -930,14 +923,12 @@ var HTMLService = {
|
|
|
930
923
|
}
|
|
931
924
|
}
|
|
932
925
|
const generatedLoc = jsdom.nodeLocation(element);
|
|
933
|
-
if (!generatedLoc)
|
|
934
|
-
return [];
|
|
926
|
+
if (!generatedLoc) return [];
|
|
935
927
|
const sourceRange = extracted.sourceLocationAt(
|
|
936
928
|
generatedLoc.startOffset + 1,
|
|
937
929
|
generatedLoc.startOffset + 1 + element.tagName.length
|
|
938
930
|
);
|
|
939
|
-
if (!sourceRange)
|
|
940
|
-
return [];
|
|
931
|
+
if (!sourceRange) return [];
|
|
941
932
|
return [
|
|
942
933
|
{
|
|
943
934
|
range: sourceRange,
|
|
@@ -1128,10 +1119,8 @@ async function stat(uri) {
|
|
|
1128
1119
|
let size = -1;
|
|
1129
1120
|
try {
|
|
1130
1121
|
const stat2 = await fs2.stat(fileURLToPath(uri));
|
|
1131
|
-
if (stat2.isDirectory())
|
|
1132
|
-
|
|
1133
|
-
else if (stat2.isFile())
|
|
1134
|
-
type = FileType.File;
|
|
1122
|
+
if (stat2.isDirectory()) type = FileType.Directory;
|
|
1123
|
+
else if (stat2.isFile()) type = FileType.File;
|
|
1135
1124
|
ctime = stat2.ctimeMs;
|
|
1136
1125
|
mtime = stat2.mtimeMs;
|
|
1137
1126
|
size = stat2.size;
|
|
@@ -1163,8 +1152,7 @@ async function readDirectory(uri) {
|
|
|
1163
1152
|
function resolveUrl(to, base) {
|
|
1164
1153
|
try {
|
|
1165
1154
|
const url = new URL(to, base);
|
|
1166
|
-
if (url.protocol === "file:")
|
|
1167
|
-
return url.toString();
|
|
1155
|
+
if (url.protocol === "file:") return url.toString();
|
|
1168
1156
|
} catch {
|
|
1169
1157
|
return void 0;
|
|
1170
1158
|
}
|
|
@@ -1179,8 +1167,7 @@ async function AttrValue({
|
|
|
1179
1167
|
const attr = node.parent;
|
|
1180
1168
|
if (isDocumentLinkAttr(code, attr.parent, attr)) {
|
|
1181
1169
|
const start = node.value.start + 1;
|
|
1182
|
-
if (code[start] !== ".")
|
|
1183
|
-
return;
|
|
1170
|
+
if (code[start] !== ".") return;
|
|
1184
1171
|
const end = node.value.end - 1;
|
|
1185
1172
|
const relativeOffset = offset - start;
|
|
1186
1173
|
const rawValue = parsed.read({
|
|
@@ -1188,8 +1175,7 @@ async function AttrValue({
|
|
|
1188
1175
|
end
|
|
1189
1176
|
});
|
|
1190
1177
|
const segmentStart = rawValue.lastIndexOf("/", relativeOffset);
|
|
1191
|
-
if (segmentStart === -1)
|
|
1192
|
-
return;
|
|
1178
|
+
if (segmentStart === -1) return;
|
|
1193
1179
|
const req = rawValue.slice(0, segmentStart);
|
|
1194
1180
|
const resolved = resolveUrl(req, uri);
|
|
1195
1181
|
if (resolved) {
|
|
@@ -1290,7 +1276,7 @@ ${autocomplete.description}`;
|
|
|
1290
1276
|
}
|
|
1291
1277
|
|
|
1292
1278
|
// src/service/marko/complete/Import.ts
|
|
1293
|
-
var importTagReg = /(['"])<((?:[
|
|
1279
|
+
var importTagReg = /(['"])<((?:[^'"\\>]+|\\.)*)>?\1/;
|
|
1294
1280
|
function Import({
|
|
1295
1281
|
node,
|
|
1296
1282
|
file: { parsed, filename, lookup }
|
|
@@ -1334,8 +1320,7 @@ function OpenTagName({
|
|
|
1334
1320
|
const result = [];
|
|
1335
1321
|
if (isAttrTag) {
|
|
1336
1322
|
let parentTag = tag.owner;
|
|
1337
|
-
while ((parentTag == null ? void 0 : parentTag.type) === NodeType2.AttrTag)
|
|
1338
|
-
parentTag = parentTag.owner;
|
|
1323
|
+
while ((parentTag == null ? void 0 : parentTag.type) === NodeType2.AttrTag) parentTag = parentTag.owner;
|
|
1339
1324
|
const parentTagDef = parentTag && parentTag.nameText && lookup.getTag(parentTag.nameText);
|
|
1340
1325
|
if (parentTagDef) {
|
|
1341
1326
|
const { nestedTags } = parentTagDef;
|
|
@@ -1385,8 +1370,7 @@ function Tag({
|
|
|
1385
1370
|
file: { parsed, code }
|
|
1386
1371
|
}) {
|
|
1387
1372
|
const isClosed = node.end !== UNFINISHED;
|
|
1388
|
-
if (isClosed || node.concise)
|
|
1389
|
-
return;
|
|
1373
|
+
if (isClosed || node.concise) return;
|
|
1390
1374
|
const closingTagStr = `</${node.nameText || ""}>`;
|
|
1391
1375
|
if (offset === node.open.end) {
|
|
1392
1376
|
return [
|
|
@@ -1545,8 +1529,7 @@ function OpenTagName2({
|
|
|
1545
1529
|
let range = START_LOCATION;
|
|
1546
1530
|
if (tag.type === NodeType4.AttrTag) {
|
|
1547
1531
|
let parentTag = tag.owner;
|
|
1548
|
-
while ((parentTag == null ? void 0 : parentTag.type) === NodeType4.AttrTag)
|
|
1549
|
-
parentTag = parentTag.owner;
|
|
1532
|
+
while ((parentTag == null ? void 0 : parentTag.type) === NodeType4.AttrTag) parentTag = parentTag.owner;
|
|
1550
1533
|
tagDef = parentTag && parentTag.nameText ? lookup.getTag(parentTag.nameText) : void 0;
|
|
1551
1534
|
} else {
|
|
1552
1535
|
tagDef = tag.nameText ? lookup.getTag(tag.nameText) : void 0;
|
|
@@ -1601,7 +1584,7 @@ var findDefinition = async (doc, params) => {
|
|
|
1601
1584
|
|
|
1602
1585
|
// src/service/marko/document-links.ts
|
|
1603
1586
|
import { NodeType as NodeType6 } from "@marko/language-tools";
|
|
1604
|
-
var importTagReg2 = /(['"])<((?:[
|
|
1587
|
+
var importTagReg2 = /(['"])<((?:[^'"\\>]+|\\.)*)>?\1/g;
|
|
1605
1588
|
var findDocumentLinks = async (doc) => {
|
|
1606
1589
|
return processDoc(doc, extractDocumentLinks);
|
|
1607
1590
|
};
|
|
@@ -1742,8 +1725,7 @@ async function formatDocument(doc, formatOptions, cancel) {
|
|
|
1742
1725
|
}).catch(() => null) : null
|
|
1743
1726
|
};
|
|
1744
1727
|
markoPrettier.setCompiler(Project3.getCompiler(dir), Project3.getConfig(dir));
|
|
1745
|
-
if (cancel == null ? void 0 : cancel.isCancellationRequested)
|
|
1746
|
-
return;
|
|
1728
|
+
if (cancel == null ? void 0 : cancel.isCancellationRequested) return;
|
|
1747
1729
|
return [
|
|
1748
1730
|
TextEdit6.replace(
|
|
1749
1731
|
{
|
|
@@ -1897,8 +1879,7 @@ function addDiagnosticsForError(err, diagnostics) {
|
|
|
1897
1879
|
}
|
|
1898
1880
|
} else if (isErrorWithLoc(err)) {
|
|
1899
1881
|
const message = err.label || err.message || err.stack;
|
|
1900
|
-
if (!message)
|
|
1901
|
-
return;
|
|
1882
|
+
if (!message) return;
|
|
1902
1883
|
const { loc } = err;
|
|
1903
1884
|
diagnostics.push({
|
|
1904
1885
|
range: {
|
|
@@ -1944,8 +1925,7 @@ function isAggregateError(err) {
|
|
|
1944
1925
|
}
|
|
1945
1926
|
function isErrorWithLoc(err) {
|
|
1946
1927
|
const loc = err == null ? void 0 : err.loc;
|
|
1947
|
-
if (typeof loc !== "object")
|
|
1948
|
-
return false;
|
|
1928
|
+
if (typeof loc !== "object") return false;
|
|
1949
1929
|
return loc !== null && typeof loc === "object" && typeof loc.start === "object" && typeof loc.end === "object" && typeof loc.start.line === "number" && typeof loc.start.column === "number" && typeof loc.end.line === "number" && typeof loc.end.column === "number";
|
|
1950
1930
|
}
|
|
1951
1931
|
|
|
@@ -2029,8 +2009,7 @@ function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
|
|
|
2029
2009
|
if (getScriptKind) {
|
|
2030
2010
|
host.getScriptKind = (fileName) => {
|
|
2031
2011
|
const processor = getProcessor(fileName);
|
|
2032
|
-
if (processor)
|
|
2033
|
-
return processor.getScriptKind(fileName);
|
|
2012
|
+
if (processor) return processor.getScriptKind(fileName);
|
|
2034
2013
|
return getScriptKind(fileName);
|
|
2035
2014
|
};
|
|
2036
2015
|
}
|
|
@@ -2058,8 +2037,7 @@ function patch(ts2, configFile, extractCache3, resolutionCache, host, ps) {
|
|
|
2058
2037
|
const getScriptVersion = host.getScriptVersion.bind(host);
|
|
2059
2038
|
host.getScriptVersion = (fileName) => {
|
|
2060
2039
|
const processor = getProcessor(fileName);
|
|
2061
|
-
if (processor)
|
|
2062
|
-
return host.getProjectVersion();
|
|
2040
|
+
if (processor) return host.getProjectVersion();
|
|
2063
2041
|
return getScriptVersion(fileName);
|
|
2064
2042
|
};
|
|
2065
2043
|
}
|
|
@@ -2196,8 +2174,7 @@ function printJSDocTag(tag) {
|
|
|
2196
2174
|
}
|
|
2197
2175
|
case "return":
|
|
2198
2176
|
case "returns": {
|
|
2199
|
-
if (!((_a = tag.text) == null ? void 0 : _a.length))
|
|
2200
|
-
return void 0;
|
|
2177
|
+
if (!((_a = tag.text) == null ? void 0 : _a.length)) return void 0;
|
|
2201
2178
|
break;
|
|
2202
2179
|
}
|
|
2203
2180
|
}
|
|
@@ -2215,8 +2192,7 @@ function getTagBodyParts(tag) {
|
|
|
2215
2192
|
return convertLinkTags(tag.text).split(/^(\S+)\s*-?\s*/);
|
|
2216
2193
|
}
|
|
2217
2194
|
function getTagBodyText(tag) {
|
|
2218
|
-
if (!tag.text)
|
|
2219
|
-
return "";
|
|
2195
|
+
if (!tag.text) return "";
|
|
2220
2196
|
const text = convertLinkTags(tag.text);
|
|
2221
2197
|
switch (tag.name) {
|
|
2222
2198
|
case "example": {
|
|
@@ -2244,10 +2220,8 @@ ${ensureCodeblock(
|
|
|
2244
2220
|
return replaceLinks(text);
|
|
2245
2221
|
}
|
|
2246
2222
|
function convertLinkTags(parts) {
|
|
2247
|
-
if (!parts)
|
|
2248
|
-
|
|
2249
|
-
if (typeof parts === "string")
|
|
2250
|
-
return parts;
|
|
2223
|
+
if (!parts) return "";
|
|
2224
|
+
if (typeof parts === "string") return parts;
|
|
2251
2225
|
let result = "";
|
|
2252
2226
|
let currentLink;
|
|
2253
2227
|
for (const part of parts) {
|
|
@@ -2367,11 +2341,9 @@ var ScriptService = {
|
|
|
2367
2341
|
commands: {
|
|
2368
2342
|
"$/showScriptOutput": async (uri) => {
|
|
2369
2343
|
const doc = get(uri);
|
|
2370
|
-
if ((doc == null ? void 0 : doc.languageId) !== "marko")
|
|
2371
|
-
return;
|
|
2344
|
+
if ((doc == null ? void 0 : doc.languageId) !== "marko") return;
|
|
2372
2345
|
const filename = getFSPath(doc);
|
|
2373
|
-
if (!filename)
|
|
2374
|
-
return;
|
|
2346
|
+
if (!filename) return;
|
|
2375
2347
|
const tsProject = getTSProject(filename);
|
|
2376
2348
|
const extracted = processScript(doc, tsProject);
|
|
2377
2349
|
const lang = Project5.getScriptLang(
|
|
@@ -2408,14 +2380,12 @@ var ScriptService = {
|
|
|
2408
2380
|
async doComplete(doc, params) {
|
|
2409
2381
|
var _a;
|
|
2410
2382
|
const fileName = getFSPath(doc);
|
|
2411
|
-
if (!fileName)
|
|
2412
|
-
return;
|
|
2383
|
+
if (!fileName) return;
|
|
2413
2384
|
const project = getTSProject(fileName);
|
|
2414
2385
|
const extracted = processScript(doc, project);
|
|
2415
2386
|
const sourceOffset = doc.offsetAt(params.position);
|
|
2416
2387
|
const generatedOffset = extracted.generatedOffsetAt(sourceOffset);
|
|
2417
|
-
if (generatedOffset === void 0)
|
|
2418
|
-
return;
|
|
2388
|
+
if (generatedOffset === void 0) return;
|
|
2419
2389
|
const completions = project.service.getCompletionsAtPosition(
|
|
2420
2390
|
fileName,
|
|
2421
2391
|
generatedOffset,
|
|
@@ -2425,13 +2395,11 @@ var ScriptService = {
|
|
|
2425
2395
|
triggerCharacter: getTSTriggerChar((_a = params.context) == null ? void 0 : _a.triggerCharacter)
|
|
2426
2396
|
}
|
|
2427
2397
|
);
|
|
2428
|
-
if (!(completions == null ? void 0 : completions.entries.length))
|
|
2429
|
-
return;
|
|
2398
|
+
if (!(completions == null ? void 0 : completions.entries.length)) return;
|
|
2430
2399
|
const result = [];
|
|
2431
2400
|
for (const completion of completions.entries) {
|
|
2432
2401
|
let { name: label, insertText, sortText } = completion;
|
|
2433
|
-
if (label.startsWith(localInternalsPrefix))
|
|
2434
|
-
continue;
|
|
2402
|
+
if (label.startsWith(localInternalsPrefix)) continue;
|
|
2435
2403
|
const { replacementSpan } = completion;
|
|
2436
2404
|
let textEdit;
|
|
2437
2405
|
let detail;
|
|
@@ -2505,14 +2473,11 @@ var ScriptService = {
|
|
|
2505
2473
|
},
|
|
2506
2474
|
async doCompletionResolve(item) {
|
|
2507
2475
|
const { data } = item;
|
|
2508
|
-
if (!data)
|
|
2509
|
-
return;
|
|
2476
|
+
if (!data) return;
|
|
2510
2477
|
const { fileName } = data;
|
|
2511
|
-
if (!fileName)
|
|
2512
|
-
return;
|
|
2478
|
+
if (!fileName) return;
|
|
2513
2479
|
const doc = get(filenameToURI(fileName));
|
|
2514
|
-
if (!doc)
|
|
2515
|
-
return;
|
|
2480
|
+
if (!doc) return;
|
|
2516
2481
|
const project = getTSProject(fileName);
|
|
2517
2482
|
const detail = project.service.getCompletionEntryDetails(
|
|
2518
2483
|
fileName,
|
|
@@ -2523,14 +2488,12 @@ var ScriptService = {
|
|
|
2523
2488
|
await getPreferences(project.markoScriptLang),
|
|
2524
2489
|
data.originalData
|
|
2525
2490
|
);
|
|
2526
|
-
if (!(detail == null ? void 0 : detail.codeActions))
|
|
2527
|
-
return;
|
|
2491
|
+
if (!(detail == null ? void 0 : detail.codeActions)) return;
|
|
2528
2492
|
const extracted = processScript(doc, project);
|
|
2529
2493
|
const textEdits = item.additionalTextEdits = item.additionalTextEdits || [];
|
|
2530
2494
|
for (const action of detail.codeActions) {
|
|
2531
2495
|
for (const change of action.changes) {
|
|
2532
|
-
if (change.fileName !== fileName)
|
|
2533
|
-
continue;
|
|
2496
|
+
if (change.fileName !== fileName) continue;
|
|
2534
2497
|
for (const { span, newText: rawText } of change.textChanges) {
|
|
2535
2498
|
let range;
|
|
2536
2499
|
let newText = rawText;
|
|
@@ -2562,20 +2525,17 @@ var ScriptService = {
|
|
|
2562
2525
|
},
|
|
2563
2526
|
findDefinition(doc, params) {
|
|
2564
2527
|
const fileName = getFSPath(doc);
|
|
2565
|
-
if (!fileName)
|
|
2566
|
-
return;
|
|
2528
|
+
if (!fileName) return;
|
|
2567
2529
|
const project = getTSProject(fileName);
|
|
2568
2530
|
const extracted = processScript(doc, project);
|
|
2569
2531
|
const sourceOffset = doc.offsetAt(params.position);
|
|
2570
2532
|
const generatedOffset = extracted.generatedOffsetAt(sourceOffset);
|
|
2571
|
-
if (generatedOffset === void 0)
|
|
2572
|
-
return;
|
|
2533
|
+
if (generatedOffset === void 0) return;
|
|
2573
2534
|
const boundary = project.service.getDefinitionAndBoundSpan(
|
|
2574
2535
|
fileName,
|
|
2575
2536
|
generatedOffset
|
|
2576
2537
|
);
|
|
2577
|
-
if (!(boundary == null ? void 0 : boundary.definitions))
|
|
2578
|
-
return;
|
|
2538
|
+
if (!(boundary == null ? void 0 : boundary.definitions)) return;
|
|
2579
2539
|
const originSelectionRange = sourceLocationAtTextSpan(
|
|
2580
2540
|
extracted,
|
|
2581
2541
|
boundary.textSpan
|
|
@@ -2584,8 +2544,7 @@ var ScriptService = {
|
|
|
2584
2544
|
for (const def of boundary.definitions) {
|
|
2585
2545
|
const targetUri = filenameToURI(def.fileName);
|
|
2586
2546
|
const defDoc = get(targetUri);
|
|
2587
|
-
if (!defDoc)
|
|
2588
|
-
continue;
|
|
2547
|
+
if (!defDoc) continue;
|
|
2589
2548
|
let link;
|
|
2590
2549
|
if (markoFileReg.test(targetUri)) {
|
|
2591
2550
|
const extracted2 = processScript(defDoc, project);
|
|
@@ -2621,23 +2580,19 @@ var ScriptService = {
|
|
|
2621
2580
|
},
|
|
2622
2581
|
doHover(doc, params) {
|
|
2623
2582
|
const fileName = getFSPath(doc);
|
|
2624
|
-
if (!fileName)
|
|
2625
|
-
return;
|
|
2583
|
+
if (!fileName) return;
|
|
2626
2584
|
const project = getTSProject(fileName);
|
|
2627
2585
|
const extracted = processScript(doc, project);
|
|
2628
2586
|
const sourceOffset = doc.offsetAt(params.position);
|
|
2629
2587
|
const generatedOffset = extracted.generatedOffsetAt(sourceOffset);
|
|
2630
|
-
if (generatedOffset === void 0)
|
|
2631
|
-
return;
|
|
2588
|
+
if (generatedOffset === void 0) return;
|
|
2632
2589
|
const quickInfo = project.service.getQuickInfoAtPosition(
|
|
2633
2590
|
fileName,
|
|
2634
2591
|
generatedOffset
|
|
2635
2592
|
);
|
|
2636
|
-
if (!quickInfo)
|
|
2637
|
-
return;
|
|
2593
|
+
if (!quickInfo) return;
|
|
2638
2594
|
const sourceRange = sourceLocationAtTextSpan(extracted, quickInfo.textSpan);
|
|
2639
|
-
if (!sourceRange)
|
|
2640
|
-
return;
|
|
2595
|
+
if (!sourceRange) return;
|
|
2641
2596
|
let contents = "";
|
|
2642
2597
|
const displayParts = ts.displayPartsToString(quickInfo.displayParts);
|
|
2643
2598
|
if (displayParts) {
|
|
@@ -2661,14 +2616,12 @@ ${documentation}`;
|
|
|
2661
2616
|
},
|
|
2662
2617
|
doRename(doc, params) {
|
|
2663
2618
|
const fileName = getFSPath(doc);
|
|
2664
|
-
if (!fileName)
|
|
2665
|
-
return;
|
|
2619
|
+
if (!fileName) return;
|
|
2666
2620
|
const project = getTSProject(fileName);
|
|
2667
2621
|
const extracted = processScript(doc, project);
|
|
2668
2622
|
const sourceOffset = doc.offsetAt(params.position);
|
|
2669
2623
|
const generatedOffset = extracted.generatedOffsetAt(sourceOffset);
|
|
2670
|
-
if (generatedOffset === void 0)
|
|
2671
|
-
return;
|
|
2624
|
+
if (generatedOffset === void 0) return;
|
|
2672
2625
|
const renameLocations = project.service.findRenameLocations(
|
|
2673
2626
|
fileName,
|
|
2674
2627
|
generatedOffset,
|
|
@@ -2676,15 +2629,13 @@ ${documentation}`;
|
|
|
2676
2629
|
false,
|
|
2677
2630
|
false
|
|
2678
2631
|
);
|
|
2679
|
-
if (!renameLocations)
|
|
2680
|
-
return;
|
|
2632
|
+
if (!renameLocations) return;
|
|
2681
2633
|
const changes = {};
|
|
2682
2634
|
for (const rename of renameLocations) {
|
|
2683
2635
|
const renameURI = filenameToURI(rename.fileName);
|
|
2684
2636
|
const renameDoc = get(renameURI);
|
|
2685
2637
|
let edit;
|
|
2686
|
-
if (!renameDoc)
|
|
2687
|
-
continue;
|
|
2638
|
+
if (!renameDoc) continue;
|
|
2688
2639
|
if (markoFileReg.test(renameURI)) {
|
|
2689
2640
|
const extracted2 = processScript(renameDoc, project);
|
|
2690
2641
|
const sourceRange = sourceLocationAtTextSpan(
|
|
@@ -2717,8 +2668,7 @@ ${documentation}`;
|
|
|
2717
2668
|
},
|
|
2718
2669
|
doValidate(doc) {
|
|
2719
2670
|
const fileName = getFSPath(doc);
|
|
2720
|
-
if (!fileName)
|
|
2721
|
-
return;
|
|
2671
|
+
if (!fileName) return;
|
|
2722
2672
|
const project = getTSProject(fileName);
|
|
2723
2673
|
const extracted = processScript(doc, project);
|
|
2724
2674
|
let results;
|
|
@@ -2794,8 +2744,7 @@ function getOffsetAfterComments(node) {
|
|
|
2794
2744
|
return Math.max(0, node.start - 1);
|
|
2795
2745
|
}
|
|
2796
2746
|
function sourceLocationAtTextSpan(extracted, { start, length }) {
|
|
2797
|
-
if (start === 0 && length === 0)
|
|
2798
|
-
return START_LOCATION;
|
|
2747
|
+
if (start === 0 && length === 0) return START_LOCATION;
|
|
2799
2748
|
return extracted.sourceLocationAt(start, start + length);
|
|
2800
2749
|
}
|
|
2801
2750
|
function docLocationAtTextSpan(doc, { start, length }) {
|
|
@@ -2837,8 +2786,7 @@ function getTSProject(docFsPath) {
|
|
|
2837
2786
|
let cached;
|
|
2838
2787
|
if (projectCache) {
|
|
2839
2788
|
cached = projectCache.get(basePath);
|
|
2840
|
-
if (cached)
|
|
2841
|
-
return cached;
|
|
2789
|
+
if (cached) return cached;
|
|
2842
2790
|
} else {
|
|
2843
2791
|
projectCache = /* @__PURE__ */ new Map();
|
|
2844
2792
|
cache.set(getTSProject, projectCache);
|
|
@@ -2952,8 +2900,7 @@ function getTSProject(docFsPath) {
|
|
|
2952
2900
|
let snapshot = snapshotCache.get(filename);
|
|
2953
2901
|
if (!snapshot) {
|
|
2954
2902
|
const doc = get(filenameToURI(filename));
|
|
2955
|
-
if (!doc)
|
|
2956
|
-
return;
|
|
2903
|
+
if (!doc) return;
|
|
2957
2904
|
snapshot = ts.ScriptSnapshot.fromString(doc.getText());
|
|
2958
2905
|
snapshotCache.set(filename, snapshot);
|
|
2959
2906
|
}
|
|
@@ -3055,10 +3002,8 @@ function convertDiagTags(tsDiag) {
|
|
|
3055
3002
|
tags = [DiagnosticTag.Deprecated];
|
|
3056
3003
|
}
|
|
3057
3004
|
if (tsDiag.reportsUnnecessary) {
|
|
3058
|
-
if (tags)
|
|
3059
|
-
|
|
3060
|
-
else
|
|
3061
|
-
tags = [DiagnosticTag.Unnecessary];
|
|
3005
|
+
if (tags) tags.push(DiagnosticTag.Unnecessary);
|
|
3006
|
+
else tags = [DiagnosticTag.Unnecessary];
|
|
3062
3007
|
}
|
|
3063
3008
|
return tags;
|
|
3064
3009
|
}
|
|
@@ -3153,8 +3098,7 @@ var StyleSheetService = {
|
|
|
3153
3098
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3154
3099
|
for (const style of processStyle(doc)) {
|
|
3155
3100
|
const generatedPos = style.extracted.generatedPositionAt(sourceOffset);
|
|
3156
|
-
if (generatedPos === void 0)
|
|
3157
|
-
continue;
|
|
3101
|
+
if (generatedPos === void 0) continue;
|
|
3158
3102
|
const result = await style.service.doComplete2(
|
|
3159
3103
|
style.virtualDoc,
|
|
3160
3104
|
generatedPos,
|
|
@@ -3190,8 +3134,7 @@ var StyleSheetService = {
|
|
|
3190
3134
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3191
3135
|
for (const style of processStyle(doc)) {
|
|
3192
3136
|
const generatedPos = style.extracted.generatedPositionAt(sourceOffset);
|
|
3193
|
-
if (generatedPos === void 0)
|
|
3194
|
-
continue;
|
|
3137
|
+
if (generatedPos === void 0) continue;
|
|
3195
3138
|
const result = style.service.findDefinition(
|
|
3196
3139
|
style.virtualDoc,
|
|
3197
3140
|
generatedPos,
|
|
@@ -3213,8 +3156,7 @@ var StyleSheetService = {
|
|
|
3213
3156
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3214
3157
|
for (const style of processStyle(doc)) {
|
|
3215
3158
|
const generatedPos = style.extracted.generatedPositionAt(sourceOffset);
|
|
3216
|
-
if (generatedPos === void 0)
|
|
3217
|
-
continue;
|
|
3159
|
+
if (generatedPos === void 0) continue;
|
|
3218
3160
|
const result = [];
|
|
3219
3161
|
for (const location of style.service.findReferences(
|
|
3220
3162
|
style.virtualDoc,
|
|
@@ -3283,8 +3225,7 @@ var StyleSheetService = {
|
|
|
3283
3225
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3284
3226
|
for (const style of processStyle(doc)) {
|
|
3285
3227
|
const generatedPos = style.extracted.generatedPositionAt(sourceOffset);
|
|
3286
|
-
if (generatedPos === void 0)
|
|
3287
|
-
continue;
|
|
3228
|
+
if (generatedPos === void 0) continue;
|
|
3288
3229
|
const result = [];
|
|
3289
3230
|
for (const highlight of style.service.findDocumentHighlights(
|
|
3290
3231
|
style.virtualDoc,
|
|
@@ -3323,8 +3264,7 @@ var StyleSheetService = {
|
|
|
3323
3264
|
getColorPresentations(doc, params) {
|
|
3324
3265
|
for (const extracted of processStyle(doc)) {
|
|
3325
3266
|
const generatedRange = getGeneratedRange(doc, extracted, params.range);
|
|
3326
|
-
if (generatedRange === void 0)
|
|
3327
|
-
continue;
|
|
3267
|
+
if (generatedRange === void 0) continue;
|
|
3328
3268
|
const result = [];
|
|
3329
3269
|
for (const colorPresentation of extracted.service.getColorPresentations(
|
|
3330
3270
|
extracted.virtualDoc,
|
|
@@ -3349,8 +3289,7 @@ var StyleSheetService = {
|
|
|
3349
3289
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3350
3290
|
for (const style of processStyle(doc)) {
|
|
3351
3291
|
const generatedPos = style.extracted.generatedPositionAt(sourceOffset);
|
|
3352
|
-
if (generatedPos === void 0)
|
|
3353
|
-
continue;
|
|
3292
|
+
if (generatedPos === void 0) continue;
|
|
3354
3293
|
const result = style.service.doHover(
|
|
3355
3294
|
style.virtualDoc,
|
|
3356
3295
|
generatedPos,
|
|
@@ -3375,8 +3314,7 @@ var StyleSheetService = {
|
|
|
3375
3314
|
const sourceOffset = doc.offsetAt(params.position);
|
|
3376
3315
|
for (const style of processStyle(doc)) {
|
|
3377
3316
|
const generatedOffset = style.extracted.generatedOffsetAt(sourceOffset);
|
|
3378
|
-
if (generatedOffset === void 0)
|
|
3379
|
-
continue;
|
|
3317
|
+
if (generatedOffset === void 0) continue;
|
|
3380
3318
|
const result = style.service.doRename(
|
|
3381
3319
|
style.virtualDoc,
|
|
3382
3320
|
style.virtualDoc.positionAt(generatedOffset),
|
|
@@ -3406,8 +3344,7 @@ var StyleSheetService = {
|
|
|
3406
3344
|
var _a;
|
|
3407
3345
|
for (const extracted of processStyle(doc)) {
|
|
3408
3346
|
const generatedRange = getGeneratedRange(doc, extracted, params.range);
|
|
3409
|
-
if (generatedRange === void 0)
|
|
3410
|
-
continue;
|
|
3347
|
+
if (generatedRange === void 0) continue;
|
|
3411
3348
|
const result = extracted.service.doCodeActions(
|
|
3412
3349
|
extracted.virtualDoc,
|
|
3413
3350
|
generatedRange,
|
|
@@ -3547,12 +3484,10 @@ var service = {
|
|
|
3547
3484
|
return (_a = plugin.doComplete) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3548
3485
|
})
|
|
3549
3486
|
);
|
|
3550
|
-
if (cancel.isCancellationRequested)
|
|
3551
|
-
return;
|
|
3487
|
+
if (cancel.isCancellationRequested) return;
|
|
3552
3488
|
const itemsByLabel = /* @__PURE__ */ new Map();
|
|
3553
3489
|
for (const result of results) {
|
|
3554
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3555
|
-
continue;
|
|
3490
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3556
3491
|
for (const item of Array.isArray(result.value) ? result.value : result.value.items) {
|
|
3557
3492
|
const { label } = item;
|
|
3558
3493
|
const existingItem = itemsByLabel.get(label);
|
|
@@ -3572,10 +3507,8 @@ var service = {
|
|
|
3572
3507
|
for (const plugin of plugins) {
|
|
3573
3508
|
try {
|
|
3574
3509
|
const result = await ((_a = plugin.doCompletionResolve) == null ? void 0 : _a.call(plugin, item, cancel));
|
|
3575
|
-
if (cancel.isCancellationRequested)
|
|
3576
|
-
|
|
3577
|
-
if (result)
|
|
3578
|
-
return result;
|
|
3510
|
+
if (cancel.isCancellationRequested) return;
|
|
3511
|
+
if (result) return result;
|
|
3579
3512
|
} catch {
|
|
3580
3513
|
}
|
|
3581
3514
|
}
|
|
@@ -3587,12 +3520,10 @@ var service = {
|
|
|
3587
3520
|
return (_a = plugin.findDefinition) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3588
3521
|
})
|
|
3589
3522
|
);
|
|
3590
|
-
if (cancel.isCancellationRequested)
|
|
3591
|
-
return;
|
|
3523
|
+
if (cancel.isCancellationRequested) return;
|
|
3592
3524
|
let links;
|
|
3593
3525
|
for (const result of results) {
|
|
3594
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3595
|
-
continue;
|
|
3526
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3596
3527
|
links = (links || []).concat(result.value);
|
|
3597
3528
|
}
|
|
3598
3529
|
return links;
|
|
@@ -3604,12 +3535,10 @@ var service = {
|
|
|
3604
3535
|
return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3605
3536
|
})
|
|
3606
3537
|
);
|
|
3607
|
-
if (cancel.isCancellationRequested)
|
|
3608
|
-
return;
|
|
3538
|
+
if (cancel.isCancellationRequested) return;
|
|
3609
3539
|
let references;
|
|
3610
3540
|
for (const result of results) {
|
|
3611
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3612
|
-
continue;
|
|
3541
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3613
3542
|
references = (references || []).concat(result.value);
|
|
3614
3543
|
}
|
|
3615
3544
|
return references;
|
|
@@ -3623,12 +3552,10 @@ var service = {
|
|
|
3623
3552
|
}
|
|
3624
3553
|
)
|
|
3625
3554
|
);
|
|
3626
|
-
if (cancel.isCancellationRequested)
|
|
3627
|
-
return;
|
|
3555
|
+
if (cancel.isCancellationRequested) return;
|
|
3628
3556
|
let symbols;
|
|
3629
3557
|
for (const result of results) {
|
|
3630
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3631
|
-
continue;
|
|
3558
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3632
3559
|
symbols = (symbols || []).concat(result.value);
|
|
3633
3560
|
}
|
|
3634
3561
|
return symbols;
|
|
@@ -3640,12 +3567,10 @@ var service = {
|
|
|
3640
3567
|
return (_a = plugin.findDocumentLinks) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3641
3568
|
})
|
|
3642
3569
|
);
|
|
3643
|
-
if (cancel.isCancellationRequested)
|
|
3644
|
-
return;
|
|
3570
|
+
if (cancel.isCancellationRequested) return;
|
|
3645
3571
|
let links;
|
|
3646
3572
|
for (const result of results) {
|
|
3647
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3648
|
-
continue;
|
|
3573
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3649
3574
|
links = (links || []).concat(result.value);
|
|
3650
3575
|
}
|
|
3651
3576
|
return links;
|
|
@@ -3659,12 +3584,10 @@ var service = {
|
|
|
3659
3584
|
}
|
|
3660
3585
|
)
|
|
3661
3586
|
);
|
|
3662
|
-
if (cancel.isCancellationRequested)
|
|
3663
|
-
return;
|
|
3587
|
+
if (cancel.isCancellationRequested) return;
|
|
3664
3588
|
let highlights;
|
|
3665
3589
|
for (const result of results) {
|
|
3666
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3667
|
-
continue;
|
|
3590
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3668
3591
|
highlights = (highlights || []).concat(result.value);
|
|
3669
3592
|
}
|
|
3670
3593
|
return highlights;
|
|
@@ -3676,12 +3599,10 @@ var service = {
|
|
|
3676
3599
|
return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3677
3600
|
})
|
|
3678
3601
|
);
|
|
3679
|
-
if (cancel.isCancellationRequested)
|
|
3680
|
-
return;
|
|
3602
|
+
if (cancel.isCancellationRequested) return;
|
|
3681
3603
|
let colors;
|
|
3682
3604
|
for (const result of results) {
|
|
3683
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3684
|
-
continue;
|
|
3605
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3685
3606
|
colors = (colors || []).concat(result.value);
|
|
3686
3607
|
}
|
|
3687
3608
|
return colors;
|
|
@@ -3695,12 +3616,10 @@ var service = {
|
|
|
3695
3616
|
}
|
|
3696
3617
|
)
|
|
3697
3618
|
);
|
|
3698
|
-
if (cancel.isCancellationRequested)
|
|
3699
|
-
return;
|
|
3619
|
+
if (cancel.isCancellationRequested) return;
|
|
3700
3620
|
let presentations;
|
|
3701
3621
|
for (const result of results) {
|
|
3702
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3703
|
-
continue;
|
|
3622
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3704
3623
|
presentations = (presentations || []).concat(result.value);
|
|
3705
3624
|
}
|
|
3706
3625
|
return presentations;
|
|
@@ -3712,12 +3631,10 @@ var service = {
|
|
|
3712
3631
|
return (_a = plugin.doHover) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3713
3632
|
})
|
|
3714
3633
|
);
|
|
3715
|
-
if (cancel.isCancellationRequested)
|
|
3716
|
-
return;
|
|
3634
|
+
if (cancel.isCancellationRequested) return;
|
|
3717
3635
|
let hovers;
|
|
3718
3636
|
for (const result of results) {
|
|
3719
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3720
|
-
continue;
|
|
3637
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3721
3638
|
if (hovers) {
|
|
3722
3639
|
hovers.range = maxRange(hovers.range, result.value.range);
|
|
3723
3640
|
hovers.contents = mergeHoverContents(
|
|
@@ -3737,14 +3654,12 @@ var service = {
|
|
|
3737
3654
|
return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3738
3655
|
})
|
|
3739
3656
|
);
|
|
3740
|
-
if (cancel.isCancellationRequested)
|
|
3741
|
-
return;
|
|
3657
|
+
if (cancel.isCancellationRequested) return;
|
|
3742
3658
|
let changes;
|
|
3743
3659
|
let changeAnnotations;
|
|
3744
3660
|
let documentChanges;
|
|
3745
3661
|
for (const result of results) {
|
|
3746
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3747
|
-
continue;
|
|
3662
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3748
3663
|
const { value } = result;
|
|
3749
3664
|
if (value.changes) {
|
|
3750
3665
|
if (changes) {
|
|
@@ -3781,12 +3696,10 @@ var service = {
|
|
|
3781
3696
|
return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
3782
3697
|
})
|
|
3783
3698
|
);
|
|
3784
|
-
if (cancel.isCancellationRequested)
|
|
3785
|
-
return;
|
|
3699
|
+
if (cancel.isCancellationRequested) return;
|
|
3786
3700
|
let actions;
|
|
3787
3701
|
for (const result of results) {
|
|
3788
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3789
|
-
continue;
|
|
3702
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3790
3703
|
actions = (actions || []).concat(result.value);
|
|
3791
3704
|
}
|
|
3792
3705
|
return actions;
|
|
@@ -3800,8 +3713,7 @@ var service = {
|
|
|
3800
3713
|
);
|
|
3801
3714
|
let diagnostics;
|
|
3802
3715
|
for (const result of results) {
|
|
3803
|
-
if (result.status !== "fulfilled" || !result.value)
|
|
3804
|
-
continue;
|
|
3716
|
+
if (result.status !== "fulfilled" || !result.value) continue;
|
|
3805
3717
|
diagnostics = (diagnostics || []).concat(result.value);
|
|
3806
3718
|
}
|
|
3807
3719
|
return diagnostics;
|
|
@@ -3809,10 +3721,8 @@ var service = {
|
|
|
3809
3721
|
format: marko_default.format
|
|
3810
3722
|
};
|
|
3811
3723
|
function maxRange(a, b) {
|
|
3812
|
-
if (!a)
|
|
3813
|
-
|
|
3814
|
-
if (!b)
|
|
3815
|
-
return a;
|
|
3724
|
+
if (!a) return b;
|
|
3725
|
+
if (!b) return a;
|
|
3816
3726
|
return {
|
|
3817
3727
|
start: {
|
|
3818
3728
|
line: Math.min(a.start.line, b.start.line),
|
|
@@ -3825,10 +3735,8 @@ function maxRange(a, b) {
|
|
|
3825
3735
|
};
|
|
3826
3736
|
}
|
|
3827
3737
|
function mergeHoverContents(a, b) {
|
|
3828
|
-
if (!a)
|
|
3829
|
-
|
|
3830
|
-
if (!b)
|
|
3831
|
-
return a;
|
|
3738
|
+
if (!a) return b;
|
|
3739
|
+
if (!b) return a;
|
|
3832
3740
|
if (!MarkupContent.is(a)) {
|
|
3833
3741
|
a = markedStringToMarkupContent(a);
|
|
3834
3742
|
}
|
|
@@ -4057,8 +3965,7 @@ function queueDiagnostic() {
|
|
|
4057
3965
|
}
|
|
4058
3966
|
const prevDiag = prevDiags.get(doc) || [];
|
|
4059
3967
|
const nextDiag = await service.doValidate(doc) || [];
|
|
4060
|
-
if (isDeepStrictEqual(prevDiag, nextDiag))
|
|
4061
|
-
return;
|
|
3968
|
+
if (isDeepStrictEqual(prevDiag, nextDiag)) return;
|
|
4062
3969
|
return [doc, nextDiag];
|
|
4063
3970
|
})
|
|
4064
3971
|
);
|