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§
- CppBase
Specifier Fact - CppComparable
Parameter - CppDisplaced
Preprocessor Boundary - The effective end of a conditional whose real terminator tree-sitter displaced into declaration recovery.
- CppNamespace
Forward Scan - The namespace forward declarations one tree’s prefix holds, folded in as the walk asks about them.
- CppPartitioned
Region - One owned container reparse deferred until the primary declaration walk has
reached its source position. The tree and context are owned so the deferred
walk never retains a
Nodeborrowed from a temporary recovery tree. - CppRecovered
Export Class Index - One file’s embedded export-macro class recovery, resolved once and keyed by
the
ERRORnode that mints each set. - CppRecovery
Capture - What one open
CppVisitor::record_recovered_declarationshas watched happen to the declaration set. - CppSentinel
Recovered Class - CppSentinel
Recovered Owner - Owned structural recovery metadata for a namespace-sentinel region.
- CppTemplate
Parameter Name Matches - CppTree
Identity - Which tree a
CppNamespaceForwardScanwas folded out of. - CppUsing
Declaration Binding - One
using ns::Type;declaration at namespace scope: the name it introduces and the canonical namespace of the entity it names. - CppVisitor
- Scope
Info
Enums§
- CppAccess
Specifier - CppComparable
Node - CppComparable
Slot - CppFormal
Role - A grammar role for one direct child of a C or C++ parameter list. Invalid and stopped classifications are separate from a valid empty list.
- CppFormal
Role Error - CppParameter
Type - One callable parameter’s parser-derived type.
- Object
Macro Field Event - One source-order event from an object-like field-list macro environment.
Functions§
- collect_
cpp_ object_ macro_ field_ events - Collect object-like field-list macro events in source order. Conditional branches remain visible in the event stream: callers that cannot prove branch selection can invalidate names conservatively instead of inventing a replacement from one branch.
- cpp_
callable_ declaration_ return_ type_ identity - Return the structured declared result type of one callable declaration.
- cpp_
callable_ declaration_ return_ type_ node - Return the AST node that describes one callable’s declared result type.
- cpp_
callable_ parameter_ type_ identities - The structured type of each invocation parameter, in declaration order.
- cpp_
colon_ source_ aliases - Fully-kinded identities a C++ source spelling joined only by
::can name. - cpp_
comparable_ parameter_ shapes - The comparable shape of each invocation parameter, in declaration order.
- cpp_
declaration_ has_ native_ must_ use_ attribute - Whether one declaration carries a native must-use attribute.
- cpp_
declaration_ type_ identity - The parser-derived type of one declared object or parameter.
- cpp_
displaced_ preprocessor_ boundary - cpp_
displaced_ preprocessor_ branch - The first
#else/#elifofconditionalthat tree-sitter displaced into anERRORinside the conditional’s own branch. - cpp_
displaced_ preprocessor_ terminator - The real
#endifthat tree-sitter consumed inside an error subtree. - cpp_
export_ macro_ token - cpp_
field_ declaration_ linkage - Classify a C++ field while its declaration syntax is already available.
- cpp_
formal_ role_ with_ step - Classify a structurally selected list child. A bare
voidis valid only when it is the sole parameter; a typed pack keeps its declaration node. - cpp_
function_ declarator_ at - The callable declarator of the declaration that covers
start_byte. - 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_
recovered_ type_ parameter_ name - The name of a defaulted type parameter that tree-sitter-cpp recovered as a
non-type parameter. The grammar’s
default_typecannot hold an abstract declarator, sotypename U = T*always recovers the*as an ERROR sibling; since grammar 0.24.4 the parameter itself also becomes anoptional_parameter_declarationwithtype: dependent_type(typename U), no declarator anddefault_value: T. A valid dependent type names a qualified type aftertypename, so a bare type identifier there is the type parameter’s name. - cpp_
rendered_ name_ fq - Structured name for a rendered C++ qualified name supplied at the input
edge, such as an
Analyzer::definitions("ns.Outer$Inner")argument. - 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_
structured_ type_ path - The dot-free name components a qualified C++ name node writes, outermost first.
- cpp_
template_ parameter_ name_ matches - cpp_
template_ term - cpp_
type_ field_ contains_ node - cpp_
unclosed_ construct_ openers - The opening tokens of the constructs a C/C++ parse left open at the end of the file, in source order (#3501). Empty unless the tree’s root is an ERROR node.
- direct_
identifier_ name - Normalize the text of a directly selected C++ identifier node.
- enclosing_
cpp_ namespace_ nodes - The namespace definition ancestors of
node, ordered from outermost to innermost. - is_
direct_ recovered_ exported_ class_ field_ declaration - is_
macro_ wrapped_ declaration_ envelope - Whether
nodeis an envelope an attribute-like macro invocation left where declarations were written: the declaration-scopeERROR[macro_wrapped_declarations] reads, or the collapsed run [collapsed_macro_declaration_run] reads. - is_
recovered_ exported_ class_ base_ type_ node - Whether
nodeis the base type displaced into the declarator field of an export-macro class that tree-sitter represented as a declaration or function definition. - is_
recovered_ exported_ class_ container - is_
recovered_ fragmented_ partial_ specialization_ container - Whether
nodeis the function-shaped parser wrapper whose body was recovered as a fragmented partial-specialization class body. - node_
text - Verbatim source text spanned by
node, or""when the byte range is not a validstrboundary (adversarial or partially-parsed input). - normalize_
cpp_ whitespace - recovered_
callable_ body_ at - Whether the source a recovered callable’s byte range spells is a definition (a declarator with a body) rather than a declaration.
- 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.