mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-11 22:53:04 +00:00
feat(dart): add call patterns for await, cascade, lambda, and widget-tree contexts
This commit is contained in:
parent
b10d25bbca
commit
7867efeb66
2 changed files with 111 additions and 0 deletions
|
|
@ -1141,6 +1141,53 @@ export const DART_QUERIES = `
|
|||
(identifier) @call.name))
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: await direct (await doSomething()) ────────────────────────────────
|
||||
(await_expression
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: await method chain (await obj.method()) ───────────────────────────
|
||||
(await_expression
|
||||
(selector
|
||||
(unconditional_assignable_selector
|
||||
(identifier) @call.name))) @call
|
||||
|
||||
; ── Calls: named argument (foo(child: buildX())) ─────────────────────────────
|
||||
(named_argument
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: inside list literals ([buildA(), buildB()]) ───────────────────────
|
||||
(list_literal
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: cascade (obj..add(x)..sort()) ─────────────────────────────────────
|
||||
(cascade_section
|
||||
(cascade_selector (identifier) @call.name)
|
||||
(argument_part)) @call
|
||||
|
||||
; ── Calls: static/const field initializers (const _svc = MyService()) ────────
|
||||
(static_final_declaration
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: arrow function body (=> buildWidget()) ────────────────────────────
|
||||
(function_body "=>"
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Calls: lambda body (() => doSomething()) ─────────────────────────────────
|
||||
(function_expression_body
|
||||
(identifier) @call.name
|
||||
.
|
||||
(selector (argument_part))) @call
|
||||
|
||||
; ── Re-exports (export 'foo.dart') ───────────────────────────────────────────
|
||||
(import_or_export
|
||||
(library_export
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
RUST_QUERIES,
|
||||
PHP_QUERIES,
|
||||
SWIFT_QUERIES,
|
||||
DART_QUERIES,
|
||||
} from '../../src/core/ingestion/tree-sitter-queries.js';
|
||||
|
||||
describe('tree-sitter queries', () => {
|
||||
|
|
@ -292,4 +293,67 @@ describe('tree-sitter queries', () => {
|
|||
expect(SWIFT_QUERIES).toContain('"actor"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dart queries', () => {
|
||||
it('captures class, mixin, extension, enum declarations', () => {
|
||||
expect(DART_QUERIES).toContain('@definition.class');
|
||||
expect(DART_QUERIES).toContain('@definition.trait');
|
||||
expect(DART_QUERIES).toContain('@definition.enum');
|
||||
});
|
||||
|
||||
it('captures top-level functions and methods', () => {
|
||||
expect(DART_QUERIES).toContain('@definition.function');
|
||||
expect(DART_QUERIES).toContain('@definition.method');
|
||||
});
|
||||
|
||||
it('captures constructors including factory constructors', () => {
|
||||
expect(DART_QUERIES).toContain('@definition.constructor');
|
||||
expect(DART_QUERIES).toContain('factory_constructor_signature');
|
||||
});
|
||||
|
||||
it('captures field declarations and getters/setters', () => {
|
||||
expect(DART_QUERIES).toContain('@definition.property');
|
||||
expect(DART_QUERIES).toContain('getter_signature');
|
||||
expect(DART_QUERIES).toContain('setter_signature');
|
||||
});
|
||||
|
||||
it('captures import statements', () => {
|
||||
expect(DART_QUERIES).toContain('@import');
|
||||
expect(DART_QUERIES).toContain('library_import');
|
||||
});
|
||||
|
||||
it('captures heritage (extends, implements, with)', () => {
|
||||
expect(DART_QUERIES).toContain('@heritage.extends');
|
||||
});
|
||||
|
||||
it('captures direct calls and method chains', () => {
|
||||
expect(DART_QUERIES).toContain('expression_statement');
|
||||
expect(DART_QUERIES).toContain('unconditional_assignable_selector');
|
||||
expect(DART_QUERIES).toContain('@call');
|
||||
});
|
||||
|
||||
it('captures await expressions as calls', () => {
|
||||
expect(DART_QUERIES).toContain('await_expression');
|
||||
});
|
||||
|
||||
it('captures named argument calls (widget children)', () => {
|
||||
expect(DART_QUERIES).toContain('named_argument');
|
||||
});
|
||||
|
||||
it('captures list literal calls (widget children lists)', () => {
|
||||
expect(DART_QUERIES).toContain('list_literal');
|
||||
});
|
||||
|
||||
it('captures cascade calls (obj..method())', () => {
|
||||
expect(DART_QUERIES).toContain('cascade_section');
|
||||
});
|
||||
|
||||
it('captures arrow function body calls (=> expr)', () => {
|
||||
expect(DART_QUERIES).toContain('function_body "=>"');
|
||||
});
|
||||
|
||||
it('captures lambda body calls (() => expr)', () => {
|
||||
expect(DART_QUERIES).toContain('function_expression_body');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue