stripCppTemplateArgs (added in #1043 to drop <…> from templated base-class references so extends resolves) is not applied to method qualifiers. An out-of-line template method definition therefore keeps the class template parameter list in qualified_name.
Reproduction
template <typename T>
class Box { public: T get() const; void set(T v); private: T value; };
template <typename T> T Box<T>::get() const { return value; }
template <typename T> void Box<T>::set(T v) { value = v; }
After codegraph init, the nodes table has:
name |
qualified_name |
expected |
get |
Box<T>::get |
Box::get |
set |
Box<T>::set |
Box::set |
Notes:
name is already clean (get); only the qualifier leaks.
- Inline method bodies inside the class are unaffected (they come out as
Box::get); only the out-of-line definition syntax leaks the params — so the same method gets a different qualified_name depending on where it's defined.
- The
<T> here is the primary template's parameter name (always T), not a specialization, so it carries no disambiguating value.
Severe manifestation — qualified_name can exceed NAME_MAX (255)
With long, multi-line template parameter names (this is the shape of ICU's capi_helper.h), codegraph stores the entire Class<…params…>::method — newlines included — as qualified_name:
qualified_name (272 bytes):
ApiHelper<IntegerConversionSourceCTypeParameterForTheHelperTemplateClassInstanceLong,
IntegerConversionDestinationCPlusPlusTypeParameterForTheHelperTemplateClassLong,
kMagicValidationSentinelConstantForTheHelperTemplateClassInstanceGuardLong>::validate
A consumer that derives a filename from qualified_name then fails with OSError: [Errno 63] File name too long (272 > 255).
Impact
Same failure mode #1043 fixed for extends: name-matcher compares the qualifier before the last ::, and Box<T> does not match the class node indexed as Box, so a method resolved via its out-of-line definition can fail to link to its class.
Root cause / fix
extractCppReceiverType in src/extraction/languages/c-cpp.ts builds the receiver by joining the ::-parts of the declarator's qualified-id but does not strip template arguments; the receiver then becomes qualifiedName = \${receiverType}::${name}`intree-sitter.ts. Applying the existing stripCppTemplateArgsto the receiver (it already turnsOuter::Inner→Outer::Inner`) fixes both the normal and the long-name case. PR incoming.
Reproduced on 1.4.x.
stripCppTemplateArgs(added in #1043 to drop<…>from templated base-class references soextendsresolves) is not applied to method qualifiers. An out-of-line template method definition therefore keeps the class template parameter list inqualified_name.Reproduction
After
codegraph init, thenodestable has:namequalified_namegetBox<T>::getBox::getsetBox<T>::setBox::setNotes:
nameis already clean (get); only the qualifier leaks.Box::get); only the out-of-line definition syntax leaks the params — so the same method gets a differentqualified_namedepending on where it's defined.<T>here is the primary template's parameter name (alwaysT), not a specialization, so it carries no disambiguating value.Severe manifestation —
qualified_namecan exceedNAME_MAX(255)With long, multi-line template parameter names (this is the shape of ICU's
capi_helper.h), codegraph stores the entireClass<…params…>::method— newlines included — asqualified_name:A consumer that derives a filename from
qualified_namethen fails withOSError: [Errno 63] File name too long(272 > 255).Impact
Same failure mode #1043 fixed for
extends:name-matchercompares the qualifier before the last::, andBox<T>does not match the class node indexed asBox, so a method resolved via its out-of-line definition can fail to link to its class.Root cause / fix
extractCppReceiverTypeinsrc/extraction/languages/c-cpp.tsbuilds the receiver by joining the::-parts of the declarator's qualified-id but does not strip template arguments; the receiver then becomesqualifiedName = \${receiverType}::${name}`intree-sitter.ts. Applying the existingstripCppTemplateArgsto the receiver (it already turnsOuter::Inner→Outer::Inner`) fixes both the normal and the long-name case. PR incoming.Reproduced on 1.4.x.