spark-html-language-server 0.1.1 → 0.1.2
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/package.json +1 -1
- package/src/analyze.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-html-language-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Language server (LSP) for spark-html single-file components — diagnostics (undefined bindings, unused imports, script errors, missing key), go-to-definition for component imports and symbols, prop autocomplete from export let, and hover docs for every directive. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/analyze.js
CHANGED
|
@@ -343,11 +343,15 @@ function analyzeTemplate(text, tpl) {
|
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
// <template await="expr"> — `await` is in scope inside (then/catch included)
|
|
346
|
+
// <template await="expr"> — `await` is in scope inside (then/catch included),
|
|
347
|
+
// and an `as="user"` alias binds that name inside the block too.
|
|
347
348
|
const awaitRe = /<template\b[^>]*\bawait\s*=\s*"([^"]*)"/gi;
|
|
348
349
|
while ((m = awaitRe.exec(tpl)) !== null) {
|
|
349
350
|
const content = templateContentRange(tpl, m.index);
|
|
350
|
-
|
|
351
|
+
const tagEnd = tpl.indexOf('>', m.index);
|
|
352
|
+
const tag = tpl.slice(m.index, tagEnd === -1 ? tpl.length : tagEnd);
|
|
353
|
+
const asName = tag.match(/\bas\s*=\s*"\s*([A-Za-z_$][\w$]*)\s*"/)?.[1] || null;
|
|
354
|
+
if (content) awaitBlocks.push({ content, asName });
|
|
351
355
|
let expr = m[1];
|
|
352
356
|
let exprOffset = m.index + m[0].length - m[1].length - 1;
|
|
353
357
|
const once = expr.match(/^once\(([\s\S]*)\)$/);
|
|
@@ -421,6 +425,11 @@ export function analyze(text) {
|
|
|
421
425
|
if (b.content && offset < b.content.start && offset >= b.attrOffset &&
|
|
422
426
|
(name === b.itemVar || name === b.indexVar)) return true;
|
|
423
427
|
}
|
|
428
|
+
// <template await … as="user"> binds the alias inside the block.
|
|
429
|
+
for (const b of t.awaitBlocks) {
|
|
430
|
+
if (b.asName === name && b.content &&
|
|
431
|
+
offset >= b.content.start && offset < b.content.end) return true;
|
|
432
|
+
}
|
|
424
433
|
return false;
|
|
425
434
|
};
|
|
426
435
|
|