Commit 1a6ee7b
authored
feat(fsharp): route .fsi files through the dedicated signature grammar (#1162)
* feat(fsharp): route .fsi files through the dedicated signature grammar
The tree-sitter-fsharp package ships two distinct grammars: LANGUAGE_FSHARP
for .fs / .fsx source files and LANGUAGE_SIGNATURE for .fsi signature
files. Both engines previously routed all three extensions through the
source grammar, so bare `val` declarations in .fsi files surfaced as
ERROR nodes and yielded no symbols.
This change adds a separate `fsharp-signature` language for .fsi:
* native: new `FSharpSignature` LanguageKind wired to LANGUAGE_SIGNATURE
* WASM: new `fsharp-signature` registry entry using
tree-sitter-fsharp_signature.wasm (build script now produces it)
* shared F# extractor handles `value_definition` only when its first
child is the `val` keyword, distinguishing signature `val foo : type`
from source `let foo = ...`
* function vs variable kind is inferred from the type shape; supports
both `function_type` (WASM npm 0.1.0) and `curried_spec` (cargo 0.3.0)
node shapes for engine parity
docs check acknowledged: README's F# row already covers .fs/.fsx/.fsi and
the user-facing language count is unchanged; fsharp-signature is an
internal id that mirrors how ocaml-interface backs .mli files.
Closes #1114
* fix(fsharp): qualify val declarations inside nested signature modules (#1162)
Greptile review caught two .fsi extraction corners:
1. **Module qualification dropped for `val` inside `module Foo = ...`.**
The cargo 0.3.0 signature grammar wraps nested signature modules in a
`module_defn` node (distinct from `named_module`), so the existing
`enclosing_module_name` walk never reached it and `val add : int -> int`
was indexed as `add` instead of `Foo.add`. Both engines now handle
`module_defn`, emit it as a `module` definition with the dotted parent
path, and qualify nested `val` declarations accordingly.
The WASM 0.1.0 signature grammar still emits ERROR nodes for the same
construct, so the WASM-only test continues to assert `add` (with an
explicit comment pointing at the grammar bump tracked under #1161).
2. **`val mutable count: int = 0` in `.fs` source files.** Empirically
confirmed in both engines that the source grammar parses this as a
`member_defn` node (NOT a `value_definition`), so the new `val`-style
handler never sees it. Added regression tests in both engines so a
future grammar change cannot silently start mis-classifying class
fields as variables.
* chore(fsharp): align npm grammar with cargo at v0.3.0 (#1165)
* chore(fsharp): align npm grammar with cargo at v0.3.0
The WASM engine pulled tree-sitter-fsharp 0.1.0 from npm while the native
engine used 0.3.0 from crates.io. The two versions diverged in how they
parse type signatures in .fsi files: 0.1.0 emits `function_type` nodes
for `a -> b` types, while 0.3.0 wraps every signature in `curried_spec`
with `arguments_spec` children for function shapes.
The F# extractor was forced to detect both shapes simultaneously, which
is fragile — future grammar churn could silently desync further.
* package.json now installs tree-sitter-fsharp from the ionide v0.3.0
GitHub tarball (npm has no 0.3.0 release; ionide is the upstream the
cargo crate also tracks). Lockfile pins via SRI hash.
* Both extractors now check only `curried_spec` → `arguments_spec`,
removing the dead `function_type` branch from each.
docs check acknowledged: README's F# row already covers .fs/.fsx/.fsi and
the user-facing language count is unchanged; the grammar version is an
internal implementation detail.
Closes #1161
* docs(fsharp): explain tree-sitter-fsharp tarball pin (#1165)
* fix(fsharp): restore dual function_type/curried_spec detection for val (#1162)
The npm and cargo tree-sitter-fsharp 0.3.0 grammars — though sharing a
version tag — still emit type signatures with different node shapes:
WASM 0.3.0 produces `function_type` directly under `value_definition`,
while cargo 0.3.0 wraps every signature in `curried_spec` with
`arguments_spec` children for function types.
#1165 removed the `function_type` branch on the assumption that both
grammars had converged at v0.3.0, which broke WASM extraction: every
`val name : a -> b` declaration was being indexed as a `variable`
instead of a `function`. Restore the dual-shape detection in the
TypeScript extractor and update the documentation accordingly.
Also clarifies the nested-module test comment in fsharp-signature.test
to reflect that the WASM signature grammar is now at v0.3.0 but still
emits ERROR nodes for `module Foo = ...` (the fix is still pending,
tracked under #1161).
* test(fsharp): expect Foo.add qualified name after npm grammar bump (#1162)
The WASM tree-sitter-fsharp signature grammar was upgraded from v0.1.0
to v0.3.0 in adcaf40. v0.3.0 emits `module_defn` for nested
`module Foo = ...` blocks (v0.1.0 emitted ERROR nodes), so the existing
qualification logic now fires for the WASM engine too — `val` symbols
get the parent module prefix in both engines.
The signature test still expected the pre-bump behaviour (bare `add`),
which made it fail in CI where the grammar bump landed. Update the
assertion to lock in engine parity:
- assert the qualified `Foo.add` function and the outer `Foo` module
- assert the unqualified `add` is NOT emitted, so any future
regression where the walker drops the enclosing module is caught
Also refresh the `module_defn` comment in src/extractors/fsharp.ts —
it still claimed the WASM grammar emitted ERROR nodes for this
construct, which became stale after the v0.3.0 bump.1 parent c9efaca commit 1a6ee7b
13 files changed
Lines changed: 462 additions & 19 deletions
File tree
- crates/codegraph-core/src
- extractors
- scripts
- src
- ast-analysis/rules
- domain
- extractors
- tests/parsers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
36 | 67 | | |
37 | 68 | | |
38 | 69 | | |
| |||
52 | 83 | | |
53 | 84 | | |
54 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
55 | 116 | | |
56 | 117 | | |
57 | 118 | | |
| |||
300 | 361 | | |
301 | 362 | | |
302 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
| 125 | + | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| 171 | + | |
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
| |||
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
| 214 | + | |
210 | 215 | | |
211 | 216 | | |
212 | 217 | | |
| |||
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
235 | | - | |
236 | | - | |
| 240 | + | |
| 241 | + | |
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
| |||
304 | 309 | | |
305 | 310 | | |
306 | 311 | | |
| 312 | + | |
307 | 313 | | |
308 | 314 | | |
309 | 315 | | |
| |||
320 | 326 | | |
321 | 327 | | |
322 | 328 | | |
323 | | - | |
| 329 | + | |
324 | 330 | | |
325 | 331 | | |
326 | 332 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
0 commit comments