Skip to content

follow-up: F# .fsi signature files parsed with main F# grammar (both engines) #1114

@carlos-alm

Description

@carlos-alm

Deferred from PR #1104 review.

Original reviewer comment: #1104 (comment)

Context:

tree-sitter-fsharp ships two distinct grammars:

  • LANGUAGE_FSHARP — for .fs / .fsx source files
  • LANGUAGE_SIGNATURE (Rust) / tree_sitter_fsharp_signature (C) — for .fsi signature files

In codegraph, both engines route all three extensions (.fs, .fsx, .fsi) through the single main F# grammar:

  • Native: LanguageKind::FSharp => tree_sitter_fsharp::LANGUAGE_FSHARP (crates/codegraph-core/src/parser_registry.rs:187)
  • WASM: grammarFile: 'tree-sitter-fsharp.wasm' (src/domain/parser.ts:828)

For constructs that are valid only in the signature grammar (e.g., bare val declarations), .fsi files will produce ERROR nodes and the extractor will silently yield empty or partial output.

This was out of scope for PR #1104, whose mandate was to port the existing JS extractor to Rust while maintaining dual-engine parity. The JS engine already had this limitation; both engines remain in parity. Fixing this requires:

  1. Adding a separate FSharpSignature LanguageKind variant (mirror of OcamlInterface)
  2. Wiring .fsiFSharpSignature in from_extension
  3. Wiring FSharpSignature => tree_sitter_fsharp::LANGUAGE_SIGNATURE in tree_sitter_language
  4. On the JS side, building a separate tree-sitter-fsharp-signature.wasm from the upstream grammar's fsharp_signature subdirectory (scripts/build-wasm.ts:208 only references the fsharp sub)
  5. Adding a fsharp-signature entry to LANGUAGE_REGISTRY with extensions: ['.fsi']
  6. Updating AST_TYPE_MAPS and AST_STRING_CONFIGS to register the fsharp-signature id (or share the F# config)
  7. Mirroring the same in crates/codegraph-core/src/extractors/helpers.rs (FSHARP_AST_CONFIG)

The signature grammar may also need a tailored extractor for val bindings, abstract types, and module signatures.

Repro: Create a .fsi file with bare val declarations and run codegraph build; the file will produce ERROR nodes and the extractor will return no symbols.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions