class CodeRangeASTSelection

Declaration

class CodeRangeASTSelection { /* full declaration omitted */ };

Description

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 \c CodeRangeASTSelection value stores references to the full\c SelectedASTNode tree and should not outlive it.

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:95

Member Variables

private SelectedASTNode::ReferenceType SelectedNode
The reference to the selected node (or reference to the selected child nodes).
private llvm::SmallVector<SelectedASTNode::ReferenceType, 8> Parents
The parent hierarchy (top to bottom) for the selected noe.
private bool AreChildrenSelected
True only when the children of the selected node are actually selected.

Method Overview

Methods

CodeRangeASTSelection(
    clang::tooling::CodeRangeASTSelection&&)

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:97

Parameters

clang::tooling::CodeRangeASTSelection&&

CodeRangeASTSelection(
    SelectedASTNode::ReferenceType SelectedNode,
    ArrayRef<SelectedASTNode::ReferenceType>
        Parents,
    bool AreChildrenSelected)

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:137

Parameters

SelectedASTNode::ReferenceType SelectedNode
ArrayRef<SelectedASTNode::ReferenceType> Parents
bool AreChildrenSelected

static Optional<
    clang::tooling::CodeRangeASTSelection>
create(clang::SourceRange SelectionRange,
       const clang::tooling::SelectedASTNode&
           ASTSelection)

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:134

Parameters

clang::SourceRange SelectionRange
const clang::tooling::SelectedASTNode& ASTSelection

const clang::Decl* getFunctionLikeNearestParent()
    const

Description

Returns the nearest function-like parent declaration or null if such declaration doesn't exist.

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:131

ArrayRef<SelectedASTNode::ReferenceType>
getParents()

Description

Returns the parent hierarchy (top to bottom) for the selected nodes.

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:101

bool isInFunctionLikeBodyOfCode() const

Description

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 \c getFunctionLikeNearestParent to get the function-like parent declaration.

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:127

size_t size() const

Description

Returns the number of selected statements.

Declared at: clang/include/clang/Tooling/Refactoring/ASTSelection.h:104