Skip to content

fix: merge stub nodes with real cross-language definitions#442

Open
V0v1kkk wants to merge 1 commit intosafishamsi:v4from
V0v1kkk:fix/merge-stub-nodes
Open

fix: merge stub nodes with real cross-language definitions#442
V0v1kkk wants to merge 1 commit intosafishamsi:v4from
V0v1kkk:fix/merge-stub-nodes

Conversation

@V0v1kkk
Copy link
Copy Markdown

@V0v1kkk V0v1kkk commented Apr 18, 2026

Fixes #439

Summary

Adds a post-extraction pass that merges stub nodes (nodes with no source_file, created by the generic extractor for unresolved type references) with their actual definitions from other files.

When C# code inherits from a type defined in F# (e.g. class SqliteBookStore : BookStore), the C# extractor creates a stub node bookstore because it can't resolve the base type. Meanwhile, the F# extractor creates the real node interfaces_bookstore from Interfaces.fs. The inherits edge incorrectly points to the stub instead of the real definition.

The fix:

  1. Finds stub nodes (no source_file) that have a matching real definition (by label match)
  2. Prioritizes definition files (Interfaces.fs, Domain.fs, Types.fs, Contracts.fs, Abstractions.fs)
  3. Redirects all edges from the stub to the real definition
  4. Removes the stub node

Impact

Tested on a mixed F#/C# project — all cross-language inherits edges now point to real definitions. This is particularly important for mixed-language codebases where interfaces/abstract types are defined in one language and implemented in another.

Test Plan

  • Verified on a mixed F#/C# project with 8 cross-language inheritance relationships
  • All inherits edges now correctly point to real definitions
  • Stub nodes properly removed
  • Existing tests pass

When C# code inherits from a type defined in F# (e.g. SqliteBookStore
extends BookStore from Interfaces.fs), the C# extractor creates a stub
node with an empty source_file. This stub disconnects the inheritance
edge from the real F# definition.

Add a post-extraction pass that merges stub nodes into real definitions
by matching labels. Prioritize definition files (Interfaces.fs,
Domain.fs, Types.fs) so inherits edges point to abstract types rather
than implementation classes.

Made-with: Cursor
V0v1kkk added a commit to V0v1kkk/graphify that referenced this pull request Apr 18, 2026
Add upstream contribution status: 3 graphify PRs (safishamsi#440-safishamsi#442), 1
tree-sitter-razor PR (safishamsi#19), 1 tree-sitter-fsharp issue (safishamsi#176).
Document fork locations, blocked PRs, and final test metrics.
Fix document structure (reorder commit 7, remove duplicated sections).

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stub nodes break cross-language inheritance edges

1 participant