@rohal12/spindle-lsp 0.15.35 → 0.15.36
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 +71 -69
- package/dist/bin.js.map +4 -4
- 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.36";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -35198,12 +35198,14 @@ function computeDiagnostics(uri, workspace, options) {
|
|
|
35198
35198
|
const story = storyReport(workspace);
|
|
35199
35199
|
diagnostics.push(...story.metadata.get(doc) ?? []);
|
|
35200
35200
|
const effective = new Set(workspace.passages.getEffectivePassages());
|
|
35201
|
+
let passageNames;
|
|
35202
|
+
const getPassageNames = () => passageNames ??= [...effective].filter(isRuntimePassage).map((passage) => passage.name);
|
|
35201
35203
|
for (const passage of doc.passages) {
|
|
35202
35204
|
if (!effective.has(passage.passage)) continue;
|
|
35203
35205
|
attempt(() => diagnostics.push(...markupDiagnostics(passage, story, workspace)));
|
|
35204
35206
|
attempt(() => diagnostics.push(...variableDiagnostics(passage, story)));
|
|
35205
35207
|
attempt(() => diagnostics.push(...structureDiagnostics(passage, workspace)));
|
|
35206
|
-
attempt(() => diagnostics.push(...argumentDiagnostics(passage, workspace)));
|
|
35208
|
+
attempt(() => diagnostics.push(...argumentDiagnostics(passage, workspace, getPassageNames)));
|
|
35207
35209
|
attempt(() => diagnostics.push(...widgetDiagnostics(passage, story, workspace)));
|
|
35208
35210
|
}
|
|
35209
35211
|
attempt(() => diagnostics.push(...versionDiagnostics(uri, doc, workspace)));
|
|
@@ -35656,9 +35658,8 @@ function isReadInBody(passage, bodyStart, bodyEnd, name, macroStart, macroEnd) {
|
|
|
35656
35658
|
}
|
|
35657
35659
|
return false;
|
|
35658
35660
|
}
|
|
35659
|
-
function argumentDiagnostics(passage, workspace) {
|
|
35661
|
+
function argumentDiagnostics(passage, workspace, getPassageNames) {
|
|
35660
35662
|
const diagnostics = [];
|
|
35661
|
-
const passageNames = workspace.passages.getEffectivePassages().filter(isRuntimePassage).map((candidate) => candidate.name);
|
|
35662
35663
|
for (const token of passage.isMarkup ? macroTokens(passage) : []) {
|
|
35663
35664
|
if (token.type !== "macro" || token.isClose) continue;
|
|
35664
35665
|
const info = workspace.getEffectiveMacro(token.name);
|
|
@@ -35678,7 +35679,7 @@ function argumentDiagnostics(passage, workspace) {
|
|
|
35678
35679
|
}
|
|
35679
35680
|
continue;
|
|
35680
35681
|
}
|
|
35681
|
-
const result2 = params.validate(args2, { passages:
|
|
35682
|
+
const result2 = params.validate(args2, { passages: getPassageNames() });
|
|
35682
35683
|
if (result2.variantIndex === null) continue;
|
|
35683
35684
|
for (const error62 of result2.errors) {
|
|
35684
35685
|
const code = error62.message.startsWith("Too many arguments") ? DiagnosticCode.TooManyArguments : DiagnosticCode.ParameterTypeError;
|
|
@@ -87266,7 +87267,7 @@ var init_markup_cursor = __esm({
|
|
|
87266
87267
|
const found = [];
|
|
87267
87268
|
for (const token of region.tokens) {
|
|
87268
87269
|
if (token.type !== "macro" || token.isClose || token.nameEnd >= at3 || at3 >= token.end) continue;
|
|
87269
|
-
found.push({ start: token.start, name: token.name, argsBefore: at3 >= token.argsStart ? region.view.text.slice(viewIndex(region.view, token.argsStart), viewIndex(region.view, at3)) : "" });
|
|
87270
|
+
found.push({ start: token.start, name: token.name, invocation: this.passage.invocations.some((call) => call.start === token.start), argsBefore: at3 >= token.argsStart ? region.view.text.slice(viewIndex(region.view, token.argsStart), viewIndex(region.view, at3)) : "" });
|
|
87270
87271
|
}
|
|
87271
87272
|
for (const error62 of region.errors) {
|
|
87272
87273
|
const source = region.view.text;
|
|
@@ -87276,7 +87277,7 @@ var init_markup_cursor = __esm({
|
|
|
87276
87277
|
if (name && name[0] !== "/") found.push({ start: error62.offset, name, argsBefore: source.slice(end, viewIndex(region.view, at3)).trimStart() });
|
|
87277
87278
|
}
|
|
87278
87279
|
const innermost = found.filter((macro) => known(macro.name)).sort((a, b) => b.start - a.start)[0];
|
|
87279
|
-
if (innermost) return
|
|
87280
|
+
if (innermost) return innermost;
|
|
87280
87281
|
}
|
|
87281
87282
|
return void 0;
|
|
87282
87283
|
}
|
|
@@ -87568,6 +87569,65 @@ var init_completions = __esm({
|
|
|
87568
87569
|
}
|
|
87569
87570
|
});
|
|
87570
87571
|
|
|
87572
|
+
// src/core/markup/macro-heads.ts
|
|
87573
|
+
function* pairedHeads(paired, tokens2) {
|
|
87574
|
+
const unclosed = [];
|
|
87575
|
+
for (const node2 of walkNodes(paired.nodes)) {
|
|
87576
|
+
if (node2.token.type === "macro") yield { name: node2.token.name, closing: false, opener: node2.token.start, start: node2.token.nameStart, end: node2.token.nameEnd };
|
|
87577
|
+
for (const branch of node2.body?.branches ?? []) {
|
|
87578
|
+
yield { name: branch.tag.name, closing: false, opener: branch.tag.start, start: branch.tag.nameStart, end: branch.tag.nameEnd };
|
|
87579
|
+
}
|
|
87580
|
+
const close = node2.body?.close;
|
|
87581
|
+
if (node2.token.type !== "macro") continue;
|
|
87582
|
+
if (close?.type === "macro" && close.name.toLowerCase() === node2.token.name.toLowerCase()) {
|
|
87583
|
+
yield { name: close.name, closing: true, opener: node2.token.start, start: close.nameStart, end: close.nameEnd };
|
|
87584
|
+
} else if (node2.body && !close) {
|
|
87585
|
+
unclosed.push({ name: node2.token.name.toLowerCase(), start: node2.token.start });
|
|
87586
|
+
}
|
|
87587
|
+
}
|
|
87588
|
+
const byStart = new Map(tokens2.map((token) => [token.start, token]));
|
|
87589
|
+
for (const error62 of paired.errors) {
|
|
87590
|
+
const token = byStart.get(error62.start);
|
|
87591
|
+
if (error62.code !== "stray-closer" || token?.type !== "macro" || !token.isClose) continue;
|
|
87592
|
+
const name = token.name.toLowerCase();
|
|
87593
|
+
const open2 = unclosed.find((open3) => open3.name === name && open3.start < error62.start);
|
|
87594
|
+
if (open2) {
|
|
87595
|
+
yield { name: token.name, closing: true, opener: open2.start, start: token.nameStart, end: token.nameEnd };
|
|
87596
|
+
}
|
|
87597
|
+
}
|
|
87598
|
+
}
|
|
87599
|
+
function passageMacroHeads(passage) {
|
|
87600
|
+
let heads = kept2.get(passage);
|
|
87601
|
+
if (heads) return heads;
|
|
87602
|
+
const isBlock = (name) => passage.doc.context.isBlock(name);
|
|
87603
|
+
const found = [...pairedHeads(passage.pairing, passage.tokens)];
|
|
87604
|
+
for (const piece of passage.pieces) {
|
|
87605
|
+
if (piece.kind !== "text") continue;
|
|
87606
|
+
found.push(...pairedHeads(pairMarkup(piece.tokens, { isBlock }), piece.tokens));
|
|
87607
|
+
}
|
|
87608
|
+
const invocations = new Set(passage.invocations.map((token) => token.start));
|
|
87609
|
+
heads = found.sort((a, b) => a.start - b.start).map(({ opener, ...head }) => ({ ...head, invocation: invocations.has(opener), passage, range: passage.range(head.start, head.end) }));
|
|
87610
|
+
kept2.set(passage, heads);
|
|
87611
|
+
return heads;
|
|
87612
|
+
}
|
|
87613
|
+
function documentMacroHeads(doc) {
|
|
87614
|
+
return doc.passages.flatMap((passage) => passage.isMarkup ? [...passageMacroHeads(passage)] : []);
|
|
87615
|
+
}
|
|
87616
|
+
function macroHeadAt(doc, position) {
|
|
87617
|
+
const passage = doc.passageAt(position);
|
|
87618
|
+
if (!passage?.isMarkup) return void 0;
|
|
87619
|
+
return passageMacroHeads(passage).find(({ range: { start, end } }) => start.line === position.line && position.character >= start.character && position.character <= end.character);
|
|
87620
|
+
}
|
|
87621
|
+
var kept2;
|
|
87622
|
+
var init_macro_heads = __esm({
|
|
87623
|
+
"src/core/markup/macro-heads.ts"() {
|
|
87624
|
+
"use strict";
|
|
87625
|
+
init_tooling();
|
|
87626
|
+
init_tree();
|
|
87627
|
+
kept2 = /* @__PURE__ */ new WeakMap();
|
|
87628
|
+
}
|
|
87629
|
+
});
|
|
87630
|
+
|
|
87571
87631
|
// src/plugins/hover.ts
|
|
87572
87632
|
function getHoverInfo(uri, position, workspace) {
|
|
87573
87633
|
const doc = workspace.markup.get(uri);
|
|
@@ -87596,7 +87656,7 @@ function getMacroHover(passage, at3, workspace) {
|
|
|
87596
87656
|
return { contents: parts.join("\n"), range: range2 };
|
|
87597
87657
|
}
|
|
87598
87658
|
const widget = workspace.widgets.getWidget(macro.name);
|
|
87599
|
-
if (widget) return buildWidgetHover(widget, range2);
|
|
87659
|
+
if (widget && macroHeadAt(passage.doc, passage.position(at3))?.invocation) return buildWidgetHover(widget, range2);
|
|
87600
87660
|
}
|
|
87601
87661
|
return null;
|
|
87602
87662
|
}
|
|
@@ -87636,6 +87696,7 @@ var init_hover = __esm({
|
|
|
87636
87696
|
"use strict";
|
|
87637
87697
|
init_text();
|
|
87638
87698
|
init_tokens();
|
|
87699
|
+
init_macro_heads();
|
|
87639
87700
|
init_markup_symbols();
|
|
87640
87701
|
VARIABLE_KINDS = {
|
|
87641
87702
|
$: "Story variable",
|
|
@@ -87773,6 +87834,7 @@ ${p.documentation}`) : []
|
|
|
87773
87834
|
activeParameter: positional ? argument : 0
|
|
87774
87835
|
};
|
|
87775
87836
|
}
|
|
87837
|
+
if (enclosing.invocation === false) return null;
|
|
87776
87838
|
const widget = workspace.widgets.getWidget(macroName);
|
|
87777
87839
|
if (widget && widget.params.length > 0) {
|
|
87778
87840
|
const paramLabels = widget.params;
|
|
@@ -87836,65 +87898,6 @@ var init_signature = __esm({
|
|
|
87836
87898
|
}
|
|
87837
87899
|
});
|
|
87838
87900
|
|
|
87839
|
-
// src/core/markup/macro-heads.ts
|
|
87840
|
-
function* pairedHeads(paired, tokens2) {
|
|
87841
|
-
const unclosed = [];
|
|
87842
|
-
for (const node2 of walkNodes(paired.nodes)) {
|
|
87843
|
-
if (node2.token.type === "macro") yield { name: node2.token.name, closing: false, opener: node2.token.start, start: node2.token.nameStart, end: node2.token.nameEnd };
|
|
87844
|
-
for (const branch of node2.body?.branches ?? []) {
|
|
87845
|
-
yield { name: branch.tag.name, closing: false, opener: branch.tag.start, start: branch.tag.nameStart, end: branch.tag.nameEnd };
|
|
87846
|
-
}
|
|
87847
|
-
const close = node2.body?.close;
|
|
87848
|
-
if (node2.token.type !== "macro") continue;
|
|
87849
|
-
if (close?.type === "macro" && close.name.toLowerCase() === node2.token.name.toLowerCase()) {
|
|
87850
|
-
yield { name: close.name, closing: true, opener: node2.token.start, start: close.nameStart, end: close.nameEnd };
|
|
87851
|
-
} else if (node2.body && !close) {
|
|
87852
|
-
unclosed.push({ name: node2.token.name.toLowerCase(), start: node2.token.start });
|
|
87853
|
-
}
|
|
87854
|
-
}
|
|
87855
|
-
const byStart = new Map(tokens2.map((token) => [token.start, token]));
|
|
87856
|
-
for (const error62 of paired.errors) {
|
|
87857
|
-
const token = byStart.get(error62.start);
|
|
87858
|
-
if (error62.code !== "stray-closer" || token?.type !== "macro" || !token.isClose) continue;
|
|
87859
|
-
const name = token.name.toLowerCase();
|
|
87860
|
-
const open2 = unclosed.find((open3) => open3.name === name && open3.start < error62.start);
|
|
87861
|
-
if (open2) {
|
|
87862
|
-
yield { name: token.name, closing: true, opener: open2.start, start: token.nameStart, end: token.nameEnd };
|
|
87863
|
-
}
|
|
87864
|
-
}
|
|
87865
|
-
}
|
|
87866
|
-
function passageMacroHeads(passage) {
|
|
87867
|
-
let heads = kept2.get(passage);
|
|
87868
|
-
if (heads) return heads;
|
|
87869
|
-
const isBlock = (name) => passage.doc.context.isBlock(name);
|
|
87870
|
-
const found = [...pairedHeads(passage.pairing, passage.tokens)];
|
|
87871
|
-
for (const piece of passage.pieces) {
|
|
87872
|
-
if (piece.kind !== "text") continue;
|
|
87873
|
-
found.push(...pairedHeads(pairMarkup(piece.tokens, { isBlock }), piece.tokens));
|
|
87874
|
-
}
|
|
87875
|
-
const invocations = new Set(passage.invocations.map((token) => token.start));
|
|
87876
|
-
heads = found.sort((a, b) => a.start - b.start).map(({ opener, ...head }) => ({ ...head, invocation: invocations.has(opener), passage, range: passage.range(head.start, head.end) }));
|
|
87877
|
-
kept2.set(passage, heads);
|
|
87878
|
-
return heads;
|
|
87879
|
-
}
|
|
87880
|
-
function documentMacroHeads(doc) {
|
|
87881
|
-
return doc.passages.flatMap((passage) => passage.isMarkup ? [...passageMacroHeads(passage)] : []);
|
|
87882
|
-
}
|
|
87883
|
-
function macroHeadAt(doc, position) {
|
|
87884
|
-
const passage = doc.passageAt(position);
|
|
87885
|
-
if (!passage?.isMarkup) return void 0;
|
|
87886
|
-
return passageMacroHeads(passage).find(({ range: { start, end } }) => start.line === position.line && position.character >= start.character && position.character <= end.character);
|
|
87887
|
-
}
|
|
87888
|
-
var kept2;
|
|
87889
|
-
var init_macro_heads = __esm({
|
|
87890
|
-
"src/core/markup/macro-heads.ts"() {
|
|
87891
|
-
"use strict";
|
|
87892
|
-
init_tooling();
|
|
87893
|
-
init_tree();
|
|
87894
|
-
kept2 = /* @__PURE__ */ new WeakMap();
|
|
87895
|
-
}
|
|
87896
|
-
});
|
|
87897
|
-
|
|
87898
87901
|
// src/plugins/definition.ts
|
|
87899
87902
|
function getDefinition(uri, position, workspace) {
|
|
87900
87903
|
const text3 = workspace.documents.getText(uri);
|
|
@@ -88570,7 +88573,7 @@ function computeInlayHints(uri, range2, workspace) {
|
|
|
88570
88573
|
function addWidgetParamHints(passages, inRange, workspace, hints) {
|
|
88571
88574
|
if (workspace.widgets.getAllWidgets().length === 0) return;
|
|
88572
88575
|
for (const passage of passages) {
|
|
88573
|
-
for (const token of
|
|
88576
|
+
for (const token of passage.invocations) {
|
|
88574
88577
|
if (token.isClose || token.rawArgs === "") continue;
|
|
88575
88578
|
if (!inRange(passage.position(token.start).line)) continue;
|
|
88576
88579
|
if (workspace.getEffectiveMacro(token.name)) continue;
|
|
@@ -88609,7 +88612,6 @@ var init_inlay_hints = __esm({
|
|
|
88609
88612
|
"use strict";
|
|
88610
88613
|
init_tooling();
|
|
88611
88614
|
init_source_view();
|
|
88612
|
-
init_tokens();
|
|
88613
88615
|
inlayHintsPlugin = {
|
|
88614
88616
|
id: "inlay-hints",
|
|
88615
88617
|
capabilities: {
|