@hydranium/cli 1.0.0-next.24 → 1.0.0-next.241
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/README.md +39 -18
- package/bin/hydranium-cli.js +13 -0
- package/lib/cli-version.js.map +1 -1
- package/lib/cli.js +0 -0
- package/lib/commands/analyze-heap-args.js.map +1 -1
- package/lib/commands/analyze-heap.d.ts +3 -0
- package/lib/commands/analyze-heap.d.ts.map +1 -1
- package/lib/commands/analyze-heap.js +2 -1
- package/lib/commands/analyze-heap.js.map +1 -1
- package/lib/commands/ast-ground-truth-args.d.ts +3 -2
- package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
- package/lib/commands/ast-ground-truth-args.js +11 -9
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/ast-ground-truth.js +1 -1
- package/lib/commands/ast-ground-truth.js.map +1 -1
- package/lib/commands/generate-ast-builder.d.ts +49 -0
- package/lib/commands/generate-ast-builder.d.ts.map +1 -0
- package/lib/commands/generate-ast-builder.js +200 -0
- package/lib/commands/generate-ast-builder.js.map +1 -0
- package/lib/commands/generate-transfer-model-args.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-args.js +11 -1
- package/lib/commands/generate-transfer-model-args.js.map +1 -1
- package/lib/commands/generate-transfer-model-config.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-config.js +3 -1
- package/lib/commands/generate-transfer-model-config.js.map +1 -1
- package/lib/commands/generate-transfer-model.d.ts +9 -0
- package/lib/commands/generate-transfer-model.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model.js +16 -3
- package/lib/commands/generate-transfer-model.js.map +1 -1
- package/lib/commands/harness-args.d.ts +37 -42
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +65 -25
- package/lib/commands/harness-args.js.map +1 -1
- package/lib/commands/headless-harness.d.ts +37 -20
- package/lib/commands/headless-harness.d.ts.map +1 -1
- package/lib/commands/headless-harness.js +68 -17
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/init-args.js +6 -6
- package/lib/commands/init-args.js.map +1 -1
- package/lib/commands/init-prompt.d.ts.map +1 -1
- package/lib/commands/init-templates.d.ts +8 -10
- package/lib/commands/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +245 -140
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-wizard.js +4 -4
- package/lib/commands/init-wizard.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +13 -3
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +21 -6
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +16 -10
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +17 -15
- package/lib/commands/init.js.map +1 -1
- package/lib/commands/lint-grammar-args.d.ts +3 -2
- package/lib/commands/lint-grammar-args.d.ts.map +1 -1
- package/lib/commands/lint-grammar-args.js +13 -10
- package/lib/commands/lint-grammar-args.js.map +1 -1
- package/lib/commands/lint-grammar-report.js.map +1 -1
- package/lib/commands/lint-grammar.js +1 -1
- package/lib/commands/lint-grammar.js.map +1 -1
- package/lib/commands/measure-memory-args.d.ts +3 -2
- package/lib/commands/measure-memory-args.d.ts.map +1 -1
- package/lib/commands/measure-memory-args.js +20 -10
- package/lib/commands/measure-memory-args.js.map +1 -1
- package/lib/commands/measure-memory-driver.js +3 -2
- package/lib/commands/measure-memory-driver.js.map +1 -1
- package/lib/commands/measure-memory.js +1 -1
- package/lib/commands/measure-memory.js.map +1 -1
- package/lib/commands/model-docs-args.d.ts +4 -3
- package/lib/commands/model-docs-args.d.ts.map +1 -1
- package/lib/commands/model-docs-args.js +12 -10
- package/lib/commands/model-docs-args.js.map +1 -1
- package/lib/commands/model-docs.js +1 -1
- package/lib/commands/model-docs.js.map +1 -1
- package/lib/commands/projects-args.d.ts.map +1 -1
- package/lib/commands/projects-args.js +5 -5
- package/lib/commands/projects-args.js.map +1 -1
- package/lib/commands/projects.d.ts +3 -4
- package/lib/commands/projects.d.ts.map +1 -1
- package/lib/commands/projects.js +2 -2
- package/lib/commands/projects.js.map +1 -1
- package/lib/commands/query-args.d.ts.map +1 -1
- package/lib/commands/query-args.js +5 -5
- package/lib/commands/query-args.js.map +1 -1
- package/lib/commands/query.d.ts +3 -4
- package/lib/commands/query.d.ts.map +1 -1
- package/lib/commands/query.js +2 -2
- package/lib/commands/query.js.map +1 -1
- package/lib/commands/reflect-args.d.ts +3 -2
- package/lib/commands/reflect-args.d.ts.map +1 -1
- package/lib/commands/reflect-args.js +13 -10
- package/lib/commands/reflect-args.js.map +1 -1
- package/lib/commands/reflect-report.js.map +1 -1
- package/lib/commands/reflect.js +1 -1
- package/lib/commands/reflect.js.map +1 -1
- package/lib/commands/save-args.d.ts.map +1 -1
- package/lib/commands/save-args.js +6 -4
- package/lib/commands/save-args.js.map +1 -1
- package/lib/commands/save.d.ts +8 -4
- package/lib/commands/save.d.ts.map +1 -1
- package/lib/commands/save.js +31 -6
- package/lib/commands/save.js.map +1 -1
- package/lib/commands/validate-args.d.ts +3 -2
- package/lib/commands/validate-args.d.ts.map +1 -1
- package/lib/commands/validate-args.js +13 -10
- package/lib/commands/validate-args.js.map +1 -1
- package/lib/commands/validate-report.js.map +1 -1
- package/lib/commands/validate.js +1 -1
- package/lib/commands/validate.js.map +1 -1
- package/lib/commands/watch-args.d.ts.map +1 -1
- package/lib/commands/watch-args.js +6 -4
- package/lib/commands/watch-args.js.map +1 -1
- package/lib/commands/watch.d.ts +3 -4
- package/lib/commands/watch.d.ts.map +1 -1
- package/lib/commands/watch.js +20 -2
- package/lib/commands/watch.js.map +1 -1
- package/lib/driver-heap.d.ts +52 -0
- package/lib/driver-heap.d.ts.map +1 -0
- package/lib/driver-heap.js +51 -0
- package/lib/driver-heap.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/log-level.d.ts +21 -11
- package/lib/log-level.d.ts.map +1 -1
- package/lib/log-level.js +25 -14
- package/lib/log-level.js.map +1 -1
- package/lib/spawn-data-server.d.ts +6 -1
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +2 -1
- package/lib/spawn-data-server.js.map +1 -1
- package/lib/stderr-connection-logger.d.ts +12 -0
- package/lib/stderr-connection-logger.d.ts.map +1 -0
- package/lib/stderr-connection-logger.js +16 -0
- package/lib/stderr-connection-logger.js.map +1 -0
- package/lib/testing/echo-server.js +8 -1
- package/lib/testing/echo-server.js.map +1 -1
- package/package.json +39 -39
- package/src/commands/analyze-heap.ts +4 -1
- package/src/commands/ast-ground-truth-args.ts +15 -12
- package/src/commands/ast-ground-truth.ts +1 -1
- package/src/commands/generate-ast-builder.ts +246 -0
- package/src/commands/generate-transfer-model-args.ts +11 -1
- package/src/commands/generate-transfer-model-config.ts +3 -1
- package/src/commands/generate-transfer-model.ts +25 -3
- package/src/commands/harness-args.ts +73 -28
- package/src/commands/headless-harness.ts +86 -26
- package/src/commands/init-args.ts +6 -6
- package/src/commands/init-templates.ts +255 -142
- package/src/commands/init-wizard.ts +4 -4
- package/src/commands/init-workspace.ts +31 -7
- package/src/commands/init.ts +36 -26
- package/src/commands/lint-grammar-args.ts +17 -13
- package/src/commands/lint-grammar.ts +1 -1
- package/src/commands/measure-memory-args.ts +25 -13
- package/src/commands/measure-memory-driver.ts +3 -2
- package/src/commands/measure-memory.ts +1 -1
- package/src/commands/model-docs-args.ts +16 -13
- package/src/commands/model-docs.ts +1 -1
- package/src/commands/projects-args.ts +5 -4
- package/src/commands/projects.ts +4 -6
- package/src/commands/query-args.ts +5 -4
- package/src/commands/query.ts +4 -6
- package/src/commands/reflect-args.ts +17 -13
- package/src/commands/reflect.ts +1 -1
- package/src/commands/save-args.ts +6 -3
- package/src/commands/save.ts +49 -10
- package/src/commands/validate-args.ts +17 -13
- package/src/commands/validate.ts +1 -1
- package/src/commands/watch-args.ts +6 -3
- package/src/commands/watch.ts +28 -7
- package/src/driver-heap.ts +65 -0
- package/src/index.ts +1 -0
- package/src/log-level.ts +42 -14
- package/src/spawn-data-server.ts +14 -2
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +10 -2
package/README.md
CHANGED
|
@@ -27,12 +27,6 @@ operations against a spawned data-server.
|
|
|
27
27
|
|
|
28
28
|
## Install
|
|
29
29
|
|
|
30
|
-
> **Nothing in `@hydranium/*` is on npm yet**, so every `npx` line below
|
|
31
|
-
> resolves to no package and fails with `E404`. Until the first release the CLI
|
|
32
|
-
> is reachable only from a clone of this repository: run `npm run build`, then
|
|
33
|
-
> substitute `node packages/cli/lib/cli.js` for the `npx …` prefix. Subcommands,
|
|
34
|
-
> flags and output are the same either way.
|
|
35
|
-
|
|
36
30
|
`init` needs no install at all:
|
|
37
31
|
|
|
38
32
|
```bash
|
|
@@ -61,6 +55,14 @@ Most subcommands take `--services <module>`: an ESM module exporting a zero-arg
|
|
|
61
55
|
`createServices(): { shared }` thunk — normally your build's `./lib/services.js`. The head wires its
|
|
62
56
|
own filesystem inside, so the CLI boots it with no arguments.
|
|
63
57
|
|
|
58
|
+
To run the head from its TypeScript source instead, register a loader with `--import <specifier>`
|
|
59
|
+
(repeatable), which the CLI passes as Node's own `--import` to the process that imports the head:
|
|
60
|
+
`npx hydranium-cli reflect --import tsx --services ./src/services.ts`. A package name resolves from
|
|
61
|
+
the directory the command runs in, as Node's flag does; a path, absolute or relative, is resolved
|
|
62
|
+
against that directory and passed on as a file URL, so Windows paths work too. Node's built-in type
|
|
63
|
+
stripping is not enough on its own: it neither maps a head's `./x.js` imports to their `.ts` sources
|
|
64
|
+
nor accepts the namespaces Langium generates.
|
|
65
|
+
|
|
64
66
|
**Scaffolding**
|
|
65
67
|
|
|
66
68
|
- `init <target-dir>` — scaffold a new language project. See the section below.
|
|
@@ -106,6 +108,20 @@ plausibly non-zero and cannot be read as the tell.
|
|
|
106
108
|
declared alongside every other subcommand's, so an unrecognised one is rejected rather than
|
|
107
109
|
ignored.
|
|
108
110
|
|
|
111
|
+
**Child-process heap ceiling** (`HYDRANIUM_CLI_MAX_OLD_SPACE_MB`)
|
|
112
|
+
|
|
113
|
+
Subcommands that spawn a child — `analyze-heap`, `measure-memory`, `validate`, `lint-grammar`,
|
|
114
|
+
`reflect`, `model-docs`, `ast-ground-truth` — give it `--max-old-space-size=8192` on a machine with
|
|
115
|
+
no cgroup memory limit, and **no ceiling at all when there is one**. A ceiling above the limit lets
|
|
116
|
+
V8 grow past it without collecting hard, so the kernel kills the container rather than the child
|
|
117
|
+
reporting a heap error.
|
|
118
|
+
|
|
119
|
+
Under a limit, Node derives its own ceiling from that limit, which is a fraction of it — so a
|
|
120
|
+
roomy container gives a child less than the same machine would unconstrained. Set
|
|
121
|
+
`HYDRANIUM_CLI_MAX_OLD_SPACE_MB` to state a ceiling in MiB; it wins in a container too. `0` means
|
|
122
|
+
"let Node decide". A value below 256, or one carrying a unit suffix, is reported and ignored rather
|
|
123
|
+
than passed on.
|
|
124
|
+
|
|
109
125
|
**Data-server operations** (`--server "<cmd> [args...]"`)
|
|
110
126
|
|
|
111
127
|
These spawn a data-server child and talk to it over its protocol. All four also take `--cwd <dir>`
|
|
@@ -141,8 +157,8 @@ hydranium-cli projects --server "node ./lib/data-server-main.js ./models"
|
|
|
141
157
|
|
|
142
158
|
`init` writes a project you can build immediately, and it writes **only inside the target
|
|
143
159
|
directory** — it refuses a non-empty directory without `--force`, and it never edits a surrounding
|
|
144
|
-
manifest (a root `workspaces` entry
|
|
145
|
-
or `langium generate`; both are printed as next steps.
|
|
160
|
+
manifest (a root `workspaces` entry and dependency pins are printed, not added). It also does
|
|
161
|
+
**not** run `npm install` or `langium generate`; both are printed as next steps.
|
|
146
162
|
|
|
147
163
|
Project options are position-free:
|
|
148
164
|
|
|
@@ -152,6 +168,9 @@ Project options are position-free:
|
|
|
152
168
|
mandatory — it owns the workspace, the build pipeline and the shared tier the others read through.
|
|
153
169
|
- `--monorepo` scaffolds a member of the surrounding npm workspace, `--scope <@scope>` sets the npm
|
|
154
170
|
scope, `--public` drops the emitted `"private": true`, `--force` allows a non-empty directory.
|
|
171
|
+
`--monorepo` also prints the exact pins, `langium` and the LSP stack among them, for the root's
|
|
172
|
+
`devDependencies`: npm installs a root's own dependencies at the top of the tree, so another
|
|
173
|
+
member's version cannot leave this package on a copy the framework does not share.
|
|
155
174
|
|
|
156
175
|
The emitted manifest carries `files` (`lib`, `src`, `syntaxes`), a derived `description` and
|
|
157
176
|
`keywords`, and an empty `author` for you to fill. It is `"private": true` unless you pass
|
|
@@ -188,6 +207,10 @@ npm install
|
|
|
188
207
|
npm run build # langium generate + tsc, into lib/
|
|
189
208
|
npm test # the scaffolded DI-composition test
|
|
190
209
|
|
|
210
|
+
# A model to work on: the starter grammar's nodes, one referencing the other
|
|
211
|
+
mkdir models
|
|
212
|
+
printf 'node Start -> End\nnode End\n' > models/first.my-lang
|
|
213
|
+
|
|
191
214
|
# The editor entry: LSP on stdio, every other head on a published socket
|
|
192
215
|
node lib/main.js --stdio
|
|
193
216
|
|
|
@@ -206,18 +229,15 @@ npx @hydranium/cli init ./order-flow --name OrderFlow --heads lsp,data,glsp \
|
|
|
206
229
|
--grammar Layout --extensions diagram
|
|
207
230
|
```
|
|
208
231
|
|
|
209
|
-
The scaffold wires only the framework defaults. The seams a real language customizes are
|
|
210
|
-
|
|
211
|
-
[`docs/concepts/framework-vs-adopter.md`](../../docs/concepts/framework-vs-adopter.md).
|
|
232
|
+
The scaffold wires only the framework defaults. The seams a real language customizes are in
|
|
233
|
+
[Adopting Hydranium](../../docs/ADOPTING.md).
|
|
212
234
|
|
|
213
235
|
## Entry points
|
|
214
236
|
|
|
215
237
|
This package declares a two-key `exports` map — the root barrel and the CLI
|
|
216
|
-
binary — plus a `main` and a `bin`. The binary key
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
resolvers as it stands. A consumer that spawns the binary resolves it by
|
|
220
|
-
specifier, and `bin` offers a shim on `PATH` rather than a path.
|
|
238
|
+
binary — plus a `main` and a `bin`. The binary key names the file, `./lib/cli.js`:
|
|
239
|
+
a consumer that spawns the binary resolves it by specifier, and `bin` offers a
|
|
240
|
+
shim on `PATH` rather than a path.
|
|
221
241
|
|
|
222
242
|
| Entry | Kind | Contents |
|
|
223
243
|
| ---------------- | ------ | -------------------------------- |
|
|
@@ -231,8 +251,9 @@ and the `runProjects` / `runQuery` / `runSave` / `runWatch` command bodies.
|
|
|
231
251
|
|
|
232
252
|
## Status
|
|
233
253
|
|
|
234
|
-
Alpha — pre-v0,
|
|
235
|
-
moving. See the [repository README](../../README.md)
|
|
254
|
+
Alpha — pre-v0, published as a `1.0.0-next` prerelease on every merge to `main`. The subcommand
|
|
255
|
+
surface and the programmatic API are both still moving. See the [repository README](../../README.md)
|
|
256
|
+
for the current status and known limitations.
|
|
236
257
|
|
|
237
258
|
## License
|
|
238
259
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
|
|
11
|
+
// Committed rather than built, so the first install of a fresh clone links it:
|
|
12
|
+
// npm skips a `bin` whose target is missing, and `lib/` exists only after a build.
|
|
13
|
+
import '../lib/cli.js';
|
package/lib/cli-version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-version.js","sourceRoot":"","sources":["../src/cli-version.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,+FAA+F;AAC/F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"cli-version.js","sourceRoot":"","sources":["../src/cli-version.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,+FAA+F;AAC/F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAA0B,CAAC;IAC1F,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,IAAI,QAAQ,CAAC,OAAO,KAAK,EAAE,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC3B,CAAC"}
|
package/lib/cli.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-heap-args.js","sourceRoot":"","sources":["../../src/commands/analyze-heap-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AAE/G;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,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AE,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAc,EAAE,IAAI,GAAoB,EAAE;IAC7E,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,yEAAyE;QACzE,2EAA2E;QAC3E,iDAAiD;QACjD,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC7B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,IAAI,aAAa,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
import { type HeapReading } from '../driver-heap.js';
|
|
9
10
|
/**
|
|
10
11
|
* Selects the JSON-vs-JSON comparison, which reads two analysis artifacts and
|
|
11
12
|
* needs neither a snapshot nor memlab. Declared here rather than in the args
|
|
@@ -18,6 +19,8 @@ export interface AnalyzeHeapDeps {
|
|
|
18
19
|
readonly __spawnForTest?: (execArgs: string[]) => Promise<number>;
|
|
19
20
|
/** Override the memlab-availability check. */
|
|
20
21
|
readonly __memlabInstalledForTest?: () => boolean;
|
|
22
|
+
/** Decide the heap ceiling from a stated cgroup reading rather than the machine's. */
|
|
23
|
+
readonly __heapReadingForTest?: HeapReading;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
23
26
|
* Run the heap-snapshot analyzer. Memlab is an OPTIONAL PEER dependency and a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-heap.d.ts","sourceRoot":"","sources":["../../src/commands/analyze-heap.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"analyze-heap.d.ts","sourceRoot":"","sources":["../../src/commands/analyze-heap.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqBrE;;;;GAIG;AACH,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,8CAA8C;IAC9C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC;IAClD,sFAAsF;IACtF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAC;CAC9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB9F"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { driverHeapArgs } from '../driver-heap.js';
|
|
10
11
|
import { spawnNodeChild } from './headless-harness.js';
|
|
11
12
|
/**
|
|
12
13
|
* Absolute path to the bundled memlab-based analyzer (a standalone ESM script
|
|
@@ -55,7 +56,7 @@ export async function runAnalyzeHeap(args, deps = {}) {
|
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
const spawnChild = deps.__spawnForTest ?? spawnNodeChild;
|
|
58
|
-
const code = await spawnChild([
|
|
59
|
+
const code = await spawnChild([...driverHeapArgs(deps.__heapReadingForTest), ANALYZER, ...args]);
|
|
59
60
|
if (code) {
|
|
60
61
|
process.exitCode = code;
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-heap.js","sourceRoot":"","sources":["../../src/commands/analyze-heap.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,sCAAsC,EAAE,
|
|
1
|
+
{"version":3,"file":"analyze-heap.js","sourceRoot":"","sources":["../../src/commands/analyze-heap.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,sCAAsC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjG,+FAA+F;AAC/F,SAAS,eAAe;IACrB,MAAM,OAAO,GAAI,OAAO,IAAoD,CAAC,OAAO,CAAC;IACrF,IAAI,CAAC;QACF,OAAO,EAAE,CAAC,uBAAuB,CAAC,CAAC;QACnC,OAAO,OAAO,KAAK,SAAS,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACN,OAAO,KAAK,CAAC;IAChB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAYlC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc,EAAE,IAAI,GAAoB,EAAE;IAC5E,MAAM,iBAAiB,GAAG,IAAI,CAAC,wBAAwB,IAAI,eAAe,CAAC;IAC3E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACrD,OAAO,CAAC,KAAK,CACV,qFAAqF;YAClF,sFAAsF;YACtF,kDAAkD,CACvD,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACV,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACjG,IAAI,IAAI,EAAE,CAAC;QACR,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -10,8 +10,9 @@ import { type AstGroundTruthCommandOptions } from './ast-ground-truth.js';
|
|
|
10
10
|
import { type UsageError } from './harness-args.js';
|
|
11
11
|
/**
|
|
12
12
|
* Every flag `ast-ground-truth` accepts, derived from the sets the parser is
|
|
13
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
-
*
|
|
13
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
14
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
15
|
+
* so they are in neither set.
|
|
15
16
|
*/
|
|
16
17
|
export declare const AST_GROUND_TRUTH_FLAGS: readonly string[];
|
|
17
18
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-ground-truth-args.d.ts","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,KAAK,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,
|
|
1
|
+
{"version":3,"file":"ast-ground-truth-args.d.ts","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAqB,KAAK,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAUJ,KAAK,UAAU,EACjB,MAAM,mBAAmB,CAAC;AAK3B;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAA6C,CAAC;AAElG,oFAAoF;AACpF,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAA2B,CAAC;AAEtF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAclD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,4BAA4B,CAGzH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMtE"}
|
|
@@ -7,20 +7,21 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { runAstGroundTruth } from './ast-ground-truth.js';
|
|
10
|
-
import { exitWithUsage, helpRequested,
|
|
10
|
+
import { exitWithUsage, HARNESS_VALUE_FLAGS, helpRequested, importHelpLines, LOG_VALUE_FLAGS, logHelpLines, logOptions, parseHarnessArgs, printHelp } from './harness-args.js';
|
|
11
11
|
import { OUT_FILE_FLAG } from './headless-harness.js';
|
|
12
|
-
const VALUE_FLAGS = [OUT_FILE_FLAG,
|
|
12
|
+
const VALUE_FLAGS = [OUT_FILE_FLAG, ...LOG_VALUE_FLAGS];
|
|
13
13
|
/**
|
|
14
14
|
* Every flag `ast-ground-truth` accepts, derived from the sets the parser is
|
|
15
|
-
* handed so the list cannot claim a flag the parser would reject.
|
|
16
|
-
*
|
|
15
|
+
* handed so the list cannot claim a flag the parser would reject.
|
|
16
|
+
* {@link HARNESS_VALUE_FLAGS} are consumed by the shared harness parser itself,
|
|
17
|
+
* so they are in neither set.
|
|
17
18
|
*/
|
|
18
|
-
export const AST_GROUND_TRUTH_FLAGS = [
|
|
19
|
+
export const AST_GROUND_TRUTH_FLAGS = [...HARNESS_VALUE_FLAGS, ...VALUE_FLAGS];
|
|
19
20
|
/** The subset that takes a value, so `--help` in a value position reads as data. */
|
|
20
21
|
export const AST_GROUND_TRUTH_VALUE_FLAGS = AST_GROUND_TRUTH_FLAGS;
|
|
21
22
|
/** The `--help` text, as data, held to {@link AST_GROUND_TRUTH_FLAGS} by a test. */
|
|
22
23
|
export const AST_GROUND_TRUTH_HELP = [
|
|
23
|
-
'Usage: hydranium-cli ast-ground-truth --services <module> <workspace> [--out-file <file>] [--log-level <lvl>]',
|
|
24
|
+
'Usage: hydranium-cli ast-ground-truth --services <module> [--import <specifier>]... <workspace> [--out-file <file>] [--log-level <lvl>] [--log-file <file>] [--log-file-level <lvl>]',
|
|
24
25
|
'',
|
|
25
26
|
"Tally a workspace's live-model AST nodes by `$type` — the ground truth that",
|
|
26
27
|
'`analyze-heap --validate <gt.json>` checks a heap snapshot against. `<module>`',
|
|
@@ -29,13 +30,14 @@ export const AST_GROUND_TRUTH_HELP = [
|
|
|
29
30
|
'',
|
|
30
31
|
'Options:',
|
|
31
32
|
' --services <module> ESM module exporting `createServices(): { shared }` (required).',
|
|
33
|
+
...importHelpLines(22),
|
|
32
34
|
' <workspace> Workspace root (path or file URI) to build (required).',
|
|
33
35
|
' --out-file <file> Write the JSON to this file instead of stdout.',
|
|
34
|
-
|
|
36
|
+
...logHelpLines(22)
|
|
35
37
|
];
|
|
36
38
|
export function parseAstGroundTruthArgs(args, onError = exitWithUsage) {
|
|
37
|
-
const { servicesModule, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
|
|
38
|
-
return { servicesModule, workspace, outFile: options[OUT_FILE_FLAG],
|
|
39
|
+
const { servicesModule, imports, workspace, options } = parseHarnessArgs(args, 'ast-ground-truth', VALUE_FLAGS, [], { onError });
|
|
40
|
+
return { servicesModule, imports, workspace, outFile: options[OUT_FILE_FLAG], ...logOptions(options) };
|
|
39
41
|
}
|
|
40
42
|
export function runAstGroundTruthCommand(args) {
|
|
41
43
|
if (helpRequested(args, AST_GROUND_TRUTH_VALUE_FLAGS)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-ground-truth-args.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAqC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EACJ,aAAa,EACb,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"ast-ground-truth-args.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,iBAAiB,EAAqC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EACJ,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,SAAS,EAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,GAAG,eAAe,CAAU,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,CAAC,GAAG,mBAAmB,EAAE,GAAG,WAAW,CAAC,CAAC;AAElG,oFAAoF;AACpF,MAAM,CAAC,MAAM,4BAA4B,GAAsB,sBAAsB,CAAC;AAEtF,oFAAoF;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACrD,sLAAsL;IACtL,EAAE;IACF,6EAA6E;IAC7E,gFAAgF;IAChF,oEAAoE;IACpE,0EAA0E;IAC1E,EAAE;IACF,UAAU;IACV,yFAAyF;IACzF,GAAG,eAAe,CAAC,EAAE,CAAC;IACtB,gFAAgF;IAChF,wEAAwE;IACxE,GAAG,YAAY,CAAC,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,IAAc,EAAE,OAAO,GAAe,aAAa;IACxF,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACjI,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;AAC1G,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAc;IACpD,IAAI,aAAa,CAAC,IAAI,EAAE,4BAA4B,CAAC,EAAE,CAAC;QACrD,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,iBAAiB,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -31,6 +31,6 @@ export function buildGroundTruthDriverArgs(options) {
|
|
|
31
31
|
* `--out-file`). No `--expose-gc` needed — this walks the AST, it does not weigh it.
|
|
32
32
|
*/
|
|
33
33
|
export function runAstGroundTruth(options) {
|
|
34
|
-
return runDriverChild([
|
|
34
|
+
return runDriverChild([DRIVER, ...buildGroundTruthDriverArgs(options)], options);
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=ast-ground-truth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-ground-truth.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAA2B,MAAM,uBAAuB,CAAC;AAE/F;;;GAGG;AACH,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,8BAA8B,EAAE,
|
|
1
|
+
{"version":3,"file":"ast-ground-truth.js","sourceRoot":"","sources":["../../src/commands/ast-ground-truth.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAA2B,MAAM,uBAAuB,CAAC;AAE/F;;;GAGG;AACH,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,8BAA8B,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAYvF,oEAAoE;AACpE,MAAM,UAAU,0BAA0B,CAAC,OAAqC;IAC7E,MAAM,IAAI,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACvE,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAqC;IACpE,OAAO,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import type { SourceFile } from 'ts-morph';
|
|
10
|
+
/** Inputs for {@link emitAstBuilder}, resolved by the transfer-model command. */
|
|
11
|
+
export interface EmitAstBuilderOptions {
|
|
12
|
+
/** Destination path for the generated builder module. */
|
|
13
|
+
outFile: string;
|
|
14
|
+
/** Path to the Langium-generated AST file the builder imports from. */
|
|
15
|
+
astFile: string;
|
|
16
|
+
/** Language id derived from the `<LanguageId>AstReflection` class name. */
|
|
17
|
+
languageId: string;
|
|
18
|
+
/** Header line naming the command that regenerates the file. */
|
|
19
|
+
regenCommand: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Emit a module binding {@link makeAstNodeBuilder} to a project's reflection,
|
|
23
|
+
* once per grammar plus once across all of them.
|
|
24
|
+
*
|
|
25
|
+
* **The binding is boilerplate with exactly one degree of freedom** — the type
|
|
26
|
+
* map — so hand-writing it buys nothing and goes stale the moment a grammar is
|
|
27
|
+
* added. Generating it is also the only way a narrowed binding can exist at all:
|
|
28
|
+
* the per-grammar type maps live in namespaces Langium emits only on its
|
|
29
|
+
* multi-language path, so a single-grammar project gets the merged binding alone
|
|
30
|
+
* and there is nothing to narrow.
|
|
31
|
+
*
|
|
32
|
+
* **A narrowed binding is only as narrow as its grammar's import closure.**
|
|
33
|
+
* Langium's per-grammar `AstType` lists everything REACHABLE from that grammar,
|
|
34
|
+
* so where one grammar imports all the others its map equals the project's and
|
|
35
|
+
* its binding checks nothing the merged one does not. The emitted doc says so at
|
|
36
|
+
* each declaration rather than promising a guarantee the type map cannot give.
|
|
37
|
+
*
|
|
38
|
+
* Answers `false` when the AST source declares no whole-project type alias,
|
|
39
|
+
* which means the file did not come from `langium generate` and the caller
|
|
40
|
+
* should report rather than write a module that cannot compile.
|
|
41
|
+
*/
|
|
42
|
+
export declare function emitAstBuilder(astSource: SourceFile, options: EmitAstBuilderOptions): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The module text {@link emitAstBuilder} would write, or `undefined` when the
|
|
45
|
+
* AST source declares no whole-project type alias. Pure over its inputs, so the
|
|
46
|
+
* emitted shape is testable without touching a filesystem.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildAstBuilderSource(astSource: SourceFile, options: EmitAstBuilderOptions): string | undefined;
|
|
49
|
+
//# sourceMappingURL=generate-ast-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-ast-builder.d.ts","sourceRoot":"","sources":["../../src/commands/generate-ast-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACnC,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;CACvB;AAyBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAc7F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAqB/G"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
/**
|
|
12
|
+
* Langium declares this type alias inside each language's namespace in a
|
|
13
|
+
* multi-language project. Its presence is what marks a namespace as a grammar's
|
|
14
|
+
* type registry rather than an incidental one.
|
|
15
|
+
*/
|
|
16
|
+
const NAMESPACED_AST_TYPE_NAME = 'AstType';
|
|
17
|
+
/** Export name of the merged, whole-project binding. */
|
|
18
|
+
const MERGED_EXPORT_NAME = 'astNode';
|
|
19
|
+
/**
|
|
20
|
+
* Emit a module binding {@link makeAstNodeBuilder} to a project's reflection,
|
|
21
|
+
* once per grammar plus once across all of them.
|
|
22
|
+
*
|
|
23
|
+
* **The binding is boilerplate with exactly one degree of freedom** — the type
|
|
24
|
+
* map — so hand-writing it buys nothing and goes stale the moment a grammar is
|
|
25
|
+
* added. Generating it is also the only way a narrowed binding can exist at all:
|
|
26
|
+
* the per-grammar type maps live in namespaces Langium emits only on its
|
|
27
|
+
* multi-language path, so a single-grammar project gets the merged binding alone
|
|
28
|
+
* and there is nothing to narrow.
|
|
29
|
+
*
|
|
30
|
+
* **A narrowed binding is only as narrow as its grammar's import closure.**
|
|
31
|
+
* Langium's per-grammar `AstType` lists everything REACHABLE from that grammar,
|
|
32
|
+
* so where one grammar imports all the others its map equals the project's and
|
|
33
|
+
* its binding checks nothing the merged one does not. The emitted doc says so at
|
|
34
|
+
* each declaration rather than promising a guarantee the type map cannot give.
|
|
35
|
+
*
|
|
36
|
+
* Answers `false` when the AST source declares no whole-project type alias,
|
|
37
|
+
* which means the file did not come from `langium generate` and the caller
|
|
38
|
+
* should report rather than write a module that cannot compile.
|
|
39
|
+
*/
|
|
40
|
+
export function emitAstBuilder(astSource, options) {
|
|
41
|
+
const content = buildAstBuilderSource(astSource, options);
|
|
42
|
+
if (content === undefined) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
fs.mkdirSync(path.dirname(options.outFile), { recursive: true });
|
|
46
|
+
if (fs.existsSync(options.outFile) && fs.readFileSync(options.outFile, 'utf-8') === content) {
|
|
47
|
+
console.log('AST builder is up to date.');
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
fs.writeFileSync(options.outFile, content, 'utf-8');
|
|
51
|
+
console.log(`Generated: ${options.outFile}`);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The module text {@link emitAstBuilder} would write, or `undefined` when the
|
|
56
|
+
* AST source declares no whole-project type alias. Pure over its inputs, so the
|
|
57
|
+
* emitted shape is testable without touching a filesystem.
|
|
58
|
+
*/
|
|
59
|
+
export function buildAstBuilderSource(astSource, options) {
|
|
60
|
+
const mergedTypeMap = `${options.languageId}AstType`;
|
|
61
|
+
if (!astSource.getTypeAlias(mergedTypeMap)) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const bindings = [{ exportName: MERGED_EXPORT_NAME, typeMap: mergedTypeMap }];
|
|
65
|
+
for (const namespace of findGrammarNamespaces(astSource)) {
|
|
66
|
+
bindings.push({
|
|
67
|
+
exportName: builderExportName(namespace),
|
|
68
|
+
typeMap: `${namespace}.${NAMESPACED_AST_TYPE_NAME}`,
|
|
69
|
+
namespace
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
assertDistinctExportNames(bindings);
|
|
73
|
+
return renderAstBuilder(bindings, {
|
|
74
|
+
reflectionName: findReflectionConstName(astSource, options.languageId),
|
|
75
|
+
importPath: relativeImportPath(options.outFile, options.astFile),
|
|
76
|
+
regenCommand: options.regenCommand
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Namespaces that carry a grammar's type registry, in declaration order.
|
|
81
|
+
*
|
|
82
|
+
* Keyed on the nested `AstType` alias rather than on the namespace being
|
|
83
|
+
* exported, because an adopter's augmentation can add namespaces to the same
|
|
84
|
+
* file for unrelated reasons and only the ones Langium emits per grammar have
|
|
85
|
+
* a type map to bind.
|
|
86
|
+
*/
|
|
87
|
+
function findGrammarNamespaces(astSource) {
|
|
88
|
+
const names = [];
|
|
89
|
+
for (const module of astSource.getModules()) {
|
|
90
|
+
const name = module.getName();
|
|
91
|
+
if (name && module.getTypeAlias(NAMESPACED_AST_TYPE_NAME)) {
|
|
92
|
+
names.push(name);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return names;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `Domain` → `domainNode`. Lower-cases the leading character only, so a grammar
|
|
99
|
+
* named `OrderFlow` reads as `orderFlowNode` rather than losing its word break.
|
|
100
|
+
*/
|
|
101
|
+
function builderExportName(namespace) {
|
|
102
|
+
return `${namespace.charAt(0).toLowerCase()}${namespace.slice(1)}Node`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Two grammars whose names differ only in their leading character collapse to
|
|
106
|
+
* one export. Emitting anyway would silently drop a binding, so fail with both
|
|
107
|
+
* names rather than leave the caller to discover it at compile time.
|
|
108
|
+
*/
|
|
109
|
+
function assertDistinctExportNames(bindings) {
|
|
110
|
+
const seen = new Map();
|
|
111
|
+
for (const binding of bindings) {
|
|
112
|
+
const previous = seen.get(binding.exportName);
|
|
113
|
+
if (previous !== undefined) {
|
|
114
|
+
throw new Error(`Cannot emit the AST builder: grammars '${previous}' and '${binding.namespace}' both map to the export ` +
|
|
115
|
+
`'${binding.exportName}'. Rename one grammar so the generated bindings stay distinct.`);
|
|
116
|
+
}
|
|
117
|
+
seen.set(binding.exportName, binding.namespace ?? MERGED_EXPORT_NAME);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Name of the const holding the project's reflection instance.
|
|
122
|
+
*
|
|
123
|
+
* Langium emits `export const reflection = new <LanguageId>AstReflection()`, but
|
|
124
|
+
* the const is located by its initializer rather than by that name so a renamed
|
|
125
|
+
* export still resolves. Falls back to the emitted default when no declaration
|
|
126
|
+
* matches, which keeps the output compiling against a stock Langium file.
|
|
127
|
+
*/
|
|
128
|
+
function findReflectionConstName(astSource, languageId) {
|
|
129
|
+
const reflectionClass = `${languageId}AstReflection`;
|
|
130
|
+
for (const declaration of astSource.getVariableDeclarations()) {
|
|
131
|
+
if (declaration.getInitializer()?.getText().replace(/\s/g, '') === `new${reflectionClass}()`) {
|
|
132
|
+
return declaration.getName();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return 'reflection';
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Module specifier for the AST file as seen from the generated module's own
|
|
139
|
+
* directory. Emitted with a `.js` extension and posix separators because the
|
|
140
|
+
* output is ESM TypeScript, where the specifier names the compiled sibling.
|
|
141
|
+
*/
|
|
142
|
+
function relativeImportPath(outFile, astFile) {
|
|
143
|
+
const relative = path.relative(path.dirname(path.resolve(outFile)), path.resolve(astFile));
|
|
144
|
+
const posix = relative.split(path.sep).join('/').replace(/\.ts$/, '.js');
|
|
145
|
+
return posix.startsWith('.') ? posix : `./${posix}`;
|
|
146
|
+
}
|
|
147
|
+
function renderAstBuilder(bindings, context) {
|
|
148
|
+
const imported = [context.reflectionName, ...bindings.map(binding => `type ${binding.namespace ?? binding.typeMap}`)];
|
|
149
|
+
const out = [];
|
|
150
|
+
out.push('/******************************************************************************');
|
|
151
|
+
out.push(' * Generated from the Langium AST — DO NOT EDIT MANUALLY!');
|
|
152
|
+
out.push(` * ${context.regenCommand}`);
|
|
153
|
+
out.push(' ******************************************************************************/');
|
|
154
|
+
out.push('');
|
|
155
|
+
out.push('/* eslint-disable */');
|
|
156
|
+
out.push('');
|
|
157
|
+
out.push("import { makeAstNodeBuilder } from '@hydranium/core';");
|
|
158
|
+
out.push(`import { ${imported.join(', ')} } from '${context.importPath}';`);
|
|
159
|
+
out.push('');
|
|
160
|
+
// A single-grammar project has nothing to narrow to, so the merged binding is
|
|
161
|
+
// simply THE binding there and must not point at a sibling that was not emitted.
|
|
162
|
+
const narrowed = bindings.some(binding => binding.namespace !== undefined);
|
|
163
|
+
const guarantee = [
|
|
164
|
+
' * Mandatory fields are a type error at the call site, and grammar-declared',
|
|
165
|
+
' * containment arrays are materialised from reflection metadata, so a built',
|
|
166
|
+
' * node carries `[]` where a cast literal would leave `undefined`.'
|
|
167
|
+
];
|
|
168
|
+
for (const binding of bindings) {
|
|
169
|
+
out.push('/**');
|
|
170
|
+
if (binding.namespace !== undefined) {
|
|
171
|
+
out.push(` * AST-node factory narrowed to the '${binding.namespace}' grammar.`);
|
|
172
|
+
out.push(' *');
|
|
173
|
+
out.push(' * Narrowed by grammar REACHABILITY, not by ownership: a grammar that');
|
|
174
|
+
out.push(" * imports another sees that one's types too, so this binding is only as");
|
|
175
|
+
out.push(` * narrow as '${binding.namespace}'s import closure. Where that closure is the`);
|
|
176
|
+
out.push(' * whole project, it accepts exactly what the merged binding does and the');
|
|
177
|
+
out.push(' * choice is documentation rather than a check.');
|
|
178
|
+
out.push(' *');
|
|
179
|
+
out.push(...guarantee);
|
|
180
|
+
}
|
|
181
|
+
else if (narrowed) {
|
|
182
|
+
out.push(' * AST-node factory spanning every grammar in this project.');
|
|
183
|
+
out.push(' *');
|
|
184
|
+
out.push(' * Prefer the narrowed binding matching the grammar the call site works in:');
|
|
185
|
+
out.push(" * it rejects a type outside that grammar's import closure, which this one");
|
|
186
|
+
out.push(' * accepts from anywhere. Reach for this one where a call site genuinely');
|
|
187
|
+
out.push(' * spans grammars.');
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
out.push(" * AST-node factory for this project's grammar.");
|
|
191
|
+
out.push(' *');
|
|
192
|
+
out.push(...guarantee);
|
|
193
|
+
}
|
|
194
|
+
out.push(' */');
|
|
195
|
+
out.push(`export const ${binding.exportName} = makeAstNodeBuilder<${binding.typeMap}>(${context.reflectionName});`);
|
|
196
|
+
out.push('');
|
|
197
|
+
}
|
|
198
|
+
return out.join('\n');
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=generate-ast-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-ast-builder.js","sourceRoot":"","sources":["../../src/commands/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C,GAAG,SAAS,CAAC,CAAC;QAC1B,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,GAAG,CAAC,IAAI,CAAC,gBAAgB,OAAO,CAAC,UAAU,yBAAyB,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC;QACpH,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-transfer-model-args.d.ts","sourceRoot":"","sources":["../../src/commands/generate-transfer-model-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,EAA6C,KAAK,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5H,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7F;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"generate-transfer-model-args.d.ts","sourceRoot":"","sources":["../../src/commands/generate-transfer-model-args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,EAA6C,KAAK,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5H,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7F;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,MAAM,EAc1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,EAAE,SAAS,MAAM,EAAqE,CAAC;AAEvI,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAkCzD,CAAC;AAEF,2FAA2F;AAC3F,MAAM,WAAW,qBAAqB;IACnC,KAAK,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,UAA0B,GAAG,qBAAqB,CAyE/G;AAcD,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCpF"}
|
|
@@ -27,6 +27,7 @@ export const GENERATE_TRANSFER_MODEL_FLAGS = [
|
|
|
27
27
|
'--ast-file',
|
|
28
28
|
'--augmentation-file',
|
|
29
29
|
'--out-file',
|
|
30
|
+
'--ast-builder-file',
|
|
30
31
|
'--element-type-name',
|
|
31
32
|
'--terminals-name',
|
|
32
33
|
'--terminals-source-name',
|
|
@@ -44,7 +45,8 @@ export const GENERATE_TRANSFER_MODEL_VALUE_FLAGS = GENERATE_TRANSFER_MODEL_FLAGS
|
|
|
44
45
|
export const GENERATE_TRANSFER_MODEL_HELP = [
|
|
45
46
|
'Usage: hydranium-cli generate-transfer-model [options]',
|
|
46
47
|
'',
|
|
47
|
-
'Generate a serializable transfer-model TypeScript file from a Langium AST
|
|
48
|
+
'Generate a serializable transfer-model TypeScript file from a Langium AST, and',
|
|
49
|
+
'optionally an AST-node builder module bound to the same reflection. The',
|
|
48
50
|
'required inputs (--ast-file / --augmentation-file / --out-file) may instead come',
|
|
49
51
|
'from a --config JSON file, and --ast-file can be auto-discovered from a Langium',
|
|
50
52
|
"config's `out` directory. Precedence, highest first: explicit flags, then the",
|
|
@@ -63,6 +65,11 @@ export const GENERATE_TRANSFER_MODEL_HELP = [
|
|
|
63
65
|
' directory: it treats that directory as exclusively',
|
|
64
66
|
' its own, so every `langium generate` reports this',
|
|
65
67
|
' file as unexpected and offers to delete it.',
|
|
68
|
+
' --ast-builder-file <path> Also emit an AST-node builder module here: one',
|
|
69
|
+
' makeAstNodeBuilder binding per grammar, plus one',
|
|
70
|
+
' spanning all of them. Omit if nothing constructs',
|
|
71
|
+
' AST nodes. Same restriction as --out-file: keep it',
|
|
72
|
+
" out of langium-cli's own `out` directory.",
|
|
66
73
|
' --element-type-name <name> Base element type name in output. Default: TransferElement.',
|
|
67
74
|
' --terminals-name <name> Terminals const name in output. Default: ModelTerminals.',
|
|
68
75
|
' --terminals-source-name <n> Source-side terminals variable name. Default: <LanguageId>Terminals.',
|
|
@@ -106,6 +113,9 @@ export function parseGenerateOptions(args, onError = exitWithUsage) {
|
|
|
106
113
|
case '--out-file':
|
|
107
114
|
flags.outFile = next();
|
|
108
115
|
break;
|
|
116
|
+
case '--ast-builder-file':
|
|
117
|
+
flags.astBuilderFile = next();
|
|
118
|
+
break;
|
|
109
119
|
case '--element-type-name':
|
|
110
120
|
flags.elementTypeName = next();
|
|
111
121
|
break;
|