MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / matchCppDeclaredType

Function matchCppDeclaredType

src/resolution/cpp-supertypes.ts:168–187  ·  view source on GitHub ↗
(ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

166 * candidate, and a list's own `next` links nothing.
167 */
168export function matchCppDeclaredType(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null {
169 const holder = context.getNodeById?.(ref.fromNodeId);
170 if (!holder) return null;
171 const site: CppNameSite = {
172 scope: holder.kind === 'type_alias' ? cppParentScope(holder.qualifiedName) : holder.qualifiedName,
173 file: holder.filePath,
174 line: ref.line,
175 parameters: cppTemplateParameters(holder, context),
176 declared: true,
177 };
178 // A macro the file sees can rename the type (`#define sds hisds`), and a type
179 // the new name doesn't reach is left as written.
180 const renamed = cMacroRename(ref.referenceName, site.file, ref.line, ref.language, context);
181 const found = (renamed && cppClassWritten(renamed, site, ref, context)) || cppClassWritten(ref.referenceName, site, ref, context);
182 const node = found === undefined ? definedByIncluder(ref.referenceName, site, context) : found?.node;
183 if (!node || node.id === holder.id) return null;
184 return found?.exact
185 ? { original: ref, targetNodeId: node.id, confidence: 0.9, resolvedBy: 'qualified-name' }
186 : { original: ref, targetNodeId: node.id, confidence: 0.7, resolvedBy: 'exact-match' };
187}
188
189/**
190 * The type a header names and only a source file including it defines, which

Callers 1

resolveOneInnerMethod · 0.90

Calls 6

cppParentScopeFunction · 0.90
cppTemplateParametersFunction · 0.90
cMacroRenameFunction · 0.90
cppClassWrittenFunction · 0.85
definedByIncluderFunction · 0.85
getNodeByIdMethod · 0.65

Tested by

no test coverage detected