Skip to content

refactor(common): consolidate treesitter extension-to-language mapping - #6225

Merged
bug-ops merged 1 commit into
mainfrom
fix/5971-treesitter-lang-dedup
Jul 13, 2026
Merged

refactor(common): consolidate treesitter extension-to-language mapping#6225
bug-ops merged 1 commit into
mainfrom
fix/5971-treesitter-lang-dedup

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • zeph_common::treesitter::lang_for_ext had zero call sites outside its own definition, while zeph-index::languages::detect_language and zeph-tools::search_code::lang_info_for_path each hand-rolled their own independent extension-to-language mapping — the two had already drifted apart from each other and from the "shared" helper.
  • Extended lang_for_ext to the full 9-extension set both crates need (added bash/sh/zsh, toml, json/jsonc, md/markdown to the existing 5) and routed both consumers through it as the single source of truth.
  • Also delegated zeph-index::languages::Lang::grammar() to lang_for_ext — it was a byte-for-byte duplicate of the same mapping keyed by enum variant instead of extension (same duplication shape, same file; signed off by critic and tester as a legitimate, minimal extension of the fix rather than scope creep).
  • Removed the now-unused direct tree-sitter-{bash,json,md,toml-ng} dependencies from zeph-index and zeph-tools; they now flow through zeph-common's treesitter feature.
  • Added 10 regression tests closing coverage gaps that predated this change: none of the 4 newly-consolidated extension groups had direct test coverage through any of the three call sites before this PR.

No behavior change — extension coverage is identical to before (verified by direct old-vs-new diff read, not just re-running the existing suite), symbol-query pairing (RUST_SYM_Q etc.) in zeph-tools is untouched and stays separate from the extension→grammar mapping.

Closes #5971

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins (13452 passed)
  • RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"
  • gitleaks protect --staged
  • 10 new unit tests added covering all 9 extension groups through lang_for_ext, detect_language, Lang::grammar(), and lang_info_for_path

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes dependencies Dependency updates refactor Code refactoring without functional changes size/L Large PR (201-500 lines) labels Jul 13, 2026
zeph_common::treesitter::lang_for_ext had zero call sites outside its own
definition, while zeph-index::languages::detect_language and
zeph-tools::search_code::lang_info_for_path each hand-rolled their own
independent extension-to-language mapping that had already drifted apart.

Extend lang_for_ext to the full 9-extension set both crates need (bash/sh/zsh,
toml, json/jsonc, md/markdown, in addition to the existing 5) and route both
consumers through it, including Lang::grammar() which was a byte-for-byte
duplicate of the same mapping keyed by enum variant instead of extension.
Remove the now-unused direct tree-sitter-{bash,json,md,toml-ng} dependencies
from zeph-index and zeph-tools; they flow through zeph-common's treesitter
feature instead.

Closes #5971
@bug-ops
bug-ops enabled auto-merge (squash) July 13, 2026 16:56
@bug-ops
bug-ops force-pushed the fix/5971-treesitter-lang-dedup branch from dc203ef to c899a17 Compare July 13, 2026 16:56
@bug-ops
bug-ops merged commit 30ef3cd into main Jul 13, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/5971-treesitter-lang-dedup branch July 13, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(common): treesitter ext-to-language mapping duplicated across zeph-tools/zeph-index instead of using zeph_common::treesitter::lang_for_ext

1 participant