@rohal12/spindle-lsp 0.15.35 → 0.15.37
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 +73 -74
- 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.37";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -33812,9 +33812,6 @@ var init_widget_registry = __esm({
|
|
|
33812
33812
|
});
|
|
33813
33813
|
|
|
33814
33814
|
// src/core/markup/markup-index.ts
|
|
33815
|
-
function sameHeaders(a, b) {
|
|
33816
|
-
return a.length === b.length && a.every((p, i2) => p === b[i2]);
|
|
33817
|
-
}
|
|
33818
33815
|
var MarkupIndex;
|
|
33819
33816
|
var init_markup_index = __esm({
|
|
33820
33817
|
"src/core/markup/markup-index.ts"() {
|
|
@@ -33833,10 +33830,10 @@ var init_markup_index = __esm({
|
|
|
33833
33830
|
if (text3 === void 0) return void 0;
|
|
33834
33831
|
const kept3 = this.cache.get(uri);
|
|
33835
33832
|
const passages = this.sources.passages(uri);
|
|
33836
|
-
if (kept3 && kept3.text === text3 &&
|
|
33833
|
+
if (kept3 && kept3.markup.text === text3 && (kept3.headers === passages || kept3.headers.length === 0 && passages.length === 0)) return kept3.markup;
|
|
33837
33834
|
this.context ??= this.sources.context();
|
|
33838
33835
|
const fresh = new DocumentMarkup(uri, text3, passages, this.context);
|
|
33839
|
-
this.cache.set(uri, fresh);
|
|
33836
|
+
this.cache.set(uri, { markup: fresh, headers: passages });
|
|
33840
33837
|
return fresh;
|
|
33841
33838
|
}
|
|
33842
33839
|
/** The macros or widgets changed: every document's markup is read again on demand. */
|
|
@@ -35198,12 +35195,14 @@ function computeDiagnostics(uri, workspace, options) {
|
|
|
35198
35195
|
const story = storyReport(workspace);
|
|
35199
35196
|
diagnostics.push(...story.metadata.get(doc) ?? []);
|
|
35200
35197
|
const effective = new Set(workspace.passages.getEffectivePassages());
|
|
35198
|
+
let passageNames;
|
|
35199
|
+
const getPassageNames = () => passageNames ??= [...effective].filter(isRuntimePassage).map((passage) => passage.name);
|
|
35201
35200
|
for (const passage of doc.passages) {
|
|
35202
35201
|
if (!effective.has(passage.passage)) continue;
|
|
35203
35202
|
attempt(() => diagnostics.push(...markupDiagnostics(passage, story, workspace)));
|
|
35204
35203
|
attempt(() => diagnostics.push(...variableDiagnostics(passage, story)));
|
|
35205
35204
|
attempt(() => diagnostics.push(...structureDiagnostics(passage, workspace)));
|
|
35206
|
-
attempt(() => diagnostics.push(...argumentDiagnostics(passage, workspace)));
|
|
35205
|
+
attempt(() => diagnostics.push(...argumentDiagnostics(passage, workspace, getPassageNames)));
|
|
35207
35206
|
attempt(() => diagnostics.push(...widgetDiagnostics(passage, story, workspace)));
|
|
35208
35207
|
}
|
|
35209
35208
|
attempt(() => diagnostics.push(...versionDiagnostics(uri, doc, workspace)));
|
|
@@ -35656,9 +35655,8 @@ function isReadInBody(passage, bodyStart, bodyEnd, name, macroStart, macroEnd) {
|
|
|
35656
35655
|
}
|
|
35657
35656
|
return false;
|
|
35658
35657
|
}
|
|
35659
|
-
function argumentDiagnostics(passage, workspace) {
|
|
35658
|
+
function argumentDiagnostics(passage, workspace, getPassageNames) {
|
|
35660
35659
|
const diagnostics = [];
|
|
35661
|
-
const passageNames = workspace.passages.getEffectivePassages().filter(isRuntimePassage).map((candidate) => candidate.name);
|
|
35662
35660
|
for (const token of passage.isMarkup ? macroTokens(passage) : []) {
|
|
35663
35661
|
if (token.type !== "macro" || token.isClose) continue;
|
|
35664
35662
|
const info = workspace.getEffectiveMacro(token.name);
|
|
@@ -35678,7 +35676,7 @@ function argumentDiagnostics(passage, workspace) {
|
|
|
35678
35676
|
}
|
|
35679
35677
|
continue;
|
|
35680
35678
|
}
|
|
35681
|
-
const result2 = params.validate(args2, { passages:
|
|
35679
|
+
const result2 = params.validate(args2, { passages: getPassageNames() });
|
|
35682
35680
|
if (result2.variantIndex === null) continue;
|
|
35683
35681
|
for (const error62 of result2.errors) {
|
|
35684
35682
|
const code = error62.message.startsWith("Too many arguments") ? DiagnosticCode.TooManyArguments : DiagnosticCode.ParameterTypeError;
|
|
@@ -87266,7 +87264,7 @@ var init_markup_cursor = __esm({
|
|
|
87266
87264
|
const found = [];
|
|
87267
87265
|
for (const token of region.tokens) {
|
|
87268
87266
|
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)) : "" });
|
|
87267
|
+
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
87268
|
}
|
|
87271
87269
|
for (const error62 of region.errors) {
|
|
87272
87270
|
const source = region.view.text;
|
|
@@ -87276,7 +87274,7 @@ var init_markup_cursor = __esm({
|
|
|
87276
87274
|
if (name && name[0] !== "/") found.push({ start: error62.offset, name, argsBefore: source.slice(end, viewIndex(region.view, at3)).trimStart() });
|
|
87277
87275
|
}
|
|
87278
87276
|
const innermost = found.filter((macro) => known(macro.name)).sort((a, b) => b.start - a.start)[0];
|
|
87279
|
-
if (innermost) return
|
|
87277
|
+
if (innermost) return innermost;
|
|
87280
87278
|
}
|
|
87281
87279
|
return void 0;
|
|
87282
87280
|
}
|
|
@@ -87568,6 +87566,65 @@ var init_completions = __esm({
|
|
|
87568
87566
|
}
|
|
87569
87567
|
});
|
|
87570
87568
|
|
|
87569
|
+
// src/core/markup/macro-heads.ts
|
|
87570
|
+
function* pairedHeads(paired, tokens2) {
|
|
87571
|
+
const unclosed = [];
|
|
87572
|
+
for (const node2 of walkNodes(paired.nodes)) {
|
|
87573
|
+
if (node2.token.type === "macro") yield { name: node2.token.name, closing: false, opener: node2.token.start, start: node2.token.nameStart, end: node2.token.nameEnd };
|
|
87574
|
+
for (const branch of node2.body?.branches ?? []) {
|
|
87575
|
+
yield { name: branch.tag.name, closing: false, opener: branch.tag.start, start: branch.tag.nameStart, end: branch.tag.nameEnd };
|
|
87576
|
+
}
|
|
87577
|
+
const close = node2.body?.close;
|
|
87578
|
+
if (node2.token.type !== "macro") continue;
|
|
87579
|
+
if (close?.type === "macro" && close.name.toLowerCase() === node2.token.name.toLowerCase()) {
|
|
87580
|
+
yield { name: close.name, closing: true, opener: node2.token.start, start: close.nameStart, end: close.nameEnd };
|
|
87581
|
+
} else if (node2.body && !close) {
|
|
87582
|
+
unclosed.push({ name: node2.token.name.toLowerCase(), start: node2.token.start });
|
|
87583
|
+
}
|
|
87584
|
+
}
|
|
87585
|
+
const byStart = new Map(tokens2.map((token) => [token.start, token]));
|
|
87586
|
+
for (const error62 of paired.errors) {
|
|
87587
|
+
const token = byStart.get(error62.start);
|
|
87588
|
+
if (error62.code !== "stray-closer" || token?.type !== "macro" || !token.isClose) continue;
|
|
87589
|
+
const name = token.name.toLowerCase();
|
|
87590
|
+
const open2 = unclosed.find((open3) => open3.name === name && open3.start < error62.start);
|
|
87591
|
+
if (open2) {
|
|
87592
|
+
yield { name: token.name, closing: true, opener: open2.start, start: token.nameStart, end: token.nameEnd };
|
|
87593
|
+
}
|
|
87594
|
+
}
|
|
87595
|
+
}
|
|
87596
|
+
function passageMacroHeads(passage) {
|
|
87597
|
+
let heads = kept2.get(passage);
|
|
87598
|
+
if (heads) return heads;
|
|
87599
|
+
const isBlock = (name) => passage.doc.context.isBlock(name);
|
|
87600
|
+
const found = [...pairedHeads(passage.pairing, passage.tokens)];
|
|
87601
|
+
for (const piece of passage.pieces) {
|
|
87602
|
+
if (piece.kind !== "text") continue;
|
|
87603
|
+
found.push(...pairedHeads(pairMarkup(piece.tokens, { isBlock }), piece.tokens));
|
|
87604
|
+
}
|
|
87605
|
+
const invocations = new Set(passage.invocations.map((token) => token.start));
|
|
87606
|
+
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) }));
|
|
87607
|
+
kept2.set(passage, heads);
|
|
87608
|
+
return heads;
|
|
87609
|
+
}
|
|
87610
|
+
function documentMacroHeads(doc) {
|
|
87611
|
+
return doc.passages.flatMap((passage) => passage.isMarkup ? [...passageMacroHeads(passage)] : []);
|
|
87612
|
+
}
|
|
87613
|
+
function macroHeadAt(doc, position) {
|
|
87614
|
+
const passage = doc.passageAt(position);
|
|
87615
|
+
if (!passage?.isMarkup) return void 0;
|
|
87616
|
+
return passageMacroHeads(passage).find(({ range: { start, end } }) => start.line === position.line && position.character >= start.character && position.character <= end.character);
|
|
87617
|
+
}
|
|
87618
|
+
var kept2;
|
|
87619
|
+
var init_macro_heads = __esm({
|
|
87620
|
+
"src/core/markup/macro-heads.ts"() {
|
|
87621
|
+
"use strict";
|
|
87622
|
+
init_tooling();
|
|
87623
|
+
init_tree();
|
|
87624
|
+
kept2 = /* @__PURE__ */ new WeakMap();
|
|
87625
|
+
}
|
|
87626
|
+
});
|
|
87627
|
+
|
|
87571
87628
|
// src/plugins/hover.ts
|
|
87572
87629
|
function getHoverInfo(uri, position, workspace) {
|
|
87573
87630
|
const doc = workspace.markup.get(uri);
|
|
@@ -87596,7 +87653,7 @@ function getMacroHover(passage, at3, workspace) {
|
|
|
87596
87653
|
return { contents: parts.join("\n"), range: range2 };
|
|
87597
87654
|
}
|
|
87598
87655
|
const widget = workspace.widgets.getWidget(macro.name);
|
|
87599
|
-
if (widget) return buildWidgetHover(widget, range2);
|
|
87656
|
+
if (widget && macroHeadAt(passage.doc, passage.position(at3))?.invocation) return buildWidgetHover(widget, range2);
|
|
87600
87657
|
}
|
|
87601
87658
|
return null;
|
|
87602
87659
|
}
|
|
@@ -87636,6 +87693,7 @@ var init_hover = __esm({
|
|
|
87636
87693
|
"use strict";
|
|
87637
87694
|
init_text();
|
|
87638
87695
|
init_tokens();
|
|
87696
|
+
init_macro_heads();
|
|
87639
87697
|
init_markup_symbols();
|
|
87640
87698
|
VARIABLE_KINDS = {
|
|
87641
87699
|
$: "Story variable",
|
|
@@ -87773,6 +87831,7 @@ ${p.documentation}`) : []
|
|
|
87773
87831
|
activeParameter: positional ? argument : 0
|
|
87774
87832
|
};
|
|
87775
87833
|
}
|
|
87834
|
+
if (enclosing.invocation === false) return null;
|
|
87776
87835
|
const widget = workspace.widgets.getWidget(macroName);
|
|
87777
87836
|
if (widget && widget.params.length > 0) {
|
|
87778
87837
|
const paramLabels = widget.params;
|
|
@@ -87836,65 +87895,6 @@ var init_signature = __esm({
|
|
|
87836
87895
|
}
|
|
87837
87896
|
});
|
|
87838
87897
|
|
|
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
87898
|
// src/plugins/definition.ts
|
|
87899
87899
|
function getDefinition(uri, position, workspace) {
|
|
87900
87900
|
const text3 = workspace.documents.getText(uri);
|
|
@@ -88570,7 +88570,7 @@ function computeInlayHints(uri, range2, workspace) {
|
|
|
88570
88570
|
function addWidgetParamHints(passages, inRange, workspace, hints) {
|
|
88571
88571
|
if (workspace.widgets.getAllWidgets().length === 0) return;
|
|
88572
88572
|
for (const passage of passages) {
|
|
88573
|
-
for (const token of
|
|
88573
|
+
for (const token of passage.invocations) {
|
|
88574
88574
|
if (token.isClose || token.rawArgs === "") continue;
|
|
88575
88575
|
if (!inRange(passage.position(token.start).line)) continue;
|
|
88576
88576
|
if (workspace.getEffectiveMacro(token.name)) continue;
|
|
@@ -88609,7 +88609,6 @@ var init_inlay_hints = __esm({
|
|
|
88609
88609
|
"use strict";
|
|
88610
88610
|
init_tooling();
|
|
88611
88611
|
init_source_view();
|
|
88612
|
-
init_tokens();
|
|
88613
88612
|
inlayHintsPlugin = {
|
|
88614
88613
|
id: "inlay-hints",
|
|
88615
88614
|
capabilities: {
|