fix(extraction): correct C++ reference-return and conversion-operator method names#1096
Merged
colbymchenry merged 2 commits intoJul 1, 2026
Merged
Conversation
… method names Two pre-existing C++ name-extraction bugs surfaced while validating the #1093 forward-declaration fix against real Unreal Engine repos (ActionRoguelike, ALS): 1. Inline methods/functions returning a reference were named after the whole declarator. `const int& getRef() const {…}` parses with a reference_declarator wrapping the function_declarator; extractName unwrapped pointer_declarator but not reference_declarator, so the method was named "& getRef() const" instead of "getRef" — polluting search and breaking caller linkage. Ubiquitous in UE headers (`const FGameplayTagContainer& GetActiveTags() const`). Now the reference wrapper is unwrapped alongside the pointer wrapper. 2. User-defined conversion operators were named with their full declarator — `operator EALSMovementState() const` — instead of `operator EALSMovementState`, so they didn't match the symbolic-overload style (`operator+`) and carried `() const` noise. The operator_cast declarator is now named `operator <type>`. Both are additive and C++-scoped (reference_declarator / operator_cast are C++ grammar nodes). Pointer, value, and out-of-line reference returns, and symbolic operator overloads, are unchanged. Six regression tests added. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…me fixes (#1096) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Context
While validating the #1093 forward-declaration fix against real Unreal Engine repos (
tomlooman/ActionRoguelike,PanicPetal/ALS-Community), a name-quality scan surfaced two pre-existing C++ name-extraction bugs. Neither is caused by #1093 — this fix is independent.Bugs fixed
1. Reference-returning methods/functions named after the whole declarator.
const int& getRef() const { … }parses with areference_declaratorwrapping thefunction_declarator.extractNameunwrappedpointer_declaratorbut notreference_declarator, so the method was named"& getRef() const"instead ofgetRef— breaking name search and caller linkage. This is ubiquitous in UE gameplay headers (e.g.const FGameplayTagContainer& GetActiveTags() const). Fix: unwrap the reference wrapper alongside the pointer wrapper.2. Conversion operators named with their full declarator.
operator EALSMovementState() constwas indexed verbatim instead ofoperator EALSMovementState, so it didn't match the symbolic-overload style (operator+) and carried() constnoise. Fix: name theoperator_castdeclaratoroperator <type>.Scope / safety
Both changes are additive and C++-scoped —
reference_declaratorandoperator_castare C++ grammar node types, so no other language is affected (full 401-test extraction suite passes). Controls confirmed unchanged: pointer returns (int* f()→getPtr), value returns (int f() const→getVal), out-of-line reference returns (resolve via the qualified-name hook), and symbolic operator overloads (operator+,operator[]).Validation
Before/after re-index of both UE repos: every reference-returning getter and conversion operator now carries a clean name; a name-mangle scan drops to zero real mangles. Six regression tests added (
extraction.test.ts).Known follow-up (not in this PR)
A separate, messier case remains: an unknown function-level macro before an unrecognized return type (e.g. UE's
FORCEINLINE FString GetEnumerationToString(...)) throws tree-sitter into error recovery and leaks the return type into the name (FString GetEnumerationToString). That's the same family as #946/#1061 (macro misparse) and deserves its own focused fix + macro curation.🤖 Generated with Claude Code