Repository navigation
fix(swift): extract computed & observed properties (#2181) - #2220
Closed
ozdemirsarman wants to merge 1 commit into
Closed
ozdemirsarman wants to merge 1 commit into
ozdemirsarman wants to merge 1 commit into
Conversation
function_types only recognised func/init/deinit/subscript, so computed properties (var body: some View { ... }) and willSet/didSet observers produced no node and their bodies were never walked — erasing the whole SwiftUI view layer. Emit a function-like member node for them and defer the body to the call-walk via function_bodies; stored properties are unchanged. Adds tests.
Member
|
Thanks @ozdemirsarman. Shipped in v0.9.28 (cherry-picked to v8 to preserve your authorship). Closed-unmerged here, but it's in the release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.28 |
durmazoguzhan
added a commit
to durmazoguzhan/graphify
that referenced
this pull request
Aug 24, 2026
C# was the only language with a class-shaped type layer whose state was missing from the graph. A field or property produced a `references` edge to its type and no node of its own, so nothing could point at a member. C++ has emitted a node per data member with a `defines` edge for a while, Graphify-Labs#2971 is adding the same for C structs, and Graphify-Labs#2220 gave Swift computed properties nodes. This puts C# on that line, using the same relation and `context="field"` as the C++ branch. The member node does not depend on what the member is typed as, so it is emitted before the type checks: a primitive and a generic parameter both leave a member behind even though neither produces a type reference. Properties keep landing on `defines` rather than `method`, since a property is state, not a call target. Cost on a 1457-file .NET service: 9925 -> 15489 nodes and 29547 -> 34989 edges, +56% and +18%. It is a DTO-heavy corpus, which is where that ratio comes from. The added nodes are leaves, so the hub structure is unchanged: the top god nodes are identical except ProductService moving 259 -> 263 edges. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NCycXc9pjGzovxrZqojPUE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2181.
Problem
Swift's extractor only treats
function_declaration,init_declaration,deinit_declarationandsubscript_declarationas callables(
_SWIFT_CONFIG.function_types). Computed properties parse asproperty_declaration → computed_property → statements, which no branchhandled — so they produced no node and their bodies were never walked.
For SwiftUI this is severe:
var body: some View { … }is a computed property,so an entire view file collapses to just the file + struct nodes and every UI
element and call inside
bodydisappears.willSet/didSetobservers have thesame shape and lost their body calls too.
Before (repro)
Only
.doTap()was emitted;body,toggled, and thedoTap()call insidebodywere all missing.Fix
In the Swift
property_declarationbranch (which already collects type-annotationreferences), after the existing handling: if the property has a
computed_propertyor
willset_didset_blockchild, emit a function-like member node (.name,methodedge to the enclosing type) and defer its body to the call-walk viafunction_bodies— the same mechanism methods use. This is additive: theexisting
references/field edges from the property's type are unchanged.Stored properties have no body child, so they are untouched (no regression).
After
.bodyand.toggledare emitted, and thedoTap()call insidebodynowproduces a
callsedge from.body→.doTap(), so the view hierarchy istraversed.
Tests
Adds
tests/test_swift_computed_properties.py:referencesedge (regression guard);willSet/didSetobserver body is walked.Full language test suite (
test_languages.py, 324 tests) and the existing Swifttests pass with no changes.