feat(graph): add cross-file Class-to-Function CONTAINS linking#735
Open
jannahopp wants to merge 1 commit intoCodeGraphContext:mainfrom
Open
feat(graph): add cross-file Class-to-Function CONTAINS linking#735jannahopp wants to merge 1 commit intoCodeGraphContext:mainfrom
jannahopp wants to merge 1 commit intoCodeGraphContext:mainfrom
Conversation
In C/C++, classes are declared in .h files and methods are defined in .cpp files. The existing CONTAINS edge creation matched Class and Function nodes only when they shared the same file path, which never succeeds for C++ method definitions. Add a cross-file fallback: if the same-file match fails, try matching the Class node by name only (no path constraint) and link it to the Function node. This enables class_hierarchy and overrides queries to return methods for C++ classes. Note: the cross-file match uses class name only, so classes with identical names in different files could get false links. The same-file match is always tried first to avoid this for languages where class and methods share a file (Python, JS, etc.). Depends on: feat/cpp-parser-improvements (which adds class_context to Function nodes for qualified C++ method definitions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@jannahopp is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
5 tasks
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.
Summary
Add cross-file fallback for Class-to-Function CONTAINS edge creation, enabling
class_hierarchyandoverridesqueries to return methods for C++ classes.Problem
In C/C++, classes are declared in
.hfiles and methods are defined in.cppfiles. The existing CONTAINS edge creation matched Class and Function nodes only when they shared the same file path:This never succeeds for C++ method definitions, so
class_hierarchyreturned 0 methods andoverridesreturned 0 results for all C++ classes.Solution
Try the same-file match first (works for Python, JS, etc.), then fall back to matching the Class node by name only:
This requires the Function node to have a
class_contextproperty (provided by #734).Known limitation
The cross-file fallback matches by class name only (no path constraint). Classes with identical names in different files could get false links. The same-file match is always tried first, so this only affects languages with header/implementation file splits (C, C++, Objective-C). This is documented in a code comment.
Impact
On a 300-file C++ codebase:
class_hierarchy("QueueElement_Dialer_Export")now returns 1 parent, 3 children, and 42 methods (previously: 0 parents, 0 methods)overrides("execute")now returns 6 implementations across classes (previously: 0)Depends on
class_contextto Function nodes🤖 Generated with Claude Code