Cpp.AstNodeProperties Class
Namespace: Cpp
Represents the abstract syntax tree nodes of your code
Since R2026a
Description
AstNodeProperties class is a superclass that represent an abstract syntax
tree (AST) node. This class implements predicates of a generic AST node that can be accessed
and invoked by its child classes.
Predicates
| Predicates | Description |
|---|---|
toNode(T self, required Cpp.Node.Node &node) | Converts T to its underlying Cpp.Node.Node representation (type conversion; always holds). |
nodeText(T self, required Lang.String &text) | Retrieves the source text corresponding to self and stores it in text. |
nodeKind(T self, required Lang.String &kind) | Retrieves the node kind (Tree-sitter type) of self (e.g., "if_statement") and stores it in kind. |
startLine(T self, required Lang.Unsigned &line) | Retrieves the starting line number of self and stores it in line. |
startColumn(T self, required Lang.Unsigned &column) | Retrieves the starting column number of self and stores it in column. |
startPosition(T self, Lang.String &file, Lang.Unsigned &line, Lang.Unsigned &column) | Retrieves the filename, line, and column for the position at which T starts. |
startByte(T self, required Lang.Int &byte) | Retrieves the starting byte offset of self and stores it in byte. |
endLine(T self, required Lang.Unsigned &line) | Retrieves the ending line number of self and stores it in line. |
endColumn(T self, required Lang.Unsigned &column) | Retrieves the ending column number of self and stores it in column. |
endPosition(T self, Lang.String &file, Lang.Unsigned &line, Lang.Unsigned &column) | Retrieves the filename, line, and column for the position at which T ends. |
endByte(T self, required Lang.Int &byte) | Retrieves the ending byte offset of self and stores it in byte. |
getAChild(T self, Cpp.Node.Node &child) | Retrieves a named child node from the AST of self into child; may return any child when multiple exist. |
getACSTChild(T self, Cpp.Node.Node &child) | Retrieves a child (named or anonymous) from the CST of self into child; may return any child when multiple exist. |
numChildren(T self, required Lang.Int &num) | Retrieves the number of direct AST children of self into num. |
numCSTChildren(T self, required Lang.Int &num) | Retrieves the number of direct CST children (including anonymous nodes) of self into num. |
nthCSTChild(T self, Lang.Int &nth, Cpp.Node.Node &child) | Retrieves the nth CST child (1-based) of self into child. |
nthASTChild(T self, Lang.Int &nth, Cpp.Node.Node &child) | Retrieves the nth AST child (1-based) of self into child (named nodes only). |
lastChild(T self, required Cpp.Node.Node &child) | Retrieves the last direct AST child of self into child. |
lastCSTChild(T self, Cpp.Node.Node &child) | Retrieves the last direct CST child of self into child. |
lastASTChild(T self, Cpp.Node.Node &child) | Retrieves the last direct AST child of self into child. |
getAnAncestor(T self, Cpp.Node.Node &ancestor) | Retrieves an ancestor node of self into ancestor; may return any ancestor when multiple exist. |
parent(T self, Cpp.Node.Node &parent) | Retrieves the direct parent of self into parent. |
getADescendant(T self, Cpp.Node.Node &descendant) | Retrieves a descendant of self into descendant; may return any descendant when multiple exist. |
getADescendantOrSelf(T self, Cpp.Node.Node &descendant) | Retrieves self or a descendant of self into descendant. |
getEnclosingStatement(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing statement node for self into parent. |
isEnclosedInStatement(T self) | Is true if self is enclosed in any statement. |
getEnclosingFunction(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing function definition for self into parent. |
isEnclosedInFunction(T self) | Is true if self is enclosed in a function definition. |
getEnclosingClass(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing class specifier for self into parent. |
isEnclosedInClass(T self) | Is true if self is enclosed in a class specifier. |
getEnclosingNamespace(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing namespace definition for self into parent. |
isEnclosedInNamespace(T self) | Is true if self is enclosed in a namespace definition. |
getEnclosingTranslationUnit(T self, required Cpp.Node.Node &parent) | Retrieves the enclosing translation unit (file root) for self into parent. |
isEnclosedInTranslationUnit(T self) | Is true if self is enclosed in a translation unit. |
getEnclosingFile(T self, required Cpp.Node.Node &root) | Retrieves the enclosing file root node for self into root. |
getEnclosingLoop(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing loop statement (for, while, or do-while) for self into parent. |
isEnclosedInLoop(T self) | Is true if self is enclosed in a loop statement. |
getEnclosingSwitch(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing switch statement for self into parent. |
isEnclosedInSwitch(T self) | Is true if self is enclosed in a switch statement. |
getEnclosingTry(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing try statement for self into parent. |
isEnclosedInTry(T self) | Is true if self is enclosed in a try statement. |
getEnclosingCatch(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing catch clause for self into parent. |
isEnclosedInCatch(T self) | Is true if self is enclosed in a catch clause. |
getEnclosingSehTry(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing SEH __try statement for self into parent. |
isEnclosedInSehTry(T self) | Is true if self is enclosed in an SEH __try statement. |
getEnclosingSehExceptClause(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing SEH __except clause for self into parent. |
isEnclosedInSehExceptClause(T self) | Is true if self is enclosed in an SEH __except clause. |
getEnclosingSehFinallyClause(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing SEH __finally clause for self into parent. |
isEnclosedInSehFinallyClause(T self) | Is true if self is enclosed in an SEH __finally clause. |
getEnclosingLambda(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing lambda expression for self into parent. |
isEnclosedInLambda(T self) | Is true if self is enclosed in a lambda expression. |
getEnclosingTemplateDefinition(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing template declaration for self into parent. |
isEnclosedInTemplateDefinition(T self) | Is true if self is enclosed in a template declaration. |
getEnclosingIf(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing if_statement for self into parent. |
isEnclosedInIf(T self) | Is true if self is enclosed in an if_statement. |
getEnclosingBlock(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing compound_statement (block) for self into parent. |
isEnclosedInBlock(T self) | Is true if self is enclosed in a compound_statement (block). |
getEnclosingScope(T self, required Cpp.Node.Node &parent) | Retrieves the nearest enclosing scope for self (function, class, namespace, or block) into parent. |
isEnclosedInScope(T self) | Is true if self is enclosed in any scope. |
nodeLocation(T self, Lang.String &file_path, Lang.Int &start_line, Lang.Int &start_column, Lang.Int &end_line, Lang.Int &end_column, Lang.Int &start_byte, Lang.Int &end_byte) | Retrieves the file path, start/end line & column, and start/end byte offsets for self. |
nodeFlags(T self, Lang.Int &is_named, Lang.Int &is_missing, Lang.Int &is_extra, Lang.Int &has_error) | Retrieves flags for self: named/anonymous, missing (error-recovery), extra (comments/whitespace), and whether any parse error exists in the subtree. |
nodePosition(T self, Cpp.Node.Node &parent, Lang.Int &nth, Lang.Int &cst_nth, Lang.Int &ast_nth) | Retrieves position information of self within parent (1-based): overall child index, CST index, and AST index (0 for anonymous/extra). |
subtree(T self, Cpp.Node.Node &least, Cpp.Node.Node &greatest, Lang.Int &root_depth, Lang.Int &nb_childs, Lang.Int &nb_cst_childs, Lang.Int &nb_ast_childs) | Retrieves information about the subtree rooted at self: node ID range, root depth, and child counts (overall/CST/AST). |
isAfterInAST(T self, Cpp.Node.Node first) | Is true if self occurs after or at the same position as first in AST node ordering. |
isBeforeInAST(T self, Cpp.Node.Node last) | Is true if self occurs after or at the same
position as last in AST node ordering |
isAncestorOf(T self, Cpp.Node.Node descendant) | Is true if self is an ancestor of
descendant in the AST hierarchy. |
isDescendantOf(T self, Cpp.Node.Node ancestor) | Is true if self is a descendent of
ancestor in the AST hierarchy. |
areInSameTranslationUnit(T self, Cpp.Node.Node
other) | Is true if self and
other occur in the same translation unit.. |
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)