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

Function findDeclaratorQualifiedId

src/extraction/languages/c-cpp.ts:236–253  ·  view source on GitHub ↗

* Find the function NAME's `qualified_identifier` (`Foo::bar`) inside a * declarator, skipping the `parameter_list` — a parameter with a qualified type * (`const std::string& x`) must NOT be mistaken for the method name. Without the * skip, a plain free function `std::string TableFileName(const s

(declarator: SyntaxNode)

Source from the content-addressed store, hash-verified

234 * and its file looked like nothing depended on it.
235 */
236function findDeclaratorQualifiedId(declarator: SyntaxNode): SyntaxNode | undefined {
237 const queue: SyntaxNode[] = [declarator];
238 while (queue.length > 0) {
239 const current = queue.shift()!;
240 if (current.type === 'qualified_identifier') return current;
241 for (let i = 0; i < current.namedChildCount; i++) {
242 const child = current.namedChild(i);
243 // Don't descend into parameters, the trailing return type or the
244 // clauses after them — `const std::string&`, `-> std::string`,
245 // nlohmann/json's `noexcept(noexcept(JSONSerializer<U>::to_json(…)))`,
246 // `throw(std::bad_alloc)`, `requires std::integral<T>` name no function.
247 if (child && !DECLARATOR_NON_NAME_PARTS.has(child.type)) {
248 queue.push(child);
249 }
250 }
251 }
252 return undefined;
253}
254
255/** The parts of a function declarator that hold types or expressions, never its name. */
256const DECLARATOR_NON_NAME_PARTS: ReadonlySet<string> = new Set([

Callers 2

extractCppReceiverTypeFunction · 0.85

Calls 2

hasMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected