* 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)
| 234 | * and its file looked like nothing depended on it. |
| 235 | */ |
| 236 | function 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. */ |
| 256 | const DECLARATOR_NON_NAME_PARTS: ReadonlySet<string> = new Set([ |
no test coverage detected