@azerothjs/language-service 0.4.0-beta.1

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.
Files changed (98) hide show
  1. package/README.md +259 -0
  2. package/dist/html-source.d.ts +12 -0
  3. package/dist/html-source.d.ts.map +1 -0
  4. package/dist/html-source.js +108 -0
  5. package/dist/html-source.js.map +1 -0
  6. package/dist/index.d.ts +12 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +29 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/language-data.d.ts +41 -0
  11. package/dist/language-data.d.ts.map +1 -0
  12. package/dist/language-data.js +164 -0
  13. package/dist/language-data.js.map +1 -0
  14. package/dist/mapping.d.ts +71 -0
  15. package/dist/mapping.d.ts.map +1 -0
  16. package/dist/mapping.js +123 -0
  17. package/dist/mapping.js.map +1 -0
  18. package/dist/markup-model.d.ts +67 -0
  19. package/dist/markup-model.d.ts.map +1 -0
  20. package/dist/markup-model.js +313 -0
  21. package/dist/markup-model.js.map +1 -0
  22. package/dist/protocol.d.ts +176 -0
  23. package/dist/protocol.d.ts.map +1 -0
  24. package/dist/protocol.js +58 -0
  25. package/dist/protocol.js.map +1 -0
  26. package/dist/providers/completion.d.ts +26 -0
  27. package/dist/providers/completion.d.ts.map +1 -0
  28. package/dist/providers/completion.js +339 -0
  29. package/dist/providers/completion.js.map +1 -0
  30. package/dist/providers/css-service.d.ts +7 -0
  31. package/dist/providers/css-service.d.ts.map +1 -0
  32. package/dist/providers/css-service.js +84 -0
  33. package/dist/providers/css-service.js.map +1 -0
  34. package/dist/providers/diagnostics.d.ts +5 -0
  35. package/dist/providers/diagnostics.d.ts.map +1 -0
  36. package/dist/providers/diagnostics.js +89 -0
  37. package/dist/providers/diagnostics.js.map +1 -0
  38. package/dist/providers/editing.d.ts +17 -0
  39. package/dist/providers/editing.d.ts.map +1 -0
  40. package/dist/providers/editing.js +176 -0
  41. package/dist/providers/editing.js.map +1 -0
  42. package/dist/providers/hover.d.ts +5 -0
  43. package/dist/providers/hover.d.ts.map +1 -0
  44. package/dist/providers/hover.js +213 -0
  45. package/dist/providers/hover.js.map +1 -0
  46. package/dist/providers/html-service.d.ts +8 -0
  47. package/dist/providers/html-service.d.ts.map +1 -0
  48. package/dist/providers/html-service.js +108 -0
  49. package/dist/providers/html-service.js.map +1 -0
  50. package/dist/providers/inlay-hints.d.ts +25 -0
  51. package/dist/providers/inlay-hints.d.ts.map +1 -0
  52. package/dist/providers/inlay-hints.js +52 -0
  53. package/dist/providers/inlay-hints.js.map +1 -0
  54. package/dist/providers/navigation.d.ts +16 -0
  55. package/dist/providers/navigation.d.ts.map +1 -0
  56. package/dist/providers/navigation.js +107 -0
  57. package/dist/providers/navigation.js.map +1 -0
  58. package/dist/providers/semantic-tokens.d.ts +5 -0
  59. package/dist/providers/semantic-tokens.d.ts.map +1 -0
  60. package/dist/providers/semantic-tokens.js +63 -0
  61. package/dist/providers/semantic-tokens.js.map +1 -0
  62. package/dist/providers/signature.d.ts +5 -0
  63. package/dist/providers/signature.d.ts.map +1 -0
  64. package/dist/providers/signature.js +38 -0
  65. package/dist/providers/signature.js.map +1 -0
  66. package/dist/providers/structure.d.ts +19 -0
  67. package/dist/providers/structure.d.ts.map +1 -0
  68. package/dist/providers/structure.js +188 -0
  69. package/dist/providers/structure.js.map +1 -0
  70. package/dist/providers/symbols.d.ts +8 -0
  71. package/dist/providers/symbols.d.ts.map +1 -0
  72. package/dist/providers/symbols.js +108 -0
  73. package/dist/providers/symbols.js.map +1 -0
  74. package/dist/request.d.ts +37 -0
  75. package/dist/request.d.ts.map +1 -0
  76. package/dist/request.js +49 -0
  77. package/dist/request.js.map +1 -0
  78. package/dist/service.d.ts +73 -0
  79. package/dist/service.d.ts.map +1 -0
  80. package/dist/service.js +177 -0
  81. package/dist/service.js.map +1 -0
  82. package/dist/text.d.ts +25 -0
  83. package/dist/text.d.ts.map +1 -0
  84. package/dist/text.js +66 -0
  85. package/dist/text.js.map +1 -0
  86. package/dist/ts-project.d.ts +75 -0
  87. package/dist/ts-project.d.ts.map +1 -0
  88. package/dist/ts-project.js +266 -0
  89. package/dist/ts-project.js.map +1 -0
  90. package/dist/uri.d.ts +21 -0
  91. package/dist/uri.d.ts.map +1 -0
  92. package/dist/uri.js +41 -0
  93. package/dist/uri.js.map +1 -0
  94. package/dist/virtual-code.d.ts +27 -0
  95. package/dist/virtual-code.d.ts.map +1 -0
  96. package/dist/virtual-code.js +360 -0
  97. package/dist/virtual-code.js.map +1 -0
  98. package/package.json +61 -0
@@ -0,0 +1,8 @@
1
+ import { type CompletionItem, type Hover, type Position } from '../protocol.ts';
2
+ /** Host-element completion (tags / attributes / attribute values) with docs. */
3
+ export declare function htmlCompletions(source: string, position: Position): CompletionItem[];
4
+ /** MDN-backed hover for a host element / attribute / value. */
5
+ export declare function htmlHover(source: string, position: Position): Hover | null;
6
+ /** MDN documentation for a camelCase DOM event (`onClick`), or undefined. */
7
+ export declare function eventDocumentation(camelName: string): string | undefined;
8
+ //# sourceMappingURL=html-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-service.d.ts","sourceRoot":"","sources":["../../src/providers/html-service.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEH,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,QAAQ,EAEhB,MAAM,gBAAgB,CAAC;AAqBxB,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,cAAc,EAAE,CAKpF;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAY1E;AA8BD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxE"}
@@ -0,0 +1,108 @@
1
+ // Thin wrapper over `vscode-html-languageservice` - the same HTML engine VS
2
+ // Code ships - applied to the embedded HTML view of a `.azeroth` file
3
+ // (html-source.ts). It answers host-element completion (tags, attributes, and
4
+ // crucially attribute *values* like `<input type="…">`) and MDN-backed hover.
5
+ //
6
+ // Offsets are shared with the original source (the embedded view is space-for-
7
+ // space the same length), so positions and result ranges need no translation.
8
+ // The AzerothJS-specific layer - built-in components, camelCase events,
9
+ // component prop types - is added by the completion/hover providers on top of
10
+ // what this returns.
11
+ import { getLanguageService, getDefaultHTMLDataProvider } from 'vscode-html-languageservice';
12
+ import { TextDocument } from 'vscode-languageserver-textdocument';
13
+ import { generateHtmlSource } from "../html-source.js";
14
+ import { CompletionItemKind } from "../protocol.js";
15
+ let service = null;
16
+ const html = () => (service ??= getLanguageService());
17
+ /** Cache the parsed embedded document so completion + hover on the same edit reuse it. */
18
+ let cache = null;
19
+ function embeddedDocument(source) {
20
+ if (cache && cache.source === source) {
21
+ return cache;
22
+ }
23
+ const doc = TextDocument.create('embedded://azeroth.html', 'html', 0, generateHtmlSource(source));
24
+ const parsed = html().parseHTMLDocument(doc);
25
+ cache = { source, doc, parsed };
26
+ return cache;
27
+ }
28
+ /** Host-element completion (tags / attributes / attribute values) with docs. */
29
+ export function htmlCompletions(source, position) {
30
+ const { doc, parsed } = embeddedDocument(source);
31
+ const list = html().doComplete(doc, position, parsed);
32
+ return list.items.map(toCompletionItem);
33
+ }
34
+ /** MDN-backed hover for a host element / attribute / value. */
35
+ export function htmlHover(source, position) {
36
+ const { doc, parsed } = embeddedDocument(source);
37
+ const hover = html().doHover(doc, position, parsed);
38
+ if (!hover) {
39
+ return null;
40
+ }
41
+ return {
42
+ contents: markupToString(hover.contents),
43
+ range: hover.range
44
+ };
45
+ }
46
+ /**
47
+ * MDN documentation (description + reference links) for a DOM event, keyed by
48
+ * AzerothJS's camelCase name. The HTML data stores events lowercase
49
+ * (`onclick`), so `onClick` is matched case-insensitively - giving the same
50
+ * MDN docs the HTML engine shows for the lowercase form.
51
+ */
52
+ let eventDocs = null;
53
+ function buildEventDocs() {
54
+ const map = new Map();
55
+ for (const attr of getDefaultHTMLDataProvider().provideAttributes('div')) {
56
+ if (!/^on/i.test(attr.name)) {
57
+ continue;
58
+ }
59
+ const description = markupToString(attr.description);
60
+ const references = (attr.references ?? []).map(reference => `[${reference.name}](${reference.url})`).join(' · ');
61
+ const markdown = [description, references].filter(Boolean).join('\n\n');
62
+ if (markdown) {
63
+ map.set(attr.name.toLowerCase(), markdown);
64
+ }
65
+ }
66
+ return map;
67
+ }
68
+ /** MDN documentation for a camelCase DOM event (`onClick`), or undefined. */
69
+ export function eventDocumentation(camelName) {
70
+ eventDocs ??= buildEventDocs();
71
+ return eventDocs.get(camelName.toLowerCase());
72
+ }
73
+ /** Maps an HTML-service completion entry to our protocol's CompletionItem. */
74
+ function toCompletionItem(item) {
75
+ const insertText = item.textEdit && 'newText' in item.textEdit
76
+ ? item.textEdit.newText
77
+ : item.insertText ?? item.label;
78
+ return {
79
+ label: item.label,
80
+ kind: (item.kind ?? CompletionItemKind.Property),
81
+ detail: item.detail,
82
+ documentation: markupToString(item.documentation),
83
+ insertText,
84
+ insertTextFormat: item.insertTextFormat ?? 1,
85
+ sortText: item.sortText,
86
+ filterText: item.filterText
87
+ };
88
+ }
89
+ /** Flattens the HTML service's documentation/hover content into Markdown. */
90
+ function markupToString(content) {
91
+ if (content === undefined) {
92
+ return '';
93
+ }
94
+ if (typeof content === 'string') {
95
+ return content;
96
+ }
97
+ if (Array.isArray(content)) {
98
+ return content.map(markupToString).join('\n\n');
99
+ }
100
+ if ('kind' in content) {
101
+ return content.value;
102
+ }
103
+ if ('value' in content) {
104
+ return content.value;
105
+ }
106
+ return '';
107
+ }
108
+ //# sourceMappingURL=html-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-service.js","sourceRoot":"","sources":["../../src/providers/html-service.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,sEAAsE;AACtE,8EAA8E;AAC9E,8EAA8E;AAC9E,EAAE;AACF,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AC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,EACrB,CAAC;QACG,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,OAAO,IAAI,OAAO,EACtB,CAAC;QACG,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { InlayHint, Range } from '../protocol.ts';
2
+ import type { RequestContext } from '../request.ts';
3
+ /**
4
+ * Which inlay-hint families to show. Mirrors VS Code's TypeScript settings so
5
+ * the editor can enable/disable each kind. All on by default.
6
+ */
7
+ export interface InlayHintOptions {
8
+ /** Master switch; when false, no hints are produced. */
9
+ enabled?: boolean;
10
+ /** Parameter-name hints at call sites. */
11
+ parameterNames?: 'none' | 'literals' | 'all';
12
+ /** Inferred types for un-annotated function parameters. */
13
+ parameterTypes?: boolean;
14
+ /** Inferred types for `const`/`let` declarations. */
15
+ variableTypes?: boolean;
16
+ /** Inferred types for class property declarations. */
17
+ propertyDeclarationTypes?: boolean;
18
+ /** Inferred return types for functions. */
19
+ functionLikeReturnTypes?: boolean;
20
+ /** Computed values for enum members. */
21
+ enumMemberValues?: boolean;
22
+ }
23
+ /** Inlay hints for the requested range, honouring the family toggles. */
24
+ export declare function getInlayHints(ctx: RequestContext, range: Range, options?: InlayHintOptions): InlayHint[];
25
+ //# sourceMappingURL=inlay-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlay-hints.d.ts","sourceRoot":"","sources":["../../src/providers/inlay-hints.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAE7B,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;IAC7C,2DAA2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qDAAqD;IACrD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,2CAA2C;IAC3C,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAiBD,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS,EAAE,CA2C5G"}
@@ -0,0 +1,52 @@
1
+ // Inlay hints - the inline parameter-name and inferred-type annotations TS
2
+ // shows (`createSignal(initialValue: 0)`, `const x: number = …`). A direct
3
+ // TypeScript query over the virtual module, with each hint's position mapped
4
+ // back to the original source and filtered to the requested range. Hints that
5
+ // land in generated scaffolding (which has no original position) are dropped.
6
+ import ts from 'typescript';
7
+ /** Builds TypeScript preferences from the family toggles (defaults: all on). */
8
+ function buildPreferences(options) {
9
+ return {
10
+ includeInlayParameterNameHints: options.parameterNames ?? 'all',
11
+ includeInlayParameterNameHintsWhenArgumentMatchesName: false,
12
+ includeInlayFunctionParameterTypeHints: options.parameterTypes ?? true,
13
+ includeInlayVariableTypeHints: options.variableTypes ?? true,
14
+ includeInlayVariableTypeHintsWhenTypeMatchesName: false,
15
+ includeInlayPropertyDeclarationTypeHints: options.propertyDeclarationTypes ?? true,
16
+ includeInlayFunctionLikeReturnTypeHints: options.functionLikeReturnTypes ?? true,
17
+ includeInlayEnumMemberValueHints: options.enumMemberValues ?? true
18
+ };
19
+ }
20
+ /** Inlay hints for the requested range, honouring the family toggles. */
21
+ export function getInlayHints(ctx, range, options = {}) {
22
+ if (options.enabled === false) {
23
+ return [];
24
+ }
25
+ const rangeStart = ctx.lineIndex.offsetAt(range.start);
26
+ const rangeEnd = ctx.lineIndex.offsetAt(range.end);
27
+ let hints;
28
+ try {
29
+ // Compute over the whole module, then map/filter - the generated offsets
30
+ // don't line up with the requested range, so we can't pass it through.
31
+ hints = ctx.project.service.provideInlayHints(ctx.virtualFile, { start: 0, length: ctx.virtual.code.length }, buildPreferences(options));
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ const out = [];
37
+ for (const hint of hints) {
38
+ const original = ctx.virtual.mapping.toOriginal(hint.position);
39
+ if (original === null || original < rangeStart || original > rangeEnd) {
40
+ continue;
41
+ }
42
+ out.push({
43
+ position: ctx.lineIndex.positionAt(original),
44
+ label: hint.text,
45
+ kind: hint.kind === ts.InlayHintKind.Type ? 1 : hint.kind === ts.InlayHintKind.Parameter ? 2 : undefined,
46
+ paddingLeft: hint.whitespaceBefore,
47
+ paddingRight: hint.whitespaceAfter
48
+ });
49
+ }
50
+ return out;
51
+ }
52
+ //# sourceMappingURL=inlay-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlay-hints.js","sourceRoot":"","sources":["../../src/providers/inlay-hints.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAE9E,OAAO,EAAE,MAAM,YAAY,CAAC;AA0B5B,gFAAgF;AAChF,SAAS,gBAAgB,CAAC,OAAyB;IAE/C,OAAO;QACH,8BAA8B,EAAE,OAAO,CAAC,cAAc,IAAI,KAAK;QAC/D,qDAAqD,EAAE,KAAK;QAC5D,sCAAsC,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;QACtE,6BAA6B,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;QAC5D,gDAAgD,EAAE,KAAK;QACvD,wCAAwC,EAAE,OAAO,CAAC,wBAAwB,IAAI,IAAI;QAClF,uCAAuC,EAAE,OAAO,CAAC,uBAAuB,IAAI,IAAI;QAChF,gCAAgC,EAAE,OAAO,C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C,IAAI,KAAK,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YACxG,WAAW,EAAE,IAAI,CAAC,gBAAgB;YAClC,YAAY,EAAE,IAAI,CAAC,eAAe;SACrC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DocumentHighlight, Location, WorkspaceEdit } from '../protocol.ts';
2
+ import { type RequestContext } from '../request.ts';
3
+ /** Definition location(s) for the symbol at `offset`. */
4
+ export declare function getDefinition(ctx: RequestContext, offset: number): Location[];
5
+ /** Type-definition location(s) for the symbol at `offset`. */
6
+ export declare function getTypeDefinition(ctx: RequestContext, offset: number): Location[];
7
+ /** All references to the symbol at `offset`. */
8
+ export declare function getReferences(ctx: RequestContext, offset: number): Location[];
9
+ /** Occurrences of the symbol at `offset` within this document, for highlighting. */
10
+ export declare function getDocumentHighlights(ctx: RequestContext, offset: number): DocumentHighlight[];
11
+ /**
12
+ * Computes the workspace edit to rename the symbol at `offset` to `newName`,
13
+ * or null when the position can't be renamed.
14
+ */
15
+ export declare function getRenameEdits(ctx: RequestContext, offset: number, newName: string): WorkspaceEdit | null;
16
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/providers/navigation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAIH,KAAK,cAAc,EACtB,MAAM,eAAe,CAAC;AAEvB,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAe7E;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAWjF;AAED,gDAAgD;AAChD,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAW7E;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAyB9F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAoCzG"}
@@ -0,0 +1,107 @@
1
+ // Go-to-definition, type-definition, find-references, and rename. All four are
2
+ // pure TypeScript queries against the virtual module, with results translated
3
+ // back to original ranges (in this file or others). Because component tags and
4
+ // every expression identifier are mapped 1:1, jumping from `<Counter/>` to the
5
+ // `Counter` definition, or renaming a signal everywhere it's read inside markup,
6
+ // works exactly as it does in a `.ts` file.
7
+ import ts from 'typescript';
8
+ import { resolveLocation, spanToRange, toGenerated } from "../request.js";
9
+ /** Definition location(s) for the symbol at `offset`. */
10
+ export function getDefinition(ctx, offset) {
11
+ const generated = toGenerated(ctx, offset);
12
+ if (generated === null) {
13
+ return [];
14
+ }
15
+ const result = ctx.project.service.getDefinitionAndBoundSpan(ctx.virtualFile, generated);
16
+ if (!result?.definitions) {
17
+ return [];
18
+ }
19
+ return dedupe(result.definitions
20
+ .map(def => resolveLocation(ctx.project, def.fileName, def.textSpan))
21
+ .filter((loc) => loc !== null));
22
+ }
23
+ /** Type-definition location(s) for the symbol at `offset`. */
24
+ export function getTypeDefinition(ctx, offset) {
25
+ const generated = toGenerated(ctx, offset);
26
+ if (generated === null) {
27
+ return [];
28
+ }
29
+ const defs = ctx.project.service.getTypeDefinitionAtPosition(ctx.virtualFile, generated) ?? [];
30
+ return dedupe(defs
31
+ .map(def => resolveLocation(ctx.project, def.fileName, def.textSpan))
32
+ .filter((loc) => loc !== null));
33
+ }
34
+ /** All references to the symbol at `offset`. */
35
+ export function getReferences(ctx, offset) {
36
+ const generated = toGenerated(ctx, offset);
37
+ if (generated === null) {
38
+ return [];
39
+ }
40
+ const refs = ctx.project.service.getReferencesAtPosition(ctx.virtualFile, generated) ?? [];
41
+ return dedupe(refs
42
+ .map(ref => resolveLocation(ctx.project, ref.fileName, ref.textSpan))
43
+ .filter((loc) => loc !== null));
44
+ }
45
+ /** Occurrences of the symbol at `offset` within this document, for highlighting. */
46
+ export function getDocumentHighlights(ctx, offset) {
47
+ const generated = toGenerated(ctx, offset);
48
+ if (generated === null) {
49
+ return [];
50
+ }
51
+ const highlights = ctx.project.service.getDocumentHighlights(ctx.virtualFile, generated, [ctx.virtualFile]);
52
+ const out = [];
53
+ for (const fileHighlights of highlights ?? []) {
54
+ if (fileHighlights.fileName !== ctx.virtualFile) {
55
+ continue;
56
+ }
57
+ for (const span of fileHighlights.highlightSpans) {
58
+ const range = spanToRange(ctx, span.textSpan);
59
+ if (range !== null) {
60
+ out.push({ range, kind: span.kind === ts.HighlightSpanKind.writtenReference ? 3 : 2 });
61
+ }
62
+ }
63
+ }
64
+ return out;
65
+ }
66
+ /**
67
+ * Computes the workspace edit to rename the symbol at `offset` to `newName`,
68
+ * or null when the position can't be renamed.
69
+ */
70
+ export function getRenameEdits(ctx, offset, newName) {
71
+ const generated = toGenerated(ctx, offset);
72
+ if (generated === null) {
73
+ return null;
74
+ }
75
+ const locations = ctx.project.service.findRenameLocations(ctx.virtualFile, generated, false, false, {});
76
+ if (!locations || locations.length === 0) {
77
+ return null;
78
+ }
79
+ const changes = {};
80
+ for (const location of locations) {
81
+ const resolved = resolveLocation(ctx.project, location.fileName, location.textSpan);
82
+ if (resolved === null) {
83
+ continue;
84
+ }
85
+ const prefix = location.prefixText ?? '';
86
+ const suffix = location.suffixText ?? '';
87
+ (changes[resolved.uri] ??= []).push({
88
+ range: resolved.range,
89
+ newText: `${prefix}${newName}${suffix}`
90
+ });
91
+ }
92
+ return { changes };
93
+ }
94
+ /** Removes duplicate locations (same uri + range). */
95
+ function dedupe(locations) {
96
+ const seen = new Set();
97
+ const out = [];
98
+ for (const loc of locations) {
99
+ const key = `${loc.uri}:${loc.range.start.line}:${loc.range.start.character}:${loc.range.end.line}:${loc.range.end.character}`;
100
+ if (!seen.has(key)) {
101
+ seen.add(key);
102
+ out.push(loc);
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/providers/navigation.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,4CAA4C;AAE5C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EACH,eAAe,EACf,WAAW,EACX,WAAW,EAEd,MAAM,eAAe,CAAC;AAEvB,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,GAAmB,EAAE,MAAc;IAE7D,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3C,IAAI,SAAS,KAAK,IAAI,EACtB,CAAC;QACG,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACzF,IAAI,CAAC,MAAM,EAAE,WAAW,EACxB,CAAC;QACG,OAAO,EAAE,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW;SAC3B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,Q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AK,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAU,IAAK,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAK,IAAK,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,SAAU,EAAE,CAAC;QACzI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAClB,CAAC;YACG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type SemanticTokens } from '../protocol.ts';
2
+ import type { RequestContext } from '../request.ts';
3
+ /** Packed semantic tokens for the markup in the document. */
4
+ export declare function getSemanticTokens(ctx: RequestContext): SemanticTokens;
5
+ //# sourceMappingURL=semantic-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-tokens.d.ts","sourceRoot":"","sources":["../../src/providers/semantic-tokens.ts"],"names":[],"mappings":"AAQA,OAAO,EAEH,KAAK,cAAc,EAEtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAapD,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAarE"}
@@ -0,0 +1,63 @@
1
+ // Semantic highlighting for the markup layer. The TextMate grammar in the
2
+ // extension colours the bulk of a `.azeroth` file (it embeds the TypeScript
3
+ // grammar); these tokens add the precise, parser-derived distinctions a grammar
4
+ // can't make reliably - chiefly component tags vs. host tags and event vs.
5
+ // plain attributes. Output is LSP's packed delta encoding.
6
+ import { isWhitespace } from '@azerothjs/compiler';
7
+ import { SEMANTIC_TOKEN_TYPES } from "../protocol.js";
8
+ import { collectMarkupNodes } from "../markup-model.js";
9
+ const TYPE_INDEX = new Map(SEMANTIC_TOKEN_TYPES.map((type, index) => [type, index]));
10
+ /** Packed semantic tokens for the markup in the document. */
11
+ export function getSemanticTokens(ctx) {
12
+ const tokens = [];
13
+ for (const node of collectMarkupNodes(ctx.source)) {
14
+ if (node.kind === 'element') {
15
+ collectElementTokens(ctx.source, node, tokens);
16
+ }
17
+ }
18
+ tokens.sort((a, b) => a.offset - b.offset);
19
+ return { data: encode(ctx, tokens) };
20
+ }
21
+ /** Emits tokens for a single element's tag name and attributes. */
22
+ function collectElementTokens(source, node, tokens) {
23
+ tokens.push({
24
+ offset: node.start + 1,
25
+ length: node.tag.length,
26
+ type: node.isComponent ? 'component' : 'tag'
27
+ });
28
+ for (const attr of node.attributes) {
29
+ if (attr.spread || attr.name === null) {
30
+ continue;
31
+ }
32
+ const isEvent = attr.name.length > 2 && attr.name.startsWith('on') && attr.name[2] === attr.name[2].toUpperCase();
33
+ tokens.push({ offset: attr.start, length: attr.name.length, type: isEvent ? 'event' : 'attribute' });
34
+ if (attr.value.kind === 'static') {
35
+ const eq = source.indexOf('=', attr.start + attr.name.length);
36
+ if (eq !== -1) {
37
+ let q = eq + 1;
38
+ while (q < attr.end && isWhitespace(source[q])) {
39
+ q++;
40
+ }
41
+ if (source[q] === '"' || source[q] === '\'') {
42
+ tokens.push({ offset: q, length: attr.end - q, type: 'string' });
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ /** Delta-encodes tokens into the flat array LSP expects (5 ints each). */
49
+ function encode(ctx, tokens) {
50
+ const data = [];
51
+ let prevLine = 0;
52
+ let prevChar = 0;
53
+ for (const token of tokens) {
54
+ const pos = ctx.lineIndex.positionAt(token.offset);
55
+ const deltaLine = pos.line - prevLine;
56
+ const deltaChar = deltaLine === 0 ? pos.character - prevChar : pos.character;
57
+ data.push(deltaLine, deltaChar, token.length, TYPE_INDEX.get(token.type) ?? 0, 0);
58
+ prevLine = pos.line;
59
+ prevChar = pos.character;
60
+ }
61
+ return data;
62
+ }
63
+ //# sourceMappingURL=semantic-tokens.js.map
@@ -0,0 +1 @@
1
+ {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,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACrE,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,SAAS,MAAM,CAAC,GAAmB,EAAE,MAAkB;IAEnD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,KAAK,MAAM,KAAK,IAAI,MAAM,EAC1B,CAAC;QACG,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC;QACtC,MAAM,SAAS,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;QAC7E,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAClF,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC;QACpB,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { SignatureHelp } from '../protocol.ts';
2
+ import { type RequestContext } from '../request.ts';
3
+ /** Signature help for the call enclosing `offset`, or null. */
4
+ export declare function getSignatureHelp(ctx: RequestContext, offset: number): SignatureHelp | null;
5
+ //# sourceMappingURL=signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/providers/signature.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjE,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAoC1F"}
@@ -0,0 +1,38 @@
1
+ // Signature help. A direct TypeScript query at the mapped offset, so it works
2
+ // inside any expression hole or attribute expression - and because components
3
+ // compile to `Component({ ...props })` calls, it also surfaces a component's
4
+ // prop signature while you fill in its attributes.
5
+ import ts from 'typescript';
6
+ import { toGenerated } from "../request.js";
7
+ /** Signature help for the call enclosing `offset`, or null. */
8
+ export function getSignatureHelp(ctx, offset) {
9
+ const generated = toGenerated(ctx, offset);
10
+ if (generated === null) {
11
+ return null;
12
+ }
13
+ const help = ctx.project.service.getSignatureHelpItems(ctx.virtualFile, generated, undefined);
14
+ if (!help || help.items.length === 0) {
15
+ return null;
16
+ }
17
+ const signatures = help.items.map((item) => {
18
+ const prefix = ts.displayPartsToString(item.prefixDisplayParts);
19
+ const separator = ts.displayPartsToString(item.separatorDisplayParts);
20
+ const suffix = ts.displayPartsToString(item.suffixDisplayParts);
21
+ const parameters = item.parameters.map(parameter => ({
22
+ label: ts.displayPartsToString(parameter.displayParts),
23
+ documentation: ts.displayPartsToString(parameter.documentation) || undefined
24
+ }));
25
+ const label = prefix + parameters.map(parameter => parameter.label).join(separator) + suffix;
26
+ return {
27
+ label,
28
+ documentation: ts.displayPartsToString(item.documentation) || undefined,
29
+ parameters
30
+ };
31
+ });
32
+ return {
33
+ signatures,
34
+ activeSignature: help.selectedItemIndex,
35
+ activeParameter: help.argumentIndex
36
+ };
37
+ }
38
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/providers/signature.ts"],"names":[],"mapp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GAAG,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;QAC7F,OAAO;YACH,KAAK;YACL,aAAa,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,SAAS;YACvE,UAAU;SACb,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,UAAU;QACV,eAAe,EAAE,IAAI,CAAC,iBAAiB;QACvC,eAAe,EAAE,IAAI,CAAC,aAAa;KACtC,CAAC;AACN,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type CodeAction, type FoldingRange, type Position, type Range, type SelectionRange, type TextEdit } from '../protocol.ts';
2
+ import { type RequestContext } from '../request.ts';
3
+ /** Collapsible regions: multi-line markup elements + TS outlining spans. */
4
+ export declare function getFoldingRanges(ctx: RequestContext): FoldingRange[];
5
+ /**
6
+ * Code actions for `range`: TypeScript quick fixes for the overlapping
7
+ * diagnostics, plus any applicable refactors (extract function/constant, …)
8
+ * whose edits map cleanly back to the source. Refactors that would touch
9
+ * generated markup scaffolding are skipped, since their edits can't be
10
+ * represented faithfully in the original document.
11
+ */
12
+ export declare function getCodeActions(ctx: RequestContext, range: Range, errorCodes: number[]): CodeAction[];
13
+ /** Formats the document, applying only edits that map cleanly to the source. */
14
+ export declare function getFormattingEdits(ctx: RequestContext): TextEdit[];
15
+ /** Formatting edits triggered by typing `ch` at a position (e.g. `;`, `}`). */
16
+ export declare function getOnTypeFormattingEdits(ctx: RequestContext, position: Position, ch: string): TextEdit[];
17
+ /** Smart-selection (Expand Selection) chains for each caret position. */
18
+ export declare function getSelectionRanges(ctx: RequestContext, positions: Position[]): SelectionRange[];
19
+ //# sourceMappingURL=structure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/providers/structure.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,QAAQ,EAEhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAc/F,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,EAAE,CAuCpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAyBpG;AA4CD,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,EAAE,CAGlE;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE,CAQxG;AAiBD,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAa/F"}