@rohal12/spindle-lsp 0.15.48 → 0.15.49
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/bin.js +43 -27
- package/dist/bin.js.map +2 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -55,7 +55,7 @@ var VERSION;
|
|
|
55
55
|
var init_version = __esm({
|
|
56
56
|
"src/version.ts"() {
|
|
57
57
|
"use strict";
|
|
58
|
-
VERSION = false ? pkg.version : "0.15.
|
|
58
|
+
VERSION = false ? pkg.version : "0.15.49";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -35952,13 +35952,21 @@ function readText2(text3) {
|
|
|
35952
35952
|
}
|
|
35953
35953
|
return new DocumentMarkup(TEXT_URI, text3, passages, TEXT_CONTEXT);
|
|
35954
35954
|
}
|
|
35955
|
+
function bracketLinksByTarget(passage) {
|
|
35956
|
+
let index = bracketLinks.get(passage);
|
|
35957
|
+
if (!index) {
|
|
35958
|
+
index = new Map(passage.tokens.flatMap((token) => token.type === "link" ? [[token.targetStart, token]] : []));
|
|
35959
|
+
bracketLinks.set(passage, index);
|
|
35960
|
+
}
|
|
35961
|
+
return index;
|
|
35962
|
+
}
|
|
35955
35963
|
function findLinkRuntimeMismatches(text3) {
|
|
35956
35964
|
if (!(typeof text3 === "string" ? text3 : text3.text).includes("[[")) return [];
|
|
35957
35965
|
const found = [];
|
|
35958
35966
|
for (const ref2 of documentPassageRefs(markupOfText(text3))) {
|
|
35959
35967
|
if (ref2.form !== "bracket") continue;
|
|
35960
|
-
const link = ref2.passage.
|
|
35961
|
-
if (link
|
|
35968
|
+
const link = bracketLinksByTarget(ref2.passage).get(ref2.start);
|
|
35969
|
+
if (!link) continue;
|
|
35962
35970
|
const runtime = bracketLinkMismatch(link.display, link.target);
|
|
35963
35971
|
if (!runtime) continue;
|
|
35964
35972
|
found.push({ range: ref2.passage.range(link.start, link.end), display: link.display, target: link.target, runtime });
|
|
@@ -35984,7 +35992,7 @@ function findLiteralLinkInterpolations(text3) {
|
|
|
35984
35992
|
}
|
|
35985
35993
|
return found;
|
|
35986
35994
|
}
|
|
35987
|
-
var TEXT_URI, TEXT_CONTEXT, lastMarkup;
|
|
35995
|
+
var TEXT_URI, TEXT_CONTEXT, lastMarkup, bracketLinks;
|
|
35988
35996
|
var init_link_parser = __esm({
|
|
35989
35997
|
"src/core/parsing/link-parser.ts"() {
|
|
35990
35998
|
"use strict";
|
|
@@ -35995,6 +36003,7 @@ var init_link_parser = __esm({
|
|
|
35995
36003
|
init_passage_refs();
|
|
35996
36004
|
TEXT_URI = "memory:///text.tw";
|
|
35997
36005
|
TEXT_CONTEXT = { macros: builtinMacros, isBlock: isBlockMacro };
|
|
36006
|
+
bracketLinks = /* @__PURE__ */ new WeakMap();
|
|
35998
36007
|
}
|
|
35999
36008
|
});
|
|
36000
36009
|
|
|
@@ -36019,35 +36028,38 @@ function computeDiagnostics(uri, workspace, options) {
|
|
|
36019
36028
|
const diagnostics = [...tweeDiagnostics(doc)];
|
|
36020
36029
|
if (doc.passages.length === 0) return diagnostics;
|
|
36021
36030
|
const attempt = (check2) => {
|
|
36031
|
+
let batch;
|
|
36022
36032
|
try {
|
|
36023
|
-
check2();
|
|
36033
|
+
batch = check2();
|
|
36024
36034
|
} catch {
|
|
36035
|
+
return;
|
|
36025
36036
|
}
|
|
36037
|
+
for (const diagnostic of batch) diagnostics.push(diagnostic);
|
|
36026
36038
|
};
|
|
36027
36039
|
const story = storyReport(workspace);
|
|
36028
|
-
|
|
36040
|
+
for (const diagnostic of story.metadata.get(doc) ?? []) diagnostics.push(diagnostic);
|
|
36029
36041
|
const effective = new Set(workspace.passages.getEffectivePassages());
|
|
36030
36042
|
let passageNames;
|
|
36031
36043
|
const getPassageNames = () => passageNames ??= [...effective].filter(isRuntimePassage).map((passage) => passage.name);
|
|
36032
36044
|
for (const passage of doc.passages) {
|
|
36033
36045
|
if (!effective.has(passage.passage)) continue;
|
|
36034
|
-
attempt(() =>
|
|
36035
|
-
attempt(() =>
|
|
36036
|
-
attempt(() =>
|
|
36037
|
-
attempt(() =>
|
|
36038
|
-
attempt(() =>
|
|
36039
|
-
}
|
|
36040
|
-
attempt(() =>
|
|
36041
|
-
attempt(() =>
|
|
36042
|
-
attempt(() =>
|
|
36043
|
-
attempt(() =>
|
|
36046
|
+
attempt(() => markupDiagnostics(passage, story, workspace));
|
|
36047
|
+
attempt(() => variableDiagnostics(passage, story));
|
|
36048
|
+
attempt(() => structureDiagnostics(passage, story, workspace));
|
|
36049
|
+
attempt(() => argumentDiagnostics(passage, workspace, getPassageNames));
|
|
36050
|
+
attempt(() => widgetDiagnostics(passage, story, workspace));
|
|
36051
|
+
}
|
|
36052
|
+
attempt(() => versionDiagnostics(uri, doc, workspace));
|
|
36053
|
+
attempt(() => storyVariablesDiagnostics(uri, doc, story, workspace));
|
|
36054
|
+
attempt(() => arrayMemberDiagnostics(uri, workspace));
|
|
36055
|
+
attempt(() => linkDiagnostics(doc).filter((diagnostic) => {
|
|
36044
36056
|
const passage = doc.passageAt(diagnostic.range.start);
|
|
36045
36057
|
return passage !== void 0 && effective.has(passage.passage);
|
|
36046
|
-
}))
|
|
36047
|
-
attempt(() =>
|
|
36058
|
+
}));
|
|
36059
|
+
attempt(() => unusedWidgetDiagnostics(doc, story));
|
|
36048
36060
|
if (options?.maxLineLength) {
|
|
36049
36061
|
const maxLength = options.maxLineLength;
|
|
36050
|
-
attempt(() =>
|
|
36062
|
+
attempt(() => lineLengthDiagnostics(doc, maxLength));
|
|
36051
36063
|
}
|
|
36052
36064
|
return diagnostics.sort((a, b) => a.range.start.line - b.range.start.line || a.range.start.character - b.range.start.character);
|
|
36053
36065
|
}
|
|
@@ -36136,6 +36148,7 @@ function buildReport(documents, workspace) {
|
|
|
36136
36148
|
metadata: storyDataDiagnostics(documents, workspace),
|
|
36137
36149
|
passages,
|
|
36138
36150
|
macros,
|
|
36151
|
+
toolingChildren: new Set(workspace.macros.getAllMacros().filter((macro) => macro.source === "user").flatMap((macro) => macro.subMacros.map((name) => name.toLowerCase()))),
|
|
36139
36152
|
markup,
|
|
36140
36153
|
widgets,
|
|
36141
36154
|
widgetList,
|
|
@@ -36308,15 +36321,15 @@ function versionDiagnostics(uri, doc, workspace) {
|
|
|
36308
36321
|
const first = doc.passages[0].passage;
|
|
36309
36322
|
return [makeDiag({ start: first.range.start, end: first.headerEnd.end }, DiagnosticCode.UnsupportedSpindleVersion, unsupportedVersionMessage(target))];
|
|
36310
36323
|
}
|
|
36311
|
-
function structureDiagnostics(passage, workspace) {
|
|
36324
|
+
function structureDiagnostics(passage, story, workspace) {
|
|
36312
36325
|
const diagnostics = [];
|
|
36313
36326
|
if (!passage.isMarkup) return diagnostics;
|
|
36314
36327
|
const visit2 = (nodes, ancestors) => {
|
|
36315
36328
|
for (const node2 of nodes) {
|
|
36316
36329
|
const token = node2.token;
|
|
36317
36330
|
if (token.type === "macro" && !token.isClose) {
|
|
36318
|
-
diagnostics.push(...parentDiagnostics(passage, token, ancestors, workspace));
|
|
36319
|
-
|
|
36331
|
+
diagnostics.push(...parentDiagnostics(passage, token, ancestors, story, workspace));
|
|
36332
|
+
for (const diagnostic of childDiagnostics(passage, node2, token, workspace)) diagnostics.push(diagnostic);
|
|
36320
36333
|
diagnostics.push(...loopDiagnostics(passage, token, ancestors, workspace));
|
|
36321
36334
|
}
|
|
36322
36335
|
if (!node2.body) continue;
|
|
@@ -36336,11 +36349,11 @@ function structureDiagnostics(passage, workspace) {
|
|
|
36336
36349
|
}
|
|
36337
36350
|
return diagnostics;
|
|
36338
36351
|
}
|
|
36339
|
-
function parentDiagnostics(passage, token, ancestors, workspace) {
|
|
36352
|
+
function parentDiagnostics(passage, token, ancestors, story, workspace) {
|
|
36340
36353
|
const name = token.name.toLowerCase();
|
|
36341
36354
|
const parents = workspace.getEffectiveMacro(name)?.parents;
|
|
36342
36355
|
if (!parents || parents.length === 0 || BRANCH_MACROS2.has(name)) return [];
|
|
36343
|
-
if (
|
|
36356
|
+
if (story.toolingChildren.has(name)) return [];
|
|
36344
36357
|
const allowed = new Set(parents.map((parent) => parent.toLowerCase()));
|
|
36345
36358
|
const parentList = parents.join(", ");
|
|
36346
36359
|
const range2 = passage.range(token.start, token.end);
|
|
@@ -90171,9 +90184,12 @@ function addMacroToConfig(uri, macroName, workspace, options) {
|
|
|
90171
90184
|
return null;
|
|
90172
90185
|
}
|
|
90173
90186
|
}
|
|
90174
|
-
|
|
90175
|
-
|
|
90176
|
-
|
|
90187
|
+
try {
|
|
90188
|
+
const edit = configPath.toLowerCase().endsWith(".json") ? addMacroToJsonConfig(text3, macroName) : addMacroToYamlConfig(text3, macroName);
|
|
90189
|
+
return edit ? { ...action, edits: [{ uri: configUri, ...edit }] } : null;
|
|
90190
|
+
} catch {
|
|
90191
|
+
return null;
|
|
90192
|
+
}
|
|
90177
90193
|
}
|
|
90178
90194
|
function resolveConfigRoot(uri, workspaceRoot) {
|
|
90179
90195
|
if (workspaceRoot) {
|