@venn-lang/lsp 0.1.0

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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/dist/bin/venn-lsp.d.mts +1 -0
  4. package/dist/bin/venn-lsp.mjs +17 -0
  5. package/dist/bin/venn-lsp.mjs.map +1 -0
  6. package/dist/index.d.mts +722 -0
  7. package/dist/index.d.mts.map +1 -0
  8. package/dist/index.mjs +2 -0
  9. package/dist/server-BET60xwK.mjs +5376 -0
  10. package/dist/server-BET60xwK.mjs.map +1 -0
  11. package/package.json +65 -0
  12. package/src/bin/venn-lsp.ts +17 -0
  13. package/src/catalog/build-catalog.ts +72 -0
  14. package/src/catalog/catalog.types.ts +44 -0
  15. package/src/catalog/index.ts +2 -0
  16. package/src/code-actions/anchor.ts +49 -0
  17. package/src/code-actions/code-actions.ts +139 -0
  18. package/src/code-actions/exporting-modules.ts +73 -0
  19. package/src/code-actions/index.ts +5 -0
  20. package/src/completion/argument-items.ts +81 -0
  21. package/src/completion/completion.ts +416 -0
  22. package/src/completion/completion.types.ts +38 -0
  23. package/src/completion/context.ts +144 -0
  24. package/src/completion/icons.ts +83 -0
  25. package/src/completion/index.ts +4 -0
  26. package/src/completion/items.ts +232 -0
  27. package/src/completion/member-items.ts +147 -0
  28. package/src/completion/module-paths.ts +63 -0
  29. package/src/completion/options-map-items.ts +47 -0
  30. package/src/completion/read-from.ts +77 -0
  31. package/src/completion/type-name-items.ts +62 -0
  32. package/src/deco/builtin-decos.ts +35 -0
  33. package/src/deco/builtin-docs.ts +26 -0
  34. package/src/deco/declared-deco.ts +56 -0
  35. package/src/deco/deco.types.ts +23 -0
  36. package/src/deco/decos-in-scope.ts +63 -0
  37. package/src/deco/imported-decos.ts +49 -0
  38. package/src/deco/index.ts +9 -0
  39. package/src/deco/kind-of.ts +15 -0
  40. package/src/deco/render-deco.ts +44 -0
  41. package/src/definition/definition.ts +93 -0
  42. package/src/definition/index.ts +1 -0
  43. package/src/docs/doc.types.ts +17 -0
  44. package/src/docs/index.ts +4 -0
  45. package/src/docs/parse-doc.ts +42 -0
  46. package/src/docs/read-doc.ts +45 -0
  47. package/src/docs/render-doc.ts +42 -0
  48. package/src/document/exported-names.ts +30 -0
  49. package/src/document/expression-path.ts +43 -0
  50. package/src/document/find-binding.ts +82 -0
  51. package/src/document/host-at.ts +61 -0
  52. package/src/document/imported-modules.ts +91 -0
  53. package/src/document/imported-names.ts +15 -0
  54. package/src/document/index.ts +19 -0
  55. package/src/document/interpolation-at.ts +134 -0
  56. package/src/document/names-in-scope.ts +126 -0
  57. package/src/document/resolve-fragment.ts +38 -0
  58. package/src/document/resolve-imported.ts +35 -0
  59. package/src/effects/index.ts +1 -0
  60. package/src/effects/waiting-fns.ts +83 -0
  61. package/src/env/env-vars.ts +88 -0
  62. package/src/env/env.types.ts +9 -0
  63. package/src/env/index.ts +3 -0
  64. package/src/env/render-env.ts +25 -0
  65. package/src/formatting/formatter.ts +68 -0
  66. package/src/formatting/index.ts +1 -0
  67. package/src/hover/hover.ts +322 -0
  68. package/src/hover/index.ts +1 -0
  69. package/src/hover/keywords.ts +168 -0
  70. package/src/hover/render-action.ts +94 -0
  71. package/src/hover/render-decl.ts +155 -0
  72. package/src/hover/render-imported.ts +49 -0
  73. package/src/hover/render-symbol.ts +108 -0
  74. package/src/hover/render-type-name.ts +78 -0
  75. package/src/hover/resolve-symbol.ts +77 -0
  76. package/src/hover/type-hover.ts +62 -0
  77. package/src/index.ts +38 -0
  78. package/src/markdown/index.ts +1 -0
  79. package/src/markdown/markdown.ts +38 -0
  80. package/src/references/document-highlight.ts +45 -0
  81. package/src/references/find-occurrences.ts +49 -0
  82. package/src/references/index.ts +13 -0
  83. package/src/references/name-property.ts +14 -0
  84. package/src/references/occurrence-range.ts +23 -0
  85. package/src/references/occurrences.ts +124 -0
  86. package/src/references/references.ts +38 -0
  87. package/src/references/symbol-at.ts +114 -0
  88. package/src/references/symbol.types.ts +38 -0
  89. package/src/rename/declares-deco.ts +15 -0
  90. package/src/rename/index.ts +1 -0
  91. package/src/rename/rename.ts +73 -0
  92. package/src/semantic/highlight-calls.ts +56 -0
  93. package/src/semantic/highlight-interpolation.ts +135 -0
  94. package/src/semantic/highlight-keywords.ts +115 -0
  95. package/src/semantic/highlight-literals.ts +38 -0
  96. package/src/semantic/highlight-module.ts +36 -0
  97. package/src/semantic/highlight-names.ts +97 -0
  98. package/src/semantic/highlight-paths.ts +80 -0
  99. package/src/semantic/highlight.types.ts +10 -0
  100. package/src/semantic/index.ts +1 -0
  101. package/src/semantic/semantic-tokens.ts +32 -0
  102. package/src/server/index.ts +1 -0
  103. package/src/server/start-server.ts +15 -0
  104. package/src/services/index.ts +2 -0
  105. package/src/services/lsp.types.ts +14 -0
  106. package/src/services/venn-lsp-module.ts +65 -0
  107. package/src/signature/action-call.ts +82 -0
  108. package/src/signature/bare-call.ts +55 -0
  109. package/src/signature/call-shape.ts +90 -0
  110. package/src/signature/call-shape.types.ts +34 -0
  111. package/src/signature/declared-shape.ts +52 -0
  112. package/src/signature/index.ts +11 -0
  113. package/src/signature/paren-call.ts +77 -0
  114. package/src/signature/render-shape.ts +92 -0
  115. package/src/signature/shape-at.ts +35 -0
  116. package/src/signature/signature-help.ts +98 -0
  117. package/src/symbols/document-symbols.ts +68 -0
  118. package/src/symbols/index.ts +1 -0
  119. package/src/testing/fixtures/alias-import.vn +16 -0
  120. package/src/testing/fixtures/shared/auth.vn +33 -0
  121. package/src/testing/fixtures/venn.toml +8 -0
  122. package/src/testing/lsp-fixture.ts +77 -0
  123. package/src/types/index.ts +3 -0
  124. package/src/types/type-service.ts +144 -0
  125. package/src/types/warm-types.ts +30 -0
  126. package/src/validation/check-validator.ts +111 -0
  127. package/src/validation/index.ts +1 -0
  128. package/src/workspace/import-resolver.ts +187 -0
  129. package/src/workspace/index.ts +1 -0
@@ -0,0 +1,722 @@
1
+ import { AstNode, DecoDecl, Document, Expr, FragmentDecl, Problem, Type } from "@venn-lang/core";
2
+ import { AstNode as AstNode$1, LangiumDocument, LangiumDocuments, URI } from "langium";
3
+ import { ActionDefinition, MatcherDefinition, PluginDefinition } from "@venn-lang/sdk";
4
+ import { TypeSpec } from "@venn-lang/types";
5
+ import { CompletionList, CompletionParams, Connection, DefinitionParams, DocumentFormattingParams, DocumentHighlight, DocumentHighlightParams, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingParams, DocumentRangeFormattingParams, DocumentSymbol, Hover, HoverParams, Location, LocationLink, Position, PrepareRenameParams, Range, ReferenceParams, RenameParams, SignatureHelp, SignatureHelpOptions, SignatureHelpParams, TextEdit, WorkspaceEdit } from "vscode-languageserver";
6
+ import { AbstractSemanticTokenProvider, CompletionProvider, DefaultSharedModuleContext, DefinitionProvider, DocumentHighlightProvider, DocumentSymbolProvider, Formatter, HoverProvider, LangiumServices, LangiumSharedServices, ReferencesProvider, RenameProvider, SemanticTokenAcceptor, SignatureHelpProvider } from "langium/lsp";
7
+ //#region src/catalog/catalog.types.d.ts
8
+ /** One type a plugin publishes: `http.Request`, and the shape behind it. */
9
+ interface TypeEntry {
10
+ namespace: string;
11
+ name: string;
12
+ package: string;
13
+ spec: TypeSpec;
14
+ }
15
+ /** One action, with the package that contributes it. */
16
+ interface ActionEntry {
17
+ namespace: string;
18
+ name: string;
19
+ package: string;
20
+ action: ActionDefinition;
21
+ }
22
+ /** One matcher, with the package that contributes it. */
23
+ interface MatcherEntry {
24
+ name: string;
25
+ package: string;
26
+ matcher: MatcherDefinition;
27
+ }
28
+ /**
29
+ * Everything the editor needs to resolve, list and describe stdlib symbols.
30
+ * The grammar cannot tell `http.post` from `myHelper.foo`; this catalogue can.
31
+ */
32
+ interface SymbolCatalog {
33
+ namespaces(): readonly string[];
34
+ packages(): readonly string[];
35
+ hasNamespace(namespace: string): boolean;
36
+ actionsIn(namespace: string): readonly ActionEntry[];
37
+ action(namespace: string, name: string): ActionEntry | undefined;
38
+ /** The types that namespace publishes: what `http.` offers besides verbs. */
39
+ typesIn(namespace: string): readonly TypeEntry[];
40
+ matchers(): readonly MatcherEntry[];
41
+ matcher(name: string): MatcherEntry | undefined;
42
+ namespaceOfPackage(pkg: string): string | undefined;
43
+ /** Every package contributing this namespace: the `use` options to offer. */
44
+ packagesFor(namespace: string): readonly string[];
45
+ }
46
+ //#endregion
47
+ //#region src/catalog/build-catalog.d.ts
48
+ /**
49
+ * Index the loaded plugins so completion, hover and tokens can look symbols up.
50
+ *
51
+ * @param plugins The plugin definitions loaded for the workspace.
52
+ * @returns A read-only view over their actions, matchers and published types.
53
+ */
54
+ declare function buildCatalog(plugins: readonly PluginDefinition[]): SymbolCatalog;
55
+ //#endregion
56
+ //#region src/types/type-service.d.ts
57
+ /** What inference found for one document: its type errors and every node's type. */
58
+ interface DocumentTypes {
59
+ problems: readonly Problem[];
60
+ types: ReadonlyMap<AstNode, Type>;
61
+ /**
62
+ * Per string literal, the expression inference parsed from each `${…}`. The
63
+ * document's own tree stops at the string, so these are the only nodes the
64
+ * editor can reach for code written inside one.
65
+ */
66
+ slots: ReadonlyMap<AstNode, readonly (Expr | undefined)[]>;
67
+ }
68
+ /**
69
+ * Type information for the workspace, computed once per parse of a document.
70
+ *
71
+ * Inference walks a whole file, and several features want its result:
72
+ * diagnostics on every edit, hover on every mouse move. Without a shared cache
73
+ * the same file is re-checked many times per keystroke; with it, a file is
74
+ * checked once when it changes and every reader is served from memory.
75
+ */
76
+ interface TypeService {
77
+ /** Everything inference knows about this document, cached until it is reparsed. */
78
+ of(document: LangiumDocument): DocumentTypes;
79
+ /** What is already cached, or undefined, for readers that must not block. */
80
+ peek(document: LangiumDocument): DocumentTypes | undefined;
81
+ /** Forget a document: it was deleted, or its folder was closed. */
82
+ forget(uri: string): void;
83
+ }
84
+ //#endregion
85
+ //#region src/workspace/import-resolver.d.ts
86
+ /**
87
+ * Reads the nearest `venn.toml` and answers the project-level questions that
88
+ * depend on it: where an import points, and how this project formats.
89
+ */
90
+ interface ImportResolver {
91
+ resolve(spec: string, base: URI): URI;
92
+ /** The `[paths]` aliases visible from a file, and the folder each maps to. */
93
+ aliases(base: URI): Record<string, URI>;
94
+ /** The raw `[format]` table, for {@link formatOptionsFrom}. */
95
+ formatSettings(base: URI): Record<string, unknown>;
96
+ /** Every variable the project declares: `[env.*]` and the dotenv files. */
97
+ env(base: URI): Record<string, Record<string, string>>;
98
+ /** The comment written above each key in `venn.toml`, as its documentation. */
99
+ envDocs(base: URI): Record<string, string>;
100
+ /**
101
+ * What an installed package publishes, derived at install into `target/types/`.
102
+ *
103
+ * Read here rather than derived here: deriving means loading the TypeScript
104
+ * compiler and reading a package's whole declaration graph, which is a second
105
+ * of work and cannot happen on a keystroke. Nothing installed, or nothing
106
+ * derived yet, means an imported name is `dynamic`, which is the truth about
107
+ * it and not a failure.
108
+ */
109
+ packageTypes(base: URI, packages: readonly string[]): Map<string, Record<string, TypeSpec>>;
110
+ }
111
+ /**
112
+ * Relative specifiers resolve against the importing file; `#alias/…` resolves
113
+ * through the nearest `venn.toml`, searched upwards and cached per directory.
114
+ */
115
+ declare function createImportResolver(): ImportResolver;
116
+ //#endregion
117
+ //#region src/services/lsp.types.d.ts
118
+ /** The extra services Venn adds on top of Langium's LSP stack. */
119
+ interface VennAddedServices {
120
+ catalog: SymbolCatalog;
121
+ imports: ImportResolver;
122
+ types: TypeService;
123
+ }
124
+ /** The full language services for Venn. */
125
+ type VennServices = LangiumServices & VennAddedServices;
126
+ //#endregion
127
+ //#region src/completion/completion.d.ts
128
+ /**
129
+ * Context-aware completion, driven by the text before the cursor.
130
+ *
131
+ * `contextAt` classifies the cursor, and each context has exactly one source of
132
+ * items: a namespace's verbs, an options map's keys, the names in scope.
133
+ */
134
+ declare class VennCompletionProvider implements CompletionProvider {
135
+ private readonly catalog;
136
+ private readonly documents;
137
+ private readonly imports;
138
+ private readonly types;
139
+ constructor(services: VennServices);
140
+ getCompletion(document: LangiumDocument, params: CompletionParams): Promise<CompletionList>;
141
+ /**
142
+ * What follows a dot. A name the file bound wins over a plugin namespace, the
143
+ * same rule the evaluator and the highlighter follow, so a variable named
144
+ * `auth` completes as its own value even when `@venn-lang/auth` is loaded.
145
+ */
146
+ private afterDot;
147
+ /**
148
+ * What follows a dot no name can precede: `(1234.567).`, `f(x).`, `xs[0].`.
149
+ * The receiver has no text to look up, so its inferred type answers.
150
+ */
151
+ private afterExpression;
152
+ private env;
153
+ private itemsFor;
154
+ /**
155
+ * Every name in scope, with an imported one drawn as what it really is.
156
+ *
157
+ * `namesInScope` reads this file's tree, so it can say only that a name came
158
+ * from an import. Its kind lives in the file it came from, which is in reach
159
+ * here, so an imported fragment is drawn as a fragment rather than as an
160
+ * anonymous binding.
161
+ */
162
+ private scopeNames;
163
+ /** What each name this file imported was declared as, in the file it came from. */
164
+ private publishedTo;
165
+ /**
166
+ * `run ▮`: the fragments this file declared, and the ones it imported.
167
+ *
168
+ * `run` can only invoke a fragment, so an imported name is offered only once
169
+ * the file it came from confirms it is one.
170
+ */
171
+ private fragments;
172
+ /** `id: ▮`: the language's own types, this file's, and its imports'. */
173
+ private typeNames;
174
+ /**
175
+ * The last two shapes a cursor can be in before it is simply a new statement:
176
+ * inside a call's brackets, or after a matcher word.
177
+ */
178
+ private fallback;
179
+ /**
180
+ * A fresh statement: the names already bound, then the words that open one.
181
+ *
182
+ * Calling a function is itself a statement, so bound names belong here. They
183
+ * come first because the language's own vocabulary is always available.
184
+ */
185
+ private opening;
186
+ /**
187
+ * `const r = http.get "u" ▮`: a bracket-less call bound to a name.
188
+ *
189
+ * The `argument` context reads the head of the line, which here is `const`
190
+ * rather than the verb. Same words deserve the same help, so it is caught
191
+ * separately.
192
+ */
193
+ private afterBareCall;
194
+ /** What may go in this position: a value, or the options map that ends the call. */
195
+ private dueAt;
196
+ /** `expect res contains ▮`: the value the check is waiting for. */
197
+ private afterMatcher;
198
+ /**
199
+ * `saudacao(▮)`, `fmt.json(x, ▮)`: inside a bracketed call.
200
+ *
201
+ * Reached last, before offering a fresh statement. Everything more specific
202
+ * (a dot, an options key, a bare argument) has already had its turn, so what
203
+ * is left inside brackets is a value.
204
+ */
205
+ private inBrackets;
206
+ /**
207
+ * `http.on ▮`: what the program already holds, before what the stdlib offers.
208
+ * A name the text took for a verb but the language does not know is not an
209
+ * argument position at all, so that falls back to a fresh statement.
210
+ */
211
+ private argument;
212
+ /** What the program holds that could go here, the fitting ones first. */
213
+ private valuesFor;
214
+ private decorators;
215
+ private paths;
216
+ private exports;
217
+ }
218
+ //#endregion
219
+ //#region src/completion/completion.types.d.ts
220
+ /**
221
+ * Where the cursor sits, and from which character the completion should
222
+ * replace. Without that range VS Code falls back to its own word rules, which
223
+ * break on `@` and `/`: accepting `@venn-lang/http` inside `"@venn-lang/"` would paste
224
+ * the prefix twice.
225
+ */
226
+ type CompletionContext = {
227
+ kind: "package";
228
+ from: number;
229
+ } | {
230
+ kind: "modulePath";
231
+ from: number;
232
+ partial: string;
233
+ } | {
234
+ kind: "importName";
235
+ from: number;
236
+ path?: string;
237
+ } | {
238
+ kind: "action";
239
+ from: number;
240
+ receiver: string;
241
+ } | {
242
+ kind: "member";
243
+ from: number;
244
+ } | {
245
+ kind: "annotation";
246
+ from: number;
247
+ } | {
248
+ kind: "fragment";
249
+ from: number;
250
+ } | {
251
+ kind: "matcher";
252
+ from: number;
253
+ } | {
254
+ kind: "optionKey";
255
+ from: number;
256
+ target: string;
257
+ } | {
258
+ kind: "argument";
259
+ from: number;
260
+ target: string;
261
+ } | {
262
+ kind: "typeName";
263
+ from: number;
264
+ } | {
265
+ kind: "statement";
266
+ from: number;
267
+ };
268
+ /** The text the classifier reads: the current line, and everything before the cursor. */
269
+ interface CursorText {
270
+ /** The current line up to the cursor; `from` is a column on this line. */
271
+ prefix: string;
272
+ /** The whole current line. */
273
+ line: string;
274
+ /** The whole document up to the cursor; an options map spans lines. */
275
+ before: string;
276
+ }
277
+ //#endregion
278
+ //#region src/completion/context.d.ts
279
+ /**
280
+ * Classify the cursor from the text before it. String contexts are tested first:
281
+ * a module path like `#shared/auth.vn` also looks like `namespace.action`.
282
+ *
283
+ * @param text The line, the prefix up to the cursor and the document before it.
284
+ * @returns The narrowest context that matches, or `statement` when none does.
285
+ */
286
+ declare function contextAt(text: CursorText): CompletionContext;
287
+ //#endregion
288
+ //#region src/completion/module-paths.d.ts
289
+ interface PathArgs {
290
+ partial: string;
291
+ base: URI;
292
+ imports: ImportResolver;
293
+ }
294
+ /**
295
+ * What may follow `from "`: a `#alias/…` path from `venn.toml`, or a relative
296
+ * path to a sibling `.vn` file. The `#` only marks an alias; plain relative
297
+ * paths need no prefix.
298
+ *
299
+ * @returns Path strings ready to insert, without the surrounding quotes.
300
+ */
301
+ declare function modulePaths(args: PathArgs): string[];
302
+ //#endregion
303
+ //#region src/deco/deco.types.d.ts
304
+ /**
305
+ * One decorator a `@name` could mean here: a `deco` some file declares, or one
306
+ * the language ships with.
307
+ *
308
+ * `decorates` is in the language's own words (`Fn`, `Flow`, `Step`), never a
309
+ * node type. What a decorator applies to is part of its signature, so reading
310
+ * one costs nobody a lesson in the compiler's vocabulary.
311
+ */
312
+ interface DecoInfo {
313
+ name: string;
314
+ /** The kinds it may sit on. Empty means it constrains nothing. */
315
+ decorates: readonly string[];
316
+ /** The line a hover fences: `pub deco retry(target: Flow, times: number)`. */
317
+ signature: string;
318
+ doc?: string;
319
+ /** The declaration, when a `.vn` declares it: where go-to-definition lands. */
320
+ decl?: DecoDecl;
321
+ /** The document holding {@link decl}. Absent for a built-in. */
322
+ document?: LangiumDocument;
323
+ }
324
+ //#endregion
325
+ //#region src/deco/builtin-decos.d.ts
326
+ /**
327
+ * The decorators every file has without asking: the ones the runtime ships.
328
+ * They are read through the same shape a declared `deco` produces, so the
329
+ * editor holds one notion of what a decorator is rather than two.
330
+ */
331
+ declare function builtinDecos(): DecoInfo[];
332
+ //#endregion
333
+ //#region src/deco/decos-in-scope.d.ts
334
+ /** What a file needs consulted before it can say what `@name` means. */
335
+ interface DecoScope {
336
+ document: LangiumDocument;
337
+ documents: LangiumDocuments;
338
+ imports: ImportResolver;
339
+ }
340
+ /**
341
+ * Every decorator a `@name` written in this file could mean: the ones the
342
+ * language ships with, the `pub deco`s it imported, and the `deco`s it declares
343
+ * itself.
344
+ *
345
+ * Later wins, on the same rule the runtime already follows for plugins: the
346
+ * built-ins are a stdlib, not a reserved word list, so a file that declares its
347
+ * own `deco retry` means its own.
348
+ */
349
+ declare function decosInScope(scope: DecoScope): Promise<DecoInfo[]>;
350
+ /** The decorator a `@name` resolves to, or nothing when no decorator carries it. */
351
+ declare function decoNamed(name: string, scope: DecoScope): Promise<DecoInfo | undefined>;
352
+ //#endregion
353
+ //#region src/definition/definition.d.ts
354
+ /** Ctrl+Click: `run` fragments (local or imported), bindings, and imported files. */
355
+ declare class VennDefinitionProvider implements DefinitionProvider {
356
+ private readonly documents;
357
+ private readonly imports;
358
+ constructor(services: VennServices);
359
+ getDefinition(document: LangiumDocument, params: DefinitionParams): Promise<LocationLink[] | undefined>;
360
+ /** `"${base}/users"`: the name inside the placeholder is a real reference. */
361
+ private interpolated;
362
+ private resolve;
363
+ private decorator;
364
+ private fragment;
365
+ }
366
+ //#endregion
367
+ //#region src/docs/doc.types.d.ts
368
+ /** One documented parameter. */
369
+ interface DocParam {
370
+ name: string;
371
+ text: string;
372
+ }
373
+ /**
374
+ * A parsed documentation block: the `##` lines above a declaration, or its
375
+ * `@doc("…")` annotation (§08). Summary and every field are markdown.
376
+ */
377
+ interface DocBlock {
378
+ summary: string;
379
+ params: DocParam[];
380
+ returns?: string;
381
+ examples: string[];
382
+ deprecated?: string;
383
+ }
384
+ //#endregion
385
+ //#region src/docs/parse-doc.d.ts
386
+ /** Split doc lines into a summary plus `@param` / `@returns` / `@example` / `@deprecated`. */
387
+ declare function parseDoc(lines: readonly string[]): DocBlock;
388
+ //#endregion
389
+ //#region src/docs/read-doc.d.ts
390
+ /**
391
+ * The documentation attached to a declaration: a `##` block directly above it,
392
+ * or its `@doc("…")` annotation (§08). `##` wins when both are present.
393
+ *
394
+ * @returns The parsed block, or `undefined` when the declaration has neither.
395
+ */
396
+ declare function readDoc(document: LangiumDocument, node: AstNode): DocBlock | undefined;
397
+ //#endregion
398
+ //#region src/docs/render-doc.d.ts
399
+ /**
400
+ * Render a doc block. The prose keeps its own paragraph rhythm; the tagged
401
+ * sections sit below a rule so they read as a distinct band, not as more prose.
402
+ *
403
+ * @returns Markdown, or `undefined` when the block has nothing worth showing.
404
+ */
405
+ declare function renderDoc(doc: DocBlock | undefined): string | undefined;
406
+ //#endregion
407
+ //#region src/document/exported-names.d.ts
408
+ /** A name a module publishes, and which kind of thing it is. */
409
+ interface ExportedName {
410
+ name: string;
411
+ /** `fragment`, `fn` or `deco`: what the editor draws it as. */
412
+ origin: string;
413
+ }
414
+ /**
415
+ * The names a module marks `pub`: everything another file is allowed to import.
416
+ * A `deco` crosses files like a fragment or a function does.
417
+ *
418
+ * The kind travels with the name because the two are read together everywhere:
419
+ * an `import { … }` list draws a fragment apart from a function, and `run`
420
+ * accepts only one of them.
421
+ */
422
+ declare function exportedNames(document: Document): ExportedName[];
423
+ //#endregion
424
+ //#region src/document/find-binding.d.ts
425
+ /** The node that binds `name`, searched from `from` outwards to the document. */
426
+ declare function findBinding(from: AstNode, name: string): AstNode | undefined;
427
+ /** The fragment a document declares under `name`. */
428
+ declare function findFragment(document: Document, name: string): FragmentDecl | undefined;
429
+ //#endregion
430
+ //#region src/document/imported-names.d.ts
431
+ /** The names a document pulls in via `import { a, b } from "…"`. */
432
+ declare function importedNames(document: Document): string[];
433
+ //#endregion
434
+ //#region src/document/resolve-fragment.d.ts
435
+ /** Where a fragment lives. `decl` is absent when the file could not be read. */
436
+ interface FragmentLocation {
437
+ uri: URI;
438
+ decl?: FragmentDecl;
439
+ document?: LangiumDocument;
440
+ }
441
+ interface ResolveFragmentArgs {
442
+ name: string;
443
+ document: LangiumDocument;
444
+ documents: LangiumDocuments;
445
+ imports: ImportResolver;
446
+ }
447
+ /** Find a fragment: declared in this file, or followed through the `import` naming it. */
448
+ declare function resolveFragment(args: ResolveFragmentArgs): Promise<FragmentLocation | undefined>;
449
+ //#endregion
450
+ //#region src/formatting/formatter.d.ts
451
+ /**
452
+ * Formatting runs through `@venn-lang/core`, so the editor and `venn fmt` produce
453
+ * byte-identical output. Project settings come from `[format]` in `venn.toml`;
454
+ * the editor's own indent settings fill in what the project left unset.
455
+ */
456
+ declare class VennFormatter implements Formatter {
457
+ private readonly imports;
458
+ constructor(services: VennServices);
459
+ /** Re-indent the line as soon as a block is closed. */
460
+ get formatOnTypeOptions(): DocumentOnTypeFormattingOptions;
461
+ formatDocument(document: LangiumDocument, params: DocumentFormattingParams): TextEdit[];
462
+ formatDocumentRange(document: LangiumDocument, params: DocumentRangeFormattingParams): TextEdit[];
463
+ formatDocumentOnType(document: LangiumDocument, params: DocumentOnTypeFormattingParams): TextEdit[];
464
+ private rewrite;
465
+ }
466
+ //#endregion
467
+ //#region src/hover/hover.d.ts
468
+ /**
469
+ * Rich markdown hover: actions, matchers, fragments, bindings and keywords.
470
+ *
471
+ * Which token the cursor sits on decides the answer, so every branch checks the
472
+ * CST property it belongs to rather than the enclosing node alone.
473
+ */
474
+ declare class VennHoverProvider implements HoverProvider {
475
+ private readonly catalog;
476
+ private readonly documents;
477
+ private readonly imports;
478
+ private readonly types;
479
+ constructor(services: VennServices);
480
+ getHoverContent(document: LangiumDocument, params: HoverParams): Promise<Hover | undefined>;
481
+ /** Inside `"${…}"` the name is code, so it hovers like code, not like text. */
482
+ private inString;
483
+ /**
484
+ * A member read off the node rather than off the text.
485
+ *
486
+ * The dotted-path resolver can only name a chain of identifiers, so it has
487
+ * nothing to say about `(1234.567).round` or `f(x).len`. The receiver's
488
+ * inferred type is right there on the tree, so read it from there instead.
489
+ */
490
+ private member;
491
+ /** The one resolver every place uses, so a name reads the same anywhere. */
492
+ private resolve;
493
+ /** Which of this file's functions wait for something, for the signature to say so. */
494
+ private waits;
495
+ /** `env.NAME` is not a variable anyone declared here; `venn.toml` declares it. */
496
+ private envVar;
497
+ private describe;
498
+ private symbol;
499
+ /**
500
+ * A name in an `import` list, or the specifier it comes from.
501
+ *
502
+ * The list is the one place a name is neither declared nor used, so no other
503
+ * branch reaches it. It is also where a reader is deciding whether they want
504
+ * the thing at all, which is where a hover is worth the most.
505
+ */
506
+ private imported;
507
+ /**
508
+ * The verb of a call written as a statement.
509
+ *
510
+ * Usually a plugin's, as in `http.get`. But `target.wrap(…)` is a method on a
511
+ * value, and the parser reads it as a call whose target is text, so the
512
+ * member chain a hover normally walks does not exist. Resolving from that
513
+ * text puts it back, which is why hovering `target` inside a `deco` answers.
514
+ */
515
+ private callTarget;
516
+ /**
517
+ * A dotted path written plainly: `fmt.json`, `xs.map`, `range`. The segment
518
+ * under the cursor decides what is described: the namespace, or its verb.
519
+ */
520
+ private pathHover;
521
+ private declared;
522
+ /**
523
+ * `@name`: whatever defines it. A `deco` this file declares or imported, or
524
+ * a built-in; either way the same text a hover on the `deco` itself gives.
525
+ */
526
+ private decorator;
527
+ private fragment;
528
+ }
529
+ //#endregion
530
+ //#region src/references/document-highlight.d.ts
531
+ /**
532
+ * The other places the name under the cursor appears, marked in this file.
533
+ *
534
+ * Only this file, whatever the symbol's reach: highlighting is about the page
535
+ * being read. Where the name is introduced is drawn apart from where it is
536
+ * used, which is the quickest way to see that a value is written once and read
537
+ * four times, or written twice, which is usually the bug being looked for.
538
+ */
539
+ declare class VennDocumentHighlightProvider implements DocumentHighlightProvider {
540
+ getDocumentHighlight(document: LangiumDocument, params: DocumentHighlightParams): DocumentHighlight[];
541
+ }
542
+ //#endregion
543
+ //#region src/references/symbol.types.d.ts
544
+ /**
545
+ * What a name under the cursor turns out to be.
546
+ *
547
+ * The kinds differ in one thing that decides everything downstream: how far the
548
+ * name reaches. A `fragment`, a `deco` and a `pub fn` cross files, so finding
549
+ * every use means reading the workspace. A `const`, a parameter or a loop
550
+ * variable is bound in one place in one file, and a name spelled the same
551
+ * anywhere else is a different name: following it out of the file would report
552
+ * strangers as references.
553
+ */
554
+ type SymbolKind$1 = "fragment" | "deco" | "fn" | "type" | "binding" | "external";
555
+ interface FoundSymbol {
556
+ kind: SymbolKind$1;
557
+ name: string;
558
+ /**
559
+ * The node that binds it, when the kind is file-scoped. Two `const`s of the
560
+ * same name in one file are two symbols, and this is what tells them apart.
561
+ */
562
+ binding?: AstNode;
563
+ }
564
+ /** One place a name appears, named by the property of the node that holds it. */
565
+ interface Occurrence {
566
+ node: AstNode;
567
+ property: string;
568
+ /** For a list-valued property: the names inside `import { a, b }`. */
569
+ index?: number;
570
+ /** Whether this is where the name is introduced, rather than used. */
571
+ declaration: boolean;
572
+ }
573
+ //#endregion
574
+ //#region src/references/find-occurrences.d.ts
575
+ /** One document's share of the answer. */
576
+ interface FoundIn {
577
+ uri: string;
578
+ occurrences: readonly Occurrence[];
579
+ }
580
+ /**
581
+ * Every place a symbol appears, in the file that asked and in the workspace
582
+ * when the symbol reaches that far.
583
+ *
584
+ * A file-scoped binding is never searched for elsewhere. That is not an
585
+ * optimisation: a `const` named `user` next door is a different `user`, and
586
+ * offering it as a reference sends the reader somewhere unrelated.
587
+ */
588
+ declare function findOccurrences(args: {
589
+ symbol: FoundSymbol;
590
+ document: LangiumDocument;
591
+ documents: LangiumDocuments;
592
+ }): FoundIn[];
593
+ //#endregion
594
+ //#region src/references/occurrences.d.ts
595
+ /**
596
+ * Every place one symbol appears in one document.
597
+ *
598
+ * One walk, one answer, whatever the caller wants it for: "find all references"
599
+ * shows them, the editor highlights them, and rename rewrites them. Three
600
+ * separate readings of the tree would be three chances to disagree.
601
+ */
602
+ declare function occurrencesIn(args: {
603
+ root: Document;
604
+ symbol: FoundSymbol;
605
+ }): Occurrence[];
606
+ //#endregion
607
+ //#region src/references/references.d.ts
608
+ /**
609
+ * Shift+F12: every place a name is used.
610
+ *
611
+ * Langium's own provider resolves cross-references the grammar declares, and
612
+ * this grammar declares none: a `run` target is a string, a `@name` is a string,
613
+ * and which `const` a `Ref` means is worked out by walking scopes. So the answer
614
+ * has to be worked out the same way the checker and the evaluator work it out,
615
+ * which is what this shares with them.
616
+ */
617
+ declare class VennReferencesProvider implements ReferencesProvider {
618
+ private readonly documents;
619
+ constructor(services: VennServices);
620
+ findReferences(document: LangiumDocument, params: ReferenceParams): Location[];
621
+ }
622
+ //#endregion
623
+ //#region src/references/symbol-at.d.ts
624
+ /**
625
+ * The symbol a position names, or nothing when it names none.
626
+ *
627
+ * Read from the token under the cursor rather than from the node containing it:
628
+ * one node often carries two names (`import { a, b }` is a single node, and so
629
+ * is `run login("x")`), and the answer depends on which word was clicked.
630
+ */
631
+ declare function symbolAt(document: LangiumDocument, position: Position): FoundSymbol | undefined;
632
+ //#endregion
633
+ //#region src/rename/rename.d.ts
634
+ /**
635
+ * F2: rename a name wherever it means this one.
636
+ *
637
+ * Reads the same occurrences "find all references" reports, so the two cannot
638
+ * disagree. A rename that silently misses a use is worse than no rename at all.
639
+ */
640
+ declare class VennRenameProvider implements RenameProvider {
641
+ private readonly documents;
642
+ constructor(services: VennServices);
643
+ rename(document: LangiumDocument, params: RenameParams): WorkspaceEdit | undefined;
644
+ prepareRename(document: LangiumDocument, params: PrepareRenameParams): Range | undefined;
645
+ /**
646
+ * The symbol under the cursor, when it is one this can rewrite.
647
+ *
648
+ * A built-in decorator has no source to rewrite, and changing one use of it
649
+ * would break the program while looking like a rename.
650
+ */
651
+ private wanted;
652
+ }
653
+ //#endregion
654
+ //#region src/semantic/semantic-tokens.d.ts
655
+ /**
656
+ * Colours a `.vn` the way §23 specifies. The grammar cannot tell `http.post`
657
+ * from `myHelper.foo`, since both are `ActionCall`, so the catalog decides.
658
+ * Each pass owns one family of tokens, and a node matches at most one of them.
659
+ */
660
+ declare class VennSemanticTokenProvider extends AbstractSemanticTokenProvider {
661
+ private readonly catalog;
662
+ constructor(services: VennServices);
663
+ protected override highlightElement(node: AstNode$1, acceptor: SemanticTokenAcceptor): void;
664
+ }
665
+ //#endregion
666
+ //#region src/server/start-server.d.ts
667
+ /**
668
+ * Start the Venn language server on an established connection. This is the one
669
+ * wiring shared by the standalone `venn-lsp` binary and the VS Code extension.
670
+ *
671
+ * @param connection An LSP connection the caller has already created.
672
+ */
673
+ declare function startVennServer(connection: Connection): void;
674
+ //#endregion
675
+ //#region src/services/venn-lsp-module.d.ts
676
+ /**
677
+ * Build the Venn language services on top of Langium's LSP stack. Registering
678
+ * the validator and warming the type cache happen here, so a caller only has to
679
+ * supply a connection and start the server.
680
+ *
681
+ * @param context Langium's shared module context: a connection and a file system.
682
+ * @returns The shared Langium services, and the Venn services built on them.
683
+ */
684
+ declare function createVennLspServices(context: DefaultSharedModuleContext): {
685
+ shared: LangiumSharedServices;
686
+ Venn: VennServices;
687
+ };
688
+ //#endregion
689
+ //#region src/signature/signature-help.d.ts
690
+ /**
691
+ * What the call being typed takes, one argument at a time.
692
+ *
693
+ * The space is a trigger character because Venn's calls have no brackets to
694
+ * hang one off: `http.on ` is already a call with an argument due. Waiting for
695
+ * a `(` that never comes is how a language ends up unable to explain itself.
696
+ */
697
+ declare class VennSignatureHelpProvider implements SignatureHelpProvider {
698
+ private readonly catalog;
699
+ private readonly types;
700
+ constructor(services: VennServices);
701
+ get signatureHelpOptions(): SignatureHelpOptions;
702
+ provideSignatureHelp(document: LangiumDocument, params: SignatureHelpParams): SignatureHelp | undefined;
703
+ /** `saudacao(▮)`: a call with brackets, wherever its callee was declared. */
704
+ private forParens;
705
+ /** `expect res contains ▮`: the value the check is waiting for. */
706
+ private forMatcher;
707
+ /** `http.on api handler`: a verb and its bare arguments, bound or not. */
708
+ private forAction;
709
+ }
710
+ //#endregion
711
+ //#region src/symbols/document-symbols.d.ts
712
+ /** The outline: flows with their steps and groups, plus fragments and resources. */
713
+ declare class VennDocumentSymbolProvider implements DocumentSymbolProvider {
714
+ getSymbols(document: LangiumDocument): DocumentSymbol[];
715
+ }
716
+ //#endregion
717
+ //#region src/validation/check-validator.d.ts
718
+ /** Wire the runtime's static check (VN2003/4/5) into the editor's diagnostics. */
719
+ declare function registerVennChecks(services: VennServices): void;
720
+ //#endregion
721
+ export { type ActionEntry, type CompletionContext, type DecoInfo, type DecoScope, type DocBlock, type DocParam, type FragmentLocation, type ImportResolver, type MatcherEntry, type SymbolCatalog, type VennAddedServices, VennCompletionProvider, VennDefinitionProvider, VennDocumentHighlightProvider, VennDocumentSymbolProvider, VennFormatter, VennHoverProvider, VennReferencesProvider, VennRenameProvider, VennSemanticTokenProvider, type VennServices, VennSignatureHelpProvider, buildCatalog, builtinDecos, contextAt, createImportResolver, createVennLspServices, decoNamed, decosInScope, exportedNames, findBinding, findFragment, findOccurrences, importedNames, modulePaths, occurrencesIn, parseDoc, readDoc, registerVennChecks, renderDoc, resolveFragment, startVennServer, symbolAt };
722
+ //# sourceMappingURL=index.d.mts.map