Repository navigation
fix(autoindex): index Dart extension and extension type declarations - #2865
Conversation
`xerj def <Name>` returned "no definition" for any Dart `extension` or `extension type`, while classes, mixins and the methods inside the extension body were found. On Flutter's packages/flutter/lib this hid names such as `HtmlElementViewImpl` and `_DomPerformanceExtension`. Root cause: DART_Q was adapted from tree-sitter-dart 0.2.0 queries/tags.scm, which tags `extension_declaration` (tags.scm:11-13) and `extension_type_declaration` (tags.scm:15-18) as `definition.class`. The adaptation kept class, mixin, enum, function, typedef and enum-constant captures and its comment lists getter, setter and constructor variants as the deliberate omissions; the two extension patterns were dropped without being listed. Methods inside an extension were still indexed because the bare `function_signature` pattern matches anywhere, so only the extension's own name was missing. Fix: add both patterns with `@class`, the kind tags.scm uses and the kind SWIFT_Q already gives Swift's `extension` (code.rs:2211). Getters, setters and constructors stay out, as before. Evidence: the `dart` unit test gains an `extension` and an `extension type` case. On 720b999 without the query change it fails at the new `Shout` assertion (the symbol list has `shout` but not `Shout` or `UserId`); with it, it passes. End to end with a release build against a local node, `xerj def` on Flutter's lib finds `HtmlElementViewImpl` (both files) and `_DomPerformanceExtension`, and the index grows from 19,689 to 19,747 records. Written with an AI coding agent; the PR description separates what was run from what was assumed.
|
Thanks for this contribution — we'd like to merge it. Before we can, we need a signed Contributor License Agreement from: @ChandraChaan It is a one-time thing per contributor, not per pull request. Read CLA.md, then open a small pull request adding your GitHub username to Once it is merged, comment |
|
@cla-bot check |
|
Re-checking the CLA status for every commit author on this pull request… |
# Conflicts: # CHANGELOG.md
|
Merged main into this branch to resolve a CHANGELOG.md conflict (kept both entries; no change to your code). CI will rerun, and I'll merge once it's green. |
# Conflicts: # CHANGELOG.md
|
Xerj Merger made the fix: autoindex's Dart query now captures |
Written by an AI coding agent (Claude Opus 5.5 in Claude Code), run by @ChandraChaan, who has reviewed this change.
What this changes, and why
xerj def <Name>returns "no definition" for every Dartextensionandextension type, while classes, mixins and the methods inside the extension body are found. On Flutter'spackages/flutter/libthat hides names likeHtmlElementViewImpland_DomPerformanceExtension.DART_Qinengine/crates/xerj-autoindex/src/extract/code.rswas adapted from tree-sitter-dart 0.2.0queries/tags.scm, which tagsextension_declaration(tags.scm:11-13) andextension_type_declaration(tags.scm:15-18) asdefinition.class. The adaptation's comment names getter, setter and constructor variants as the deliberate omissions; the two extension patterns were dropped without being listed. Methods inside an extension were still indexed because the barefunction_signaturepattern matches anywhere, so only the extension's own name was missing.This adds both patterns with
@class, the kind tags.scm uses and the kindSWIFT_Qalready gives Swift'sextension(code.rs:2211). Getters, setters and constructors stay out, as before. CHANGELOG entry under Unreleased / Fixed.I searched open and closed issues and PRs for "dart", "dart getter" and "DART_Q" and found nothing covering this.
Evidence
Unit test (
extract::code::tests::dart, two new Dart lines and three new assertions), on 720b999 with the test change but without the query change:With the query change:
End to end, release build, local node,
xerj autoindexthenxerj def:(
RupeeFormat/TransactionId/Moneyare from a 23-line Dart file thatdart analyzereports clean; the rest is flutter/flutter master'spackages/flutter/lib.)Checks
cargo fmt --all --check: clean on Rust 1.97.1 (CI's pinned toolchain) and on 1.99.1cargo build --release -j 8 -p xerj-autoindex -p xerj-serverfinished (Rust 1.99.1)cargo test -p xerj-autoindex: 1951 passed, 13 failed, 2 ignored on this branch. Unmodified 720b999 on the same Mac gives the same 13 failures (identical names: 9 infailure_resume_http_tests, pluscontent::tests::lossy_display_collisions_keep_distinct_alias_identities,corpus_data_skip_tests::corpus_index_summary_splits_indexed_extensions_from_ignored_data,inventory_delta_tests::a_non_utf8_excluded_name_is_matched_on_disk_via_path_id,sync_executor::tests::preparation_sniffs_and_extracts_only_the_sealed_blob_after_live_mutation). Not caused by this change; I did not investigate why they fail on macOS. (Rust 1.99.1)cargo +1.97.1 clippy -p xerj-autoindex --all-targets -- -D warningsfails on both this branch and unmodified 720b999 with the same single error,function resolve_reporting is never used(content.rs:143). Warnings with-Ddropped are identical on both (that one warning). The workspace-widecargo clippy --workspacethat CI runs was not run (disk space).docs/CONTRIBUTION_REVIEW.mdaudit: one query pattern pair plus a test; no stateful, recovery, legacy-data or performance claimsNot run: the ES-YAML suite.
es-yaml-runnerhas no auth option, so it needs an--insecurenode, which my environment blocked. The change is confined to the Dart tree-sitter query thatxerj autoindexuses client-side and does not touch the server's REST handling, but I have not run the suite to show that. Workspace-wide clippy and the fuzz smoke were also not run (fuzzing applies to wire parsers, which this does not touch).Provenance
@classis the right kind for both forms, matching tags.scm and Swift. A maintainer preferring a distinctextensionkind would change one word per pattern.