Expand description
The C++ declaration walk, including the macro-sentinel error recovery.
Every function here is a pure function of a parsed tree and its source text.
analyzer/cpp/adapter.rs in brokk-bifrost-analysis drives
CppVisitor out of LanguageAdapter::parse_file.
Structs§
- CppSentinel
Recovered Class - CppSentinel
Recovered Owner - Owned structural recovery metadata for a namespace-sentinel region.
- CppVisitor
- Scope
Info
Functions§
- collect_
cpp_ identifiers - cpp_
export_ macro_ token - cpp_
field_ declaration_ linkage - Classify a C++ field while its declaration syntax is already available.
- cpp_
file_ using_ namespaces - Every
using namespace X;directive target in a file, in source order, for resolution-time consumers that need the file’s using-directives without the per-position scope threading extraction does. Parsessourcefresh and walks the tree structurally, reusingcpp_using_namespace_target(which keys on the grammar’snamespacekeyword token, not source text), so it never misreads a member-importingusing X::Y;as a namespace directive. - cpp_
member_ fq - Structured name for a member unit (function, field, enumerator). The
short_nameis the owning$-joined nested-classTypechain followed, when the member has an owner, by.member; free functions and globals have no owner and no., so the wholeshort_nameis the terminalSegmentKind::Member. C++ member names never contain a literal., so the single.(if any) separates the owner chain from the member. - cpp_
sentinel_ recovered_ classes - Recover the class and out-of-line owner scopes from every malformed
namespace-sentinel region in
root. - cpp_
sentinel_ recovered_ scope_ for_ node - Resolve the lexical scope restored for a node in a malformed
namespace-sentinel region. Owner spans (out-of-line member definitions)
outrank class spans, which in turn outrank the surviving namespace body.
The class ancestor suffix is recovered from the original CST so nested
members keep their complete
Outer::Innerowner chain. - cpp_
template_ term - is_
direct_ recovered_ exported_ class_ field_ declaration - is_
recovered_ exported_ class_ container - node_
text - normalize_
cpp_ whitespace - recover_
quoted_ includes - recovered_
exported_ class_ has_ body - recovered_
macro_ return_ type_ node - Recognize the phantom field tree-sitter emits for a macro-qualified
function return type. For example,
static API result_type ThresholdForSmallA() { ... }can become afield_declaration(APIas the type andresult_typeas a field name) followed by a cleanfunction_definitionforThresholdForSmallA.