Repository navigation
Description
Summary
tests/tools/tree_sitter_accuracy_audit.py's _get_param_count function (dart branch, lines 1239–1248) counts parameters using a single, non-recursive scan:
if node.type == "function_signature":
for child in node.children:
if child.type == "formal_parameter_list":
return sum(1 for p in child.children if p.type == "formal_parameter")This only inspects direct children of formal_parameter_list for type formal_parameter. It misses any parameters nested inside optional_formal_parameters wrappers, resulting in 0 parameters counted for any signature using [...] or {...} syntax.
Root cause
tree-sitter-dart wraps both optional-positional parameters ([bool hideHandles = true]) and named parameters ({required this.onContentInserted, ...}) in a node of type optional_formal_parameters — a single wrapper type for both bracket styles. This wrapper sits as a child of formal_parameter_list, with the actual formal_parameter nodes nested one level inside that wrapper.
Current code only checks direct children of formal_parameter_list for type formal_parameter, so any parameter list using [...] or {...} syntax measures 0 real params regardless of how many parameters it actually declares.
Concrete scope (verified against language-crucible/data/dart/flutter corpus)
Named parameters ({...}) are the dominant convention in idiomatic Dart/Flutter — virtually every widget constructor uses them.
125 separate real=0 / got=1 args-mismatches found in just the 7-file flutter corpus subset alone, out of 235 total args mismatches:
hideToolbar([bool hideHandles = true])(line 5056) — optional positional parameter_inferKeyboardType({...})(line 2225) — named parametersContentInsertionConfiguration({...})(line 461) — named parametersTextEditingController({String? text})(line 244) — named parameters (same line where ground truth measuresreal=0but GitGalaxy correctly reportsgot=1)
All are pure counting bugs (same line in both real and got), not line-attribution issues.
Example repro
// tree-sitter-dart parse tree for: "TextEditingController({String? text})"
function_signature
formal_parameter_list
optional_formal_parameters <-- wrapper node, not checked by current loop
formal_parameter <-- nested inside wrapper, invisible to scan
type_identifier
"String"
"?"
identifier
"text"
","
formal_parameter
...Current code scans formal_parameter_list's direct children, finds the optional_formal_parameters node, doesn't recognize its type as formal_parameter, and returns 0. The formal_parameter nodes inside the wrapper are never counted.
Fix direction
Extend the loop to recurse into optional_formal_parameters children:
if node.type == "function_signature":
for child in node.children:
if child.type == "formal_parameter_list":
count = sum(1 for p in child.children if p.type == "formal_parameter")
# Also count formal_parameters nested inside optional_formal_parameters wrappers
count += sum(1 for wrapper in child.children
if wrapper.type == "optional_formal_parameters"
for p in wrapper.children
if p.type == "formal_parameter")
return countAlternatively, a small recursive helper if there's ever nesting deeper than one level (unconfirmed — worth checking a real parse tree for a constructor mixing required positional and named params in the same signature to confirm optional_formal_parameters doesn't itself nest, though Dart's grammar likely disallows it).
Impact
This is a ground-truth measurement bug (the #1339 fix added dart parameter handling but missed the nested-wrapper shape). However, it severely deflates dart's args_exact_match accuracy metric by manufacturing false mismatches on ~125 signatures in just a small corpus subset, hiding any real engine-side improvements and masking the true accuracy of GitGalaxy's own args regex.
Activity