@azerothjs/language-service 0.5.0-beta.1 → 0.6.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.
- package/dist/docgen.d.ts +24 -0
- package/dist/docgen.d.ts.map +1 -0
- package/dist/docgen.js +195 -0
- package/dist/docgen.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/language-data.d.ts +1 -1
- package/dist/language-data.d.ts.map +1 -1
- package/dist/language-data.js +39 -29
- package/dist/language-data.js.map +1 -1
- package/dist/markup-model.d.ts.map +1 -1
- package/dist/markup-model.js +12 -0
- package/dist/markup-model.js.map +1 -1
- package/dist/perf.d.ts +18 -0
- package/dist/perf.d.ts.map +1 -0
- package/dist/perf.js +32 -0
- package/dist/perf.js.map +1 -0
- package/dist/protocol.d.ts +103 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +21 -2
- package/dist/protocol.js.map +1 -1
- package/dist/providers/call-hierarchy.d.ts +9 -0
- package/dist/providers/call-hierarchy.d.ts.map +1 -0
- package/dist/providers/call-hierarchy.js +184 -0
- package/dist/providers/call-hierarchy.js.map +1 -0
- package/dist/providers/code-lens.d.ts +11 -0
- package/dist/providers/code-lens.d.ts.map +1 -0
- package/dist/providers/code-lens.js +70 -0
- package/dist/providers/code-lens.js.map +1 -0
- package/dist/providers/color.d.ts +11 -0
- package/dist/providers/color.d.ts.map +1 -0
- package/dist/providers/color.js +58 -0
- package/dist/providers/color.js.map +1 -0
- package/dist/providers/completion.d.ts +19 -1
- package/dist/providers/completion.d.ts.map +1 -1
- package/dist/providers/completion.js +136 -7
- package/dist/providers/completion.js.map +1 -1
- package/dist/providers/css-service.d.ts +35 -3
- package/dist/providers/css-service.d.ts.map +1 -1
- package/dist/providers/css-service.js +78 -6
- package/dist/providers/css-service.js.map +1 -1
- package/dist/providers/diagnostics.d.ts.map +1 -1
- package/dist/providers/diagnostics.js +35 -3
- package/dist/providers/diagnostics.js.map +1 -1
- package/dist/providers/document-links.d.ts +10 -0
- package/dist/providers/document-links.d.ts.map +1 -0
- package/dist/providers/document-links.js +94 -0
- package/dist/providers/document-links.js.map +1 -0
- package/dist/providers/hover.d.ts.map +1 -1
- package/dist/providers/hover.js +117 -6
- package/dist/providers/hover.js.map +1 -1
- package/dist/providers/html-service.d.ts.map +1 -1
- package/dist/providers/html-service.js +6 -2
- package/dist/providers/html-service.js.map +1 -1
- package/dist/providers/inlay-hints.js +1 -1
- package/dist/providers/inlay-hints.js.map +1 -1
- package/dist/providers/navigation.d.ts +7 -1
- package/dist/providers/navigation.d.ts.map +1 -1
- package/dist/providers/navigation.js +20 -0
- package/dist/providers/navigation.js.map +1 -1
- package/dist/providers/semantic-tokens.d.ts +6 -1
- package/dist/providers/semantic-tokens.d.ts.map +1 -1
- package/dist/providers/semantic-tokens.js +114 -11
- package/dist/providers/semantic-tokens.js.map +1 -1
- package/dist/providers/structure.d.ts +1 -1
- package/dist/providers/structure.d.ts.map +1 -1
- package/dist/providers/structure.js +4 -2
- package/dist/providers/structure.js.map +1 -1
- package/dist/providers/symbols.d.ts.map +1 -1
- package/dist/providers/symbols.js +32 -2
- package/dist/providers/symbols.js.map +1 -1
- package/dist/service.d.ts +44 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +94 -1
- package/dist/service.js.map +1 -1
- package/dist/ts-project.d.ts.map +1 -1
- package/dist/ts-project.js +25 -12
- package/dist/ts-project.js.map +1 -1
- package/dist/virtual-code.d.ts.map +1 -1
- package/dist/virtual-code.js +32 -9
- package/dist/virtual-code.js.map +1 -1
- package/package.json +2 -2
package/dist/perf.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Opt-in performance instrumentation. Disabled by default so the hot path stays
|
|
2
|
+
// allocation-free: when `enabled` is false every measurement is a single boolean
|
|
3
|
+
// read and nothing is recorded. Callers (the service facade) flip the flag via
|
|
4
|
+
// `setEnabled`, then read accumulated timings with `snapshot`.
|
|
5
|
+
let enabled = false;
|
|
6
|
+
const timings = {};
|
|
7
|
+
/** Toggles instrumentation. Off by default; when off, `record` is a no-op. */
|
|
8
|
+
export function setEnabled(value) {
|
|
9
|
+
enabled = value;
|
|
10
|
+
}
|
|
11
|
+
/** Whether instrumentation is currently recording. */
|
|
12
|
+
export function isEnabled() {
|
|
13
|
+
return enabled;
|
|
14
|
+
}
|
|
15
|
+
/** Records a measured duration under `label`, overwriting the previous value. */
|
|
16
|
+
export function record(label, ms) {
|
|
17
|
+
timings[label] = ms;
|
|
18
|
+
}
|
|
19
|
+
/** The most recent timings as a Metrics object. Absent labels read as 0. */
|
|
20
|
+
export function snapshot() {
|
|
21
|
+
return {
|
|
22
|
+
virtualCodeMs: timings.virtualCode ?? 0,
|
|
23
|
+
totalMs: timings.total ?? 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Clears all accumulated timings. */
|
|
27
|
+
export function reset() {
|
|
28
|
+
for (const key of Object.keys(timings)) {
|
|
29
|
+
delete timings[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=perf.js.map
|
package/dist/perf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perf.js","sourceRoot":"","sources":["../src/perf.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,+DAA+D;AAY/D,IAAI,OAAO,GAAG,KAAK,CAAC;AACpB,MAAM,OAAO,GAA2B,EAAE,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,KAAc;IAErC,OAAO,GAAG,KAAK,CAAC;AACpB,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS;IAErB,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,EAAU;IAE5C,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AACxB,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,QAAQ;IAEpB,OAAO;QACH,aAAa,EAAE,OAAO,CAAC,WAAW,IAAI,CAAC;QACvC,OAAO,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAC9B,CAAC;AACN,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,KAAK;IAEjB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EACtC,CAAC;QACG,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;AACL,CAAC"}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ export interface CompletionItem {
|
|
|
46
46
|
insertTextFormat?: 1 | 2;
|
|
47
47
|
sortText?: string;
|
|
48
48
|
filterText?: string;
|
|
49
|
+
/** Characters that accept this item and are typed through (e.g. `=`, ` `). */
|
|
50
|
+
commitCharacters?: string[];
|
|
51
|
+
/** Pre-selects this item when the list opens (the clear contextual winner). */
|
|
52
|
+
preselect?: boolean;
|
|
49
53
|
/** Edits applied alongside the insertion (e.g. an auto-import line). */
|
|
50
54
|
additionalTextEdits?: TextEdit[];
|
|
51
55
|
/** Opaque payload so a resolve step can fetch lazy detail from TS. */
|
|
@@ -81,6 +85,29 @@ export interface TextEdit {
|
|
|
81
85
|
export interface WorkspaceEdit {
|
|
82
86
|
changes: Record<string, TextEdit[]>;
|
|
83
87
|
}
|
|
88
|
+
/** The prepareRename response: the identifier range and its current name. A null reply means the position can't be renamed. */
|
|
89
|
+
export interface PrepareRenameResult {
|
|
90
|
+
range: Range;
|
|
91
|
+
placeholder: string;
|
|
92
|
+
}
|
|
93
|
+
/** An RGBA color, each channel in `[0, 1]` (LSP's normalized representation). */
|
|
94
|
+
export interface Color {
|
|
95
|
+
red: number;
|
|
96
|
+
green: number;
|
|
97
|
+
blue: number;
|
|
98
|
+
alpha: number;
|
|
99
|
+
}
|
|
100
|
+
/** A color literal located in the document, for swatch rendering. */
|
|
101
|
+
export interface ColorInformation {
|
|
102
|
+
range: Range;
|
|
103
|
+
color: Color;
|
|
104
|
+
}
|
|
105
|
+
/** One way to spell a picked color (e.g. `#ff0000`, `rgb(255, 0, 0)`). */
|
|
106
|
+
export interface ColorPresentation {
|
|
107
|
+
label: string;
|
|
108
|
+
/** Edit that rewrites the literal to this spelling; absent when `label` is inserted verbatim. */
|
|
109
|
+
textEdit?: TextEdit;
|
|
110
|
+
}
|
|
84
111
|
/** LSP SymbolKind values (subset). */
|
|
85
112
|
export declare const SymbolKind: {
|
|
86
113
|
readonly File: 1;
|
|
@@ -118,6 +145,33 @@ export interface WorkspaceSymbol {
|
|
|
118
145
|
location: Location;
|
|
119
146
|
containerName?: string;
|
|
120
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* A node in the call hierarchy. `data` carries the originating document URI and
|
|
150
|
+
* the source offset of the selection so the follow-up incoming/outgoing request
|
|
151
|
+
* (which only gets the item back, not a position) can rebuild the query.
|
|
152
|
+
*/
|
|
153
|
+
export interface CallHierarchyItem {
|
|
154
|
+
name: string;
|
|
155
|
+
kind: SymbolKindValue;
|
|
156
|
+
detail?: string;
|
|
157
|
+
uri: string;
|
|
158
|
+
range: Range;
|
|
159
|
+
selectionRange: Range;
|
|
160
|
+
data?: {
|
|
161
|
+
uri: string;
|
|
162
|
+
offset: number;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** A caller of the queried item, with the ranges where the calls appear. */
|
|
166
|
+
export interface CallHierarchyIncomingCall {
|
|
167
|
+
from: CallHierarchyItem;
|
|
168
|
+
fromRanges: Range[];
|
|
169
|
+
}
|
|
170
|
+
/** A callee of the queried item, with the call-site ranges in the caller. */
|
|
171
|
+
export interface CallHierarchyOutgoingCall {
|
|
172
|
+
to: CallHierarchyItem;
|
|
173
|
+
fromRanges: Range[];
|
|
174
|
+
}
|
|
121
175
|
/** LSP DiagnosticSeverity. */
|
|
122
176
|
export declare const DiagnosticSeverity: {
|
|
123
177
|
readonly Error: 1;
|
|
@@ -126,6 +180,11 @@ export declare const DiagnosticSeverity: {
|
|
|
126
180
|
readonly Hint: 4;
|
|
127
181
|
};
|
|
128
182
|
export type DiagnosticSeverityValue = (typeof DiagnosticSeverity)[keyof typeof DiagnosticSeverity];
|
|
183
|
+
/** A secondary location that explains a diagnostic (e.g. "'x' is declared here"). */
|
|
184
|
+
export interface DiagnosticRelatedInformation {
|
|
185
|
+
location: Location;
|
|
186
|
+
message: string;
|
|
187
|
+
}
|
|
129
188
|
/** A problem reported on a range. */
|
|
130
189
|
export interface Diagnostic {
|
|
131
190
|
range: Range;
|
|
@@ -133,6 +192,7 @@ export interface Diagnostic {
|
|
|
133
192
|
message: string;
|
|
134
193
|
code?: string | number;
|
|
135
194
|
source: string;
|
|
195
|
+
relatedInformation?: DiagnosticRelatedInformation[];
|
|
136
196
|
}
|
|
137
197
|
/** A smart-selection range and its enclosing parent (for Expand Selection). */
|
|
138
198
|
export interface SelectionRange {
|
|
@@ -158,6 +218,31 @@ export interface FoldingRange {
|
|
|
158
218
|
endLine: number;
|
|
159
219
|
kind?: 'comment' | 'region' | 'imports';
|
|
160
220
|
}
|
|
221
|
+
/** An editor command (title + identifier + optional arguments). */
|
|
222
|
+
export interface Command {
|
|
223
|
+
title: string;
|
|
224
|
+
command: string;
|
|
225
|
+
arguments?: unknown[];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A clickable annotation over a range (e.g. a "N references" lens). Lenses are
|
|
229
|
+
* emitted unresolved - with `data` carrying the source URI + offset - so the
|
|
230
|
+
* initial pass stays cheap; the `command` is filled in by a later resolve step.
|
|
231
|
+
*/
|
|
232
|
+
export interface CodeLens {
|
|
233
|
+
range: Range;
|
|
234
|
+
command?: Command;
|
|
235
|
+
data?: unknown;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A clickable link over a range (e.g. a relative import specifier). `target` is
|
|
239
|
+
* the `file://` URI the editor opens on click; `tooltip` is optional hover text.
|
|
240
|
+
*/
|
|
241
|
+
export interface DocumentLink {
|
|
242
|
+
range: Range;
|
|
243
|
+
target?: string;
|
|
244
|
+
tooltip?: string;
|
|
245
|
+
}
|
|
161
246
|
/** A code action (quick fix / refactor). */
|
|
162
247
|
export interface CodeAction {
|
|
163
248
|
title: string;
|
|
@@ -170,7 +255,23 @@ export interface CodeAction {
|
|
|
170
255
|
export interface SemanticTokens {
|
|
171
256
|
data: number[];
|
|
172
257
|
}
|
|
173
|
-
/**
|
|
174
|
-
|
|
258
|
+
/**
|
|
259
|
+
* The token types this service emits, in legend order. Each name's index is the
|
|
260
|
+
* legend id sent on the wire, so this order is a contract with the editor and
|
|
261
|
+
* must stay stable - APPEND new types, never reorder. The leading six are the
|
|
262
|
+
* markup-layer distinctions; the trailing block is the standard set the
|
|
263
|
+
* TypeScript classifier produces for embedded script/expression regions, so a
|
|
264
|
+
* `.azeroth` file's TS colours the same as a `.ts` file.
|
|
265
|
+
*/
|
|
266
|
+
export declare const SEMANTIC_TOKEN_TYPES: readonly ["component", "tag", "attribute", "event", "string", "delimiter", "namespace", "class", "enum", "interface", "typeParameter", "type", "parameter", "variable", "property", "enumMember", "function", "method"];
|
|
175
267
|
export type SemanticTokenType = (typeof SEMANTIC_TOKEN_TYPES)[number];
|
|
268
|
+
/**
|
|
269
|
+
* The token modifiers this service emits, in legend order. Each name's index is
|
|
270
|
+
* the bit position the encoder sets in a token's modifier mask, so this order is
|
|
271
|
+
* a wire contract with the editor and must stay stable. The set mirrors the
|
|
272
|
+
* standard TypeScript modifiers so the legend reads the same as a `.ts` file;
|
|
273
|
+
* the markup provider currently sets only `defaultLibrary` (built-in components).
|
|
274
|
+
*/
|
|
275
|
+
export declare const SEMANTIC_TOKEN_MODIFIERS: readonly ["declaration", "readonly", "static", "async", "defaultLibrary", "local"];
|
|
276
|
+
export type SemanticTokenModifier = (typeof SEMANTIC_TOKEN_MODIFIERS)[number];
|
|
176
277
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAMA,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IAErB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,wCAAwC;AACxC,MAAM,WAAW,KAAK;IAElB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IAErB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,wDAAwD;AACxD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAEnG,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAE3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,uBAAuB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,QAAQ,EAAE,CAAC;IACjC,sEAAsE;IACtE,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,oCAAoC;AACpC,MAAM,WAAW,KAAK;IAElB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACj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AAG,QAAQ,GAAG,SAAS,CAAC;CAC3C;AAED,mEAAmE;AACnE,MAAM,WAAW,OAAO;IAEpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IAErB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAEzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IAEvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAE3B,IAAI,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,yNAIvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,oFAE3B,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/protocol.js
CHANGED
|
@@ -51,8 +51,27 @@ export const DiagnosticSeverity = {
|
|
|
51
51
|
Information: 3,
|
|
52
52
|
Hint: 4
|
|
53
53
|
};
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The token types this service emits, in legend order. Each name's index is the
|
|
56
|
+
* legend id sent on the wire, so this order is a contract with the editor and
|
|
57
|
+
* must stay stable - APPEND new types, never reorder. The leading six are the
|
|
58
|
+
* markup-layer distinctions; the trailing block is the standard set the
|
|
59
|
+
* TypeScript classifier produces for embedded script/expression regions, so a
|
|
60
|
+
* `.azeroth` file's TS colours the same as a `.ts` file.
|
|
61
|
+
*/
|
|
55
62
|
export const SEMANTIC_TOKEN_TYPES = [
|
|
56
|
-
'component', 'tag', 'attribute', 'event', 'string', 'delimiter'
|
|
63
|
+
'component', 'tag', 'attribute', 'event', 'string', 'delimiter',
|
|
64
|
+
'namespace', 'class', 'enum', 'interface', 'typeParameter', 'type',
|
|
65
|
+
'parameter', 'variable', 'property', 'enumMember', 'function', 'method'
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* The token modifiers this service emits, in legend order. Each name's index is
|
|
69
|
+
* the bit position the encoder sets in a token's modifier mask, so this order is
|
|
70
|
+
* a wire contract with the editor and must stay stable. The set mirrors the
|
|
71
|
+
* standard TypeScript modifiers so the legend reads the same as a `.ts` file;
|
|
72
|
+
* the markup provider currently sets only `defaultLibrary` (built-in components).
|
|
73
|
+
*/
|
|
74
|
+
export const SEMANTIC_TOKEN_MODIFIERS = [
|
|
75
|
+
'declaration', 'readonly', 'static', 'async', 'defaultLibrary', 'local'
|
|
57
76
|
];
|
|
58
77
|
//# sourceMappingURL=protocol.js.map
|
package/dist/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,+CAA+C;AAuB/C,wDAAwD;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAC/B;IACI,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,SA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ACb,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE,EAAE;CACJ,CAAC;AAsDX,8BAA8B;AAC9B,MAAM,CAAC,MAAM,kBAAkB,GAC/B;IACI,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,CAAC;CACD,CAAC;AAqGX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW;IAC/D,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM;IAClE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ;CACjE,CAAC;AAIX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO;CACjE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CallHierarchyIncomingCall, type CallHierarchyItem, type CallHierarchyOutgoingCall } from '../protocol.ts';
|
|
2
|
+
import { type RequestContext } from '../request.ts';
|
|
3
|
+
/** The call-hierarchy node(s) for the symbol at `offset`. */
|
|
4
|
+
export declare function prepareCallHierarchy(ctx: RequestContext, offset: number): CallHierarchyItem[];
|
|
5
|
+
/** Callers of the item, each with the ranges where the call appears. */
|
|
6
|
+
export declare function incomingCalls(ctx: RequestContext, offset: number): CallHierarchyIncomingCall[];
|
|
7
|
+
/** Callees of the item, each with the call-site ranges in the caller. */
|
|
8
|
+
export declare function outgoingCalls(ctx: RequestContext, offset: number): CallHierarchyOutgoingCall[];
|
|
9
|
+
//# sourceMappingURL=call-hierarchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-hierarchy.d.ts","sourceRoot":"","sources":["../../src/providers/call-hierarchy.ts"],"names":[],"mappings":"AASA,OAAO,EAEH,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAGjC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAIH,KAAK,cAAc,EACtB,MAAM,eAAe,CAAC;AAGvB,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAgB7F;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,yBAAyB,EAAE,CAmB9F;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,yBAAyB,EAAE,CAqB9F"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Call hierarchy: prepare a node at the caret, then walk its callers (incoming)
|
|
2
|
+
// or callees (outgoing). Like navigation.ts, every query runs against the
|
|
3
|
+
// virtual module and every span TypeScript hands back is mapped to the original
|
|
4
|
+
// `.azeroth` source. The follow-up incoming/outgoing requests don't carry a
|
|
5
|
+
// position, only the prepared item, so each item stashes its originating URI and
|
|
6
|
+
// source offset in `data`; that offset is re-mapped to the virtual module to
|
|
7
|
+
// re-query TypeScript.
|
|
8
|
+
import ts from 'typescript';
|
|
9
|
+
import { SymbolKind } from "../protocol.js";
|
|
10
|
+
import { LineIndex } from "../text.js";
|
|
11
|
+
import { pathToUri } from "../uri.js";
|
|
12
|
+
import { isVirtualFile, toAzerothPath, toGenerated } from "../request.js";
|
|
13
|
+
/** The call-hierarchy node(s) for the symbol at `offset`. */
|
|
14
|
+
export function prepareCallHierarchy(ctx, offset) {
|
|
15
|
+
const generated = toGenerated(ctx, offset);
|
|
16
|
+
if (generated === null) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const prepared = ctx.project.service.prepareCallHierarchy(ctx.virtualFile, generated);
|
|
20
|
+
if (!prepared) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const items = Array.isArray(prepared) ? prepared : [prepared];
|
|
24
|
+
return items
|
|
25
|
+
.map(item => toHierarchyItem(ctx.project, item))
|
|
26
|
+
.filter((item) => item !== null);
|
|
27
|
+
}
|
|
28
|
+
/** Callers of the item, each with the ranges where the call appears. */
|
|
29
|
+
export function incomingCalls(ctx, offset) {
|
|
30
|
+
const generated = toGenerated(ctx, offset);
|
|
31
|
+
if (generated === null) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const calls = ctx.project.service.provideCallHierarchyIncomingCalls(ctx.virtualFile, generated);
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const call of calls) {
|
|
37
|
+
const from = toHierarchyItem(ctx.project, call.from);
|
|
38
|
+
if (from === null) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
out.push({ from, fromRanges: mapSpans(ctx.project, call.from.file, call.fromSpans) });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/** Callees of the item, each with the call-site ranges in the caller. */
|
|
46
|
+
export function outgoingCalls(ctx, offset) {
|
|
47
|
+
const generated = toGenerated(ctx, offset);
|
|
48
|
+
if (generated === null) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const calls = ctx.project.service.provideCallHierarchyOutgoingCalls(ctx.virtualFile, generated);
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const call of calls) {
|
|
54
|
+
const to = toHierarchyItem(ctx.project, call.to);
|
|
55
|
+
if (to === null) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Outgoing `fromSpans` are call sites in the *caller* (the queried item's
|
|
59
|
+
// own file), so they map through that file, not the callee's.
|
|
60
|
+
out.push({ to, fromRanges: mapSpans(ctx.project, ctx.virtualFile, call.fromSpans) });
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Translates a TS call-hierarchy item (possibly in another file) to an editor
|
|
66
|
+
* item. A virtual file maps both spans back through its mapping and reports the
|
|
67
|
+
* `.azeroth` URI; a real file reports directly. Returns null when the enclosing
|
|
68
|
+
* span lands purely in generated scaffolding (no faithful source range).
|
|
69
|
+
*/
|
|
70
|
+
function toHierarchyItem(project, item) {
|
|
71
|
+
if (isVirtualFile(item.file)) {
|
|
72
|
+
const azerothPath = toAzerothPath(item.file);
|
|
73
|
+
const virtual = project.getVirtual(azerothPath);
|
|
74
|
+
const source = project.getSource(azerothPath) ?? '';
|
|
75
|
+
const lineIndex = new LineIndex(source);
|
|
76
|
+
// A function that returns markup straddles generated scaffolding, so its
|
|
77
|
+
// full span is not one contiguous mapping. Map the two endpoints
|
|
78
|
+
// independently (both sit in verbatim script), mirroring symbols.ts. The
|
|
79
|
+
// selection span is always the verbatim name, so it maps as one range.
|
|
80
|
+
const range = toEndpointRange(virtual.mapping, lineIndex, item.span);
|
|
81
|
+
const selectionRange = toSourceRange(virtual.mapping, lineIndex, item.selectionSpan);
|
|
82
|
+
if (range === null || selectionRange === null) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const offset = virtual.mapping.toOriginal(item.selectionSpan.start);
|
|
86
|
+
const uri = pathToUri(azerothPath);
|
|
87
|
+
return {
|
|
88
|
+
name: item.name,
|
|
89
|
+
kind: tsKindToSymbolKind(item.kind),
|
|
90
|
+
detail: item.containerName || undefined,
|
|
91
|
+
uri,
|
|
92
|
+
range,
|
|
93
|
+
selectionRange,
|
|
94
|
+
data: offset === null ? undefined : { uri, offset }
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const text = ts.sys.readFile(item.file);
|
|
98
|
+
if (text === undefined) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const lineIndex = new LineIndex(text);
|
|
102
|
+
const uri = pathToUri(item.file);
|
|
103
|
+
return {
|
|
104
|
+
name: item.name,
|
|
105
|
+
kind: tsKindToSymbolKind(item.kind),
|
|
106
|
+
detail: item.containerName || undefined,
|
|
107
|
+
uri,
|
|
108
|
+
range: lineIndex.rangeAt(item.span.start, item.span.start + item.span.length),
|
|
109
|
+
selectionRange: lineIndex.rangeAt(item.selectionSpan.start, item.selectionSpan.start + item.selectionSpan.length),
|
|
110
|
+
data: { uri, offset: item.selectionSpan.start }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Maps every call-site span in `fileName` back to a source range, dropping unmappable ones. */
|
|
114
|
+
function mapSpans(project, fileName, spans) {
|
|
115
|
+
const out = [];
|
|
116
|
+
if (isVirtualFile(fileName)) {
|
|
117
|
+
const azerothPath = toAzerothPath(fileName);
|
|
118
|
+
const virtual = project.getVirtual(azerothPath);
|
|
119
|
+
const lineIndex = new LineIndex(project.getSource(azerothPath) ?? '');
|
|
120
|
+
for (const span of spans) {
|
|
121
|
+
const range = toSourceRange(virtual.mapping, lineIndex, span);
|
|
122
|
+
if (range !== null) {
|
|
123
|
+
out.push(range);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
const text = ts.sys.readFile(fileName);
|
|
129
|
+
if (text === undefined) {
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
const lineIndex = new LineIndex(text);
|
|
133
|
+
for (const span of spans) {
|
|
134
|
+
out.push(lineIndex.rangeAt(span.start, span.start + span.length));
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
/** Maps a virtual span to an original range, or null when it covers scaffolding. */
|
|
139
|
+
function toSourceRange(mapping, lineIndex, span) {
|
|
140
|
+
const mapped = mapping.toOriginalRange(span.start, span.start + span.length);
|
|
141
|
+
return mapped === null ? null : lineIndex.rangeAt(mapped.start, mapped.end);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Maps a span by translating each endpoint independently. Recovers the source
|
|
145
|
+
* range of a declaration whose body contains markup (and so straddles generated
|
|
146
|
+
* scaffolding that no single range can cross). Null when either end is unmapped.
|
|
147
|
+
*/
|
|
148
|
+
function toEndpointRange(mapping, lineIndex, span) {
|
|
149
|
+
const start = mapping.toOriginal(span.start);
|
|
150
|
+
const end = mapping.toOriginal(span.start + span.length);
|
|
151
|
+
if (start === null || end === null || end < start) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return lineIndex.rangeAt(start, end);
|
|
155
|
+
}
|
|
156
|
+
/** Maps a TS ScriptElementKind to an LSP SymbolKind (call-hierarchy subset). */
|
|
157
|
+
function tsKindToSymbolKind(kind) {
|
|
158
|
+
switch (kind) {
|
|
159
|
+
case ts.ScriptElementKind.moduleElement:
|
|
160
|
+
return SymbolKind.Module;
|
|
161
|
+
case ts.ScriptElementKind.classElement:
|
|
162
|
+
case ts.ScriptElementKind.localClassElement:
|
|
163
|
+
return SymbolKind.Class;
|
|
164
|
+
case ts.ScriptElementKind.interfaceElement:
|
|
165
|
+
return SymbolKind.Interface;
|
|
166
|
+
case ts.ScriptElementKind.enumElement:
|
|
167
|
+
return SymbolKind.Enum;
|
|
168
|
+
case ts.ScriptElementKind.memberFunctionElement:
|
|
169
|
+
case ts.ScriptElementKind.constructorImplementationElement:
|
|
170
|
+
return SymbolKind.Method;
|
|
171
|
+
case ts.ScriptElementKind.memberVariableElement:
|
|
172
|
+
case ts.ScriptElementKind.memberGetAccessorElement:
|
|
173
|
+
case ts.ScriptElementKind.memberSetAccessorElement:
|
|
174
|
+
return SymbolKind.Property;
|
|
175
|
+
case ts.ScriptElementKind.variableElement:
|
|
176
|
+
case ts.ScriptElementKind.letElement:
|
|
177
|
+
return SymbolKind.Variable;
|
|
178
|
+
case ts.ScriptElementKind.constElement:
|
|
179
|
+
return SymbolKind.Constant;
|
|
180
|
+
default:
|
|
181
|
+
return SymbolKind.Function;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=call-hierarchy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-hierarchy.js","sourceRoot":"","sources":["../../src/providers/call-hierarchy.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAC1E,gFAAgF;AAChF,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,uBAAuB;AAEvB,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACH,UAAU,EAMb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACH,aAAa,EACb,aAAa,EACb,WAAW,EAEd,MAAM,eAAe,CAAC;AAGvB,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,GAAmB,EAAE,MAAc;IAEpE,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,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACtF,IAAI,CAAC,QAAQ,EACb,CAAC;QACG,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC9D,OAAO,KAAK;SACP,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SA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K,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC;QAChD,KAAK,EAAE,CAAC,iBAAiB,CAAC,gCAAgC;YACtD,OAAO,UAAU,CAAC,MAAM,CAAC;QAC7B,KAAK,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC;QAChD,KAAK,EAAE,CAAC,iBAAiB,CAAC,wBAAwB,CAAC;QACnD,KAAK,EAAE,CAAC,iBAAiB,CAAC,wBAAwB;YAC9C,OAAO,UAAU,CAAC,QAAQ,CAAC;QAC/B,KAAK,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC;QAC1C,KAAK,EAAE,CAAC,iBAAiB,CAAC,UAAU;YAChC,OAAO,UAAU,CAAC,QAAQ,CAAC;QAC/B,KAAK,EAAE,CAAC,iBAAiB,CAAC,YAAY;YAClC,OAAO,UAAU,CAAC,QAAQ,CAAC;QAC/B;YACI,OAAO,UAAU,CAAC,QAAQ,CAAC;IACnC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CodeLens } from '../protocol.ts';
|
|
2
|
+
import { type RequestContext } from '../request.ts';
|
|
3
|
+
/** One unresolved lens per top-level declaration; references are NOT counted here. */
|
|
4
|
+
export declare function getCodeLenses(ctx: RequestContext): CodeLens[];
|
|
5
|
+
/**
|
|
6
|
+
* Fills a lens's command with its reference count, computed now via the
|
|
7
|
+
* references provider. The lens carries the declaration's source offset in
|
|
8
|
+
* `data`; an unresolvable/unmappable payload yields the lens unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveCodeLens(ctx: RequestContext, lens: CodeLens): CodeLens;
|
|
11
|
+
//# sourceMappingURL=code-lens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-lens.d.ts","sourceRoot":"","sources":["../../src/providers/code-lens.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAcpD,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,EAAE,CAsB7D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAoB7E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Code lenses: a "N references" annotation over each top-level component /
|
|
2
|
+
// function declaration. The initial pass (getCodeLenses) reuses the
|
|
3
|
+
// document-symbol navigation tree to place a lens on every eligible declaration,
|
|
4
|
+
// stashing the source URI + name offset in `data` - it deliberately does NOT
|
|
5
|
+
// count references (a find-all-references per declaration is too slow for the
|
|
6
|
+
// whole document at once). The count is computed lazily, one lens at a time, in
|
|
7
|
+
// resolveCodeLens via the references provider, mirroring completion/resolve.
|
|
8
|
+
import ts from 'typescript';
|
|
9
|
+
import { getReferences } from "./navigation.js";
|
|
10
|
+
/** The script-element kinds that get a reference lens (top-level declarations). */
|
|
11
|
+
const LENS_KINDS = new Set([
|
|
12
|
+
ts.ScriptElementKind.functionElement,
|
|
13
|
+
ts.ScriptElementKind.classElement,
|
|
14
|
+
ts.ScriptElementKind.constElement,
|
|
15
|
+
ts.ScriptElementKind.variableElement,
|
|
16
|
+
ts.ScriptElementKind.letElement,
|
|
17
|
+
ts.ScriptElementKind.interfaceElement,
|
|
18
|
+
ts.ScriptElementKind.enumElement
|
|
19
|
+
]);
|
|
20
|
+
/** One unresolved lens per top-level declaration; references are NOT counted here. */
|
|
21
|
+
export function getCodeLenses(ctx) {
|
|
22
|
+
const tree = ctx.project.service.getNavigationTree(ctx.virtualFile);
|
|
23
|
+
if (!tree?.childItems) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const item of tree.childItems) {
|
|
28
|
+
if (!LENS_KINDS.has(item.kind)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const offset = nameOffset(ctx, item);
|
|
32
|
+
if (offset === null) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
out.push({ range: ctx.lineIndex.rangeAt(offset, offset), data: { uri: ctx.uri, offset } });
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fills a lens's command with its reference count, computed now via the
|
|
41
|
+
* references provider. The lens carries the declaration's source offset in
|
|
42
|
+
* `data`; an unresolvable/unmappable payload yields the lens unchanged.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveCodeLens(ctx, lens) {
|
|
45
|
+
const data = lens.data;
|
|
46
|
+
if (!data) {
|
|
47
|
+
return lens;
|
|
48
|
+
}
|
|
49
|
+
const references = getReferences(ctx, data.offset);
|
|
50
|
+
// The declaration's own name counts as a reference; subtract it so the lens
|
|
51
|
+
// reads like the editor's built-in "N references".
|
|
52
|
+
const count = Math.max(references.length - 1, 0);
|
|
53
|
+
return {
|
|
54
|
+
...lens,
|
|
55
|
+
command: {
|
|
56
|
+
title: `${count} reference${count === 1 ? '' : 's'}`,
|
|
57
|
+
command: 'editor.action.showReferences',
|
|
58
|
+
arguments: [data.uri, lens.range.start, references]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** The original-source offset of a navigation node's name, or null if unmapped. */
|
|
63
|
+
function nameOffset(ctx, item) {
|
|
64
|
+
const span = item.nameSpan ?? item.spans[0];
|
|
65
|
+
if (!span) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return ctx.virtual.mapping.toOriginal(span.start);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=code-lens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-lens.js","sourceRoot":"","sources":["../../src/providers/code-lens.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,oEAAoE;AACpE,iFAAiF;AACjF,6EAA6E;AAC7E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C,CAAC;IAC/F,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAmB,EAAE,IAAc;IAE/D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAmD,CAAC;IACtE,IAAI,CAAC,IAAI,EACT,CAAC;QACG,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,4EAA4E;IAC5E,mDAAmD;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO;QACH,GAAG,IAAI;QACP,OAAO,EACP;YACI,KAAK,EAAE,GAAI,KAAM,aAAc,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAI,EAAE;YACxD,OAAO,EAAE,8BAA8B;YACvC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,UAAwB,CAAC;SACpE;KACJ,CAAC;AACN,CAAC;AAED,mFAAmF;AACnF,SAAS,UAAU,CAAC,GAAmB,EAAE,IAAuB;IAE5D,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EACT,CAAC;QACG,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RequestContext } from '../request.ts';
|
|
2
|
+
import type { Color, ColorInformation, ColorPresentation, Range } from '../protocol.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Color swatches for every static `style="..."` value and css`` template in the
|
|
5
|
+
* document. Collects the CSS regions, runs the wrapped CSS service over each,
|
|
6
|
+
* and returns the located colors with source-mapped ranges. Never throws.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDocumentColors(ctx: RequestContext): ColorInformation[];
|
|
9
|
+
/** The spelling choices for a picked color at `range` (delegated to the CSS service). */
|
|
10
|
+
export declare function getColorPresentations(_ctx: RequestContext, color: Color, range: Range): ColorPresentation[];
|
|
11
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/providers/color.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAUxF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,EAAE,CAmBzE;AAED,yFAAyF;AACzF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,iBAAiB,EAAE,CAG3G"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Document colors: render a swatch next to every CSS color literal in a
|
|
2
|
+
// `.azeroth` file, in the two places CSS appears - a static `style="..."`
|
|
3
|
+
// attribute (a declaration list) and a css`` template (a full stylesheet).
|
|
4
|
+
// Both are handed to vscode-css-languageservice via css-service, which maps the
|
|
5
|
+
// swatch ranges back to the original source. `style={...}` is a JS expression and
|
|
6
|
+
// is left to the TypeScript bridge, never reached here.
|
|
7
|
+
import { collectMarkupNodes } from "../markup-model.js";
|
|
8
|
+
import { cssColorPresentations, cssColors, cssTemplateSpans, styleRegion, templateRegion } from "./css-service.js";
|
|
9
|
+
/**
|
|
10
|
+
* Color swatches for every static `style="..."` value and css`` template in the
|
|
11
|
+
* document. Collects the CSS regions, runs the wrapped CSS service over each,
|
|
12
|
+
* and returns the located colors with source-mapped ranges. Never throws.
|
|
13
|
+
*/
|
|
14
|
+
export function getDocumentColors(ctx) {
|
|
15
|
+
try {
|
|
16
|
+
const regions = [];
|
|
17
|
+
for (const span of styleValueSpans(ctx.source)) {
|
|
18
|
+
regions.push(styleRegion(ctx.source, span.start, span.end));
|
|
19
|
+
}
|
|
20
|
+
for (const span of cssTemplateSpans(ctx.source)) {
|
|
21
|
+
regions.push(templateRegion(ctx.source, span.start, span.end));
|
|
22
|
+
}
|
|
23
|
+
return cssColors(ctx.source, regions, ctx.lineIndex);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The spelling choices for a picked color at `range` (delegated to the CSS service). */
|
|
30
|
+
export function getColorPresentations(_ctx, color, range) {
|
|
31
|
+
return cssColorPresentations(color, range);
|
|
32
|
+
}
|
|
33
|
+
/** The `[start, end)` content span of every static `style="..."` value in the source. */
|
|
34
|
+
function styleValueSpans(source) {
|
|
35
|
+
const spans = [];
|
|
36
|
+
for (const node of collectMarkupNodes(source)) {
|
|
37
|
+
if (node.kind !== 'element') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
for (const attr of node.attributes) {
|
|
41
|
+
if (attr.name !== 'style' || attr.value.kind !== 'static') {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const eq = source.indexOf('=', attr.start);
|
|
45
|
+
if (eq === -1) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const quote = source[eq + 1];
|
|
49
|
+
if (quote !== '"' && quote !== '\'') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// attr.end sits just past the closing quote; the value is between them.
|
|
53
|
+
spans.push({ start: eq + 2, end: attr.end - 1 });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return spans;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/providers/color.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,gFAAgF;AAChF,kFAAkF;AAClF,wDAAwD;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EACH,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,cAAc,EAEjB,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IAEjD,IACA,CAAC;QACG,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EAC9C,CAAC;YACG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAC/C,CAAC;YACG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IACD,MACA,CAAC;QACG,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,qBAAqB,CAAC,IAAoB,EAAE,KAAY,EAAE,KAAY;IAElF,OAAO,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,CAA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