clang 20.0.0git
|
An AST selection value that corresponds to a selection of a set of statements that belong to one body of code (like one function). More...
#include "clang/Tooling/Refactoring/ASTSelection.h"
Public Member Functions | |
CodeRangeASTSelection (CodeRangeASTSelection &&)=default | |
CodeRangeASTSelection & | operator= (CodeRangeASTSelection &&)=default |
ArrayRef< SelectedASTNode::ReferenceType > | getParents () |
Returns the parent hierarchy (top to bottom) for the selected nodes. | |
size_t | size () const |
Returns the number of selected statements. | |
const Stmt * | operator[] (size_t I) const |
bool | isInFunctionLikeBodyOfCode () const |
Returns true when a selected code range is in a function-like body of code, like a function, method or a block. | |
const Decl * | getFunctionLikeNearestParent () const |
Returns the nearest function-like parent declaration or null if such declaration doesn't exist. | |
Static Public Member Functions | |
static std::optional< CodeRangeASTSelection > | create (SourceRange SelectionRange, const SelectedASTNode &ASTSelection) |
An AST selection value that corresponds to a selection of a set of statements that belong to one body of code (like one function).
For example, the following selection in the source.
Would correspond to a code range selection of statements "int x = 0" and the entire compound statement that follows it.
A CodeRangeASTSelection
value stores references to the full SelectedASTNode
tree and should not outlive it.
Definition at line 96 of file ASTSelection.h.
|
default |
|
static |
Definition at line 380 of file ASTSelection.cpp.
References clang::tooling::ContainsSelection, findDeepestWithKind(), clang::SourceRange::getBegin(), and clang::SourceRange::getEnd().
Referenced by clang::tooling::CodeRangeASTSelectionRequirement::evaluate().
const Decl * CodeRangeASTSelection::getFunctionLikeNearestParent | ( | ) | const |
Returns the nearest function-like parent declaration or null if such declaration doesn't exist.
Definition at line 441 of file ASTSelection.cpp.
References D, clang::DynTypedNode::get(), isFunctionLikeDeclaration(), Node, and Parent.
|
inline |
Returns the parent hierarchy (top to bottom) for the selected nodes.
Definition at line 102 of file ASTSelection.h.
bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode | ( | ) | const |
Returns true when a selected code range is in a function-like body of code, like a function, method or a block.
This function can be used to test against selected expressions that are located outside of a function, e.g. global variable initializers, default argument values, or even template arguments.
Use the getFunctionLikeNearestParent
to get the function-like parent declaration.
Definition at line 419 of file ASTSelection.cpp.
References D, clang::DynTypedNode::get(), isFunctionLikeDeclaration(), Node, and Parent.
Referenced by clang::tooling::ExtractFunction::initiate().
|
default |
Definition at line 111 of file ASTSelection.h.
|
inline |
Returns the number of selected statements.
Definition at line 105 of file ASTSelection.h.
Referenced by clang::tooling::ExtractFunction::initiate().