From 8994b5500c9ff1e4d2314cb78abfce56f524a215 Mon Sep 17 00:00:00 2001 From: safishamsi Date: Fri, 26 Jun 2026 18:08:11 +0100 Subject: [PATCH] fix(extract): recover dropped Objective-C relationships (#1475) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A detailed report (#1475) showed the ObjC extractor silently dropping ~60% of code-level relationships. Five fixes: 1. Dispatch: ObjC `.h` headers were parsed by extract_c (1 node, 0 edges, losing every @interface/@protocol/@property/method). _get_extractor now routes a `.h` to extract_objc when it contains an ObjC-only directive (@interface/@protocol/@implementation/@import) — these are illegal in C/C++, so the sniff never hijacks a genuine C/C++ header (verified: a plain C/C++ `.h` stays on its existing extractor). 2. Calls: the method-body pass produced zero `calls` edges because it matched child types `selector`/`keyword_argument_list`, but tree-sitter-objc tags selector parts with the field name `method` (type `identifier`). The selector is now reconstructed from every `method`-field child, explicitly skipping the `receiver` field — so self/super/ClassName receivers are never mistaken for a selector, and compound sends ([self a:x b:y]) resolve too. (Avoids the report's suggested `"identifier"` fix, which would have matched receivers as selectors.) 3. Generic property types: NSArray * wraps the type in a generic_specifier, so the old direct-type_identifier scan saw nothing. The element (Product) and container (NSArray) are now both referenced. 4. Class methods: `+ (…)shared` was labeled -shared; the +/- sigil is now read from the method node's first child. 5. @import: `@import Foundation;` (a module_import node) now emits an imports edge. Dot-syntax property `accesses` (Bug 5) and @selector(...) target-action edges (Bug 6b) need type/name resolution policy and are left as follow-ups. Added six regression tests; the reporter's claim that compound messages lack a message_expression wrapper (Bug 6a) was checked against the real AST and refuted — they share Bug 2's root cause, fixed by the same field-name change. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 1 + graphify/extract.py | 132 +++++++++++++++++++++++++++++----------- tests/test_languages.py | 64 +++++++++++++++++++ 3 files changed, 163 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5677e4e..1bfdd30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Full release notes with details on each version: [GitHub Releases](https://githu ## Unreleased +- Fix: the Objective-C extractor was silently dropping most code-level relationships (#1475, thanks @JabberYQ for the detailed report). Five fixes: (1) ObjC `.h` headers were parsed by the C extractor (1 node, 0 edges, losing every `@interface`/`@protocol`/`@property`/method) — a `.h` is now routed to the ObjC extractor when it contains an ObjC-only directive (`@interface`/`@protocol`/`@implementation`/`@import`), which never hijacks a real C/C++ header; (2) `[receiver selector]` calls produced no `calls` edges at all because the method-body pass looked for `selector`/`keyword_argument_list` nodes, but the grammar tags selector parts with the field name `method` (type `identifier`) — the selector is now read from the `method` fields, skipping the receiver, which also makes compound sends like `[self a:x b:y]` resolve; (3) generic property types (`NSArray *`) were invisible because the type was wrapped in a `generic_specifier` — the element and container types are now both referenced; (4) class methods (`+foo`) were mislabeled `-foo`; (5) `@import Foundation;` now produces an `imports` edge. Property/dot-syntax `accesses` and `@selector(...)` target-action edges remain follow-ups. - Feat: link WPF/XAML views to their ViewModels and extract richer binding references (#1473, thanks @MikeKatsoulakis). Builds on the initial XAML support (#1460). Resolves a view to its ViewModel from an explicit ``, a design-time `d:DataContext="{d:DesignInstance Type=…}"`, the `View`→`ViewModel` naming convention, or Prism `ViewModelLocator.AutoWireViewModel="True"` — always against an actually-extracted C# class, so a name with no matching class (or an ambiguous one) emits no edge (explicit DataContext is EXTRACTED, conventions are INFERRED). Also extracts binding paths (`{Binding User.Name}`, `Path=Order.Total`), commands (`Command="{Binding SaveCommand}"`), converters, and CommunityToolkit `[ObservableProperty]`/`[RelayCommand]` generated members. The event-handler resolution stays gated on the .NET handler signature (no spurious event edges), and ViewModel discovery is bounded to the extraction root. - Fix: `.vue` Single File Components now extract their `