Skip to content

fix(autoindex): index Dart extension and extension type declarations - #2865

Merged
xerj-org merged 3 commits into
xerj-org:mainfrom
ChandraChaan:fix/dart-extension-defs
Nov 2, 2026
Merged

xerj-org merged 3 commits into
xerj-org:mainfrom
ChandraChaan:fix/dart-extension-defs

Conversation

@ChandraChaan

Copy link
Copy Markdown
Contributor

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 Dart extension and extension type, while classes, mixins and the methods inside the extension body are found. On Flutter's packages/flutter/lib that hides names like HtmlElementViewImpl and _DomPerformanceExtension.

DART_Q in engine/crates/xerj-autoindex/src/extract/code.rs 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'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 bare function_signature pattern matches anywhere, so only the extension's own name was missing.

This adds 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. 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:

---- extract::code::tests::dart stdout ----
thread 'extract::code::tests::dart' panicked at crates/xerj-autoindex/src/extract/code.rs:4570:9:
got [Symbol { name: "Greeter", kind: "class", ... }, ..., Symbol { name: "topLevel", kind: "function", line: 5, ... }, Symbol { name: "shout", kind: "function", line: 6, end_line: 6, code: "String shout()" }]
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1965 filtered out

With the query change:

test extract::code::tests::dart ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1965 filtered out

End to end, release build, local node, xerj autoindex then xerj def:

before (720b9990)                                   after (this branch)
def RupeeFormat            -> no definition         lib/money.dart:13  [class]
def TransactionId          -> no definition         lib/money.dart:18  [class]
def HtmlElementViewImpl    -> no definition         src/widgets/_html_element_view_web.dart:16  [class]
                                                    src/widgets/_html_element_view_io.dart:11   [class]
def _DomPerformanceExtension -> no definition       src/foundation/_timeline_web.dart:24  [class]
def Money / TextSpan (controls) -> found            unchanged
flutter/lib records: 19689 -> 19747

(RupeeFormat / TransactionId / Money are from a 23-line Dart file that dart analyze reports clean; the rest is flutter/flutter master's packages/flutter/lib.)

Checks

  • cargo fmt --all --check: clean on Rust 1.97.1 (CI's pinned toolchain) and on 1.99.1
  • Scoped release build: cargo build --release -j 8 -p xerj-autoindex -p xerj-server finished (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 in failure_resume_http_tests, plus content::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)
  • Clippy: cargo +1.97.1 clippy -p xerj-autoindex --all-targets -- -D warnings fails on both this branch and unmodified 720b999 with the same single error, function resolve_reporting is never used (content.rs:143). Warnings with -D dropped are identical on both (that one warning). The workspace-wide cargo clippy --workspace that CI runs was not run (disk space).
  • ES-YAML conformance suite: not run, see below
  • No new ES-compatible behaviour, so no YAML case
  • No docs describe the Dart definition kinds; CHANGELOG updated
  • docs/CONTRIBUTION_REVIEW.md audit: one query pattern pair plus a test; no stateful, recovery, legacy-data or performance claims
  • N/A operational audit: no operational document or recipe changed

Not run: the ES-YAML suite. es-yaml-runner has no auth option, so it needs an --insecure node, which my environment blocked. The change is confined to the Dart tree-sitter query that xerj autoindex uses 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

  • Written by: AI agent (Claude Opus 5.5 in Claude Code), run by @ChandraChaan, who has reviewed it
  • Verified (commands run, output observed): everything under Evidence; the fmt, build, test and clippy results above, including the 720b999 baselines; issue/PR searches for duplicates
  • Assumed (not tested, and what would falsify it):
    • The ES-YAML suite is unaffected. Falsified by any new failure on this branch versus main.
    • @class is the right kind for both forms, matching tags.scm and Swift. A maintainer preferring a distinct extension kind would change one word per pattern.
    • The fixed query behaves the same on Linux. I only ran macOS arm64.

`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.
@cla-bot

cla-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

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 .contributors — that pull request is your signature, since it is made from your own account.

Once it is merged, comment @cla-bot check here and this check will go green. If you believe you are already covered, comment @cla-bot check and it will re-verify.

@xerj-org

xerj-org commented Nov 2, 2026

Copy link
Copy Markdown
Owner

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Nov 2, 2026
@cla-bot

cla-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

Re-checking the CLA status for every commit author on this pull request…

@xerj-org

xerj-org commented Nov 2, 2026

Copy link
Copy Markdown
Owner

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.

@xerj-org
xerj-org merged commit f50aae9 into xerj-org:main Nov 2, 2026
23 of 24 checks passed
@xerj-org

xerj-org commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Xerj Merger made the fix: autoindex's Dart query now captures extension and extension type declarations as class definitions, so xerj def <ExtensionName> finds them, with a regression test. Thanks @ChandraChaan!

@xerj-org xerj-org mentioned this pull request Nov 2, 2026
5 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants