ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
acav::SourceLocationIndex Class Reference

Index for source-to-AST node lookup. More...

#include <SourceLocationIndex.h>

Public Member Functions

 SourceLocationIndex (const SourceLocationIndex &)=delete
SourceLocationIndex & operator= (const SourceLocationIndex &)=delete
void addNode (AstViewNode *node)
 Add node to index.
void finalize ()
 Finalize all interval trees (call after all nodes added).
std::vector< AstViewNode * > getNodesAt (FileID fileId, unsigned line, unsigned column) const
 Query nodes at specific source position.
AstViewNodegetFirstNodeContainedInRange (FileID fileId, unsigned beginLine, unsigned beginColumn, unsigned endLine, unsigned endColumn) const
 Query first node fully contained within a range.
std::size_t getFileCount () const
 Get number of files in index.
std::size_t getTotalIntervals () const
 Get total number of intervals across all files.
bool hasFile (FileID fileId) const
 Check whether the current TU AST contains any indexed nodes for a file.

Detailed Description

Index for source-to-AST node lookup.

Maintains one IntervalTree per FileID. Built during AST extraction. Owned by AstContext, destroyed when TU is closed.

Definition at line 108 of file SourceLocationIndex.h.

Member Function Documentation

◆ addNode()

void acav::SourceLocationIndex::addNode ( AstViewNode * node)

Add node to index.

Parameters
nodeAST node with valid source range
Precondition
node->getSourceRange().begin().fileID() != 0 (valid)

Definition at line 145 of file SourceLocationIndex.cpp.

References acav::AstViewNode::getSourceRange(), and acav::FileManager::InvalidFileID.

◆ finalize()

void acav::SourceLocationIndex::finalize ( )

Finalize all interval trees (call after all nodes added).

Definition at line 166 of file SourceLocationIndex.cpp.

◆ getFileCount()

std::size_t acav::SourceLocationIndex::getFileCount ( ) const
inline

Get number of files in index.

Definition at line 146 of file SourceLocationIndex.h.

◆ getFirstNodeContainedInRange()

AstViewNode * acav::SourceLocationIndex::getFirstNodeContainedInRange ( FileID fileId,
unsigned beginLine,
unsigned beginColumn,
unsigned endLine,
unsigned endColumn ) const

Query first node fully contained within a range.

Parameters
fileIdFile identifier
beginLineRange start line (1-based)
beginColumnRange start column (1-based)
endLineRange end line (1-based)
endColumnRange end column (1-based)
Returns
First node contained in the range, or nullptr

Definition at line 184 of file SourceLocationIndex.cpp.

◆ getNodesAt()

std::vector< AstViewNode * > acav::SourceLocationIndex::getNodesAt ( FileID fileId,
unsigned line,
unsigned column ) const

Query nodes at specific source position.

Parameters
fileIdFile identifier
lineLine number (1-based)
columnColumn number (1-based)
Returns
Vector of matching nodes, sorted deepest-first

Definition at line 173 of file SourceLocationIndex.cpp.

◆ getTotalIntervals()

std::size_t acav::SourceLocationIndex::getTotalIntervals ( ) const

Get total number of intervals across all files.

Definition at line 196 of file SourceLocationIndex.cpp.

◆ hasFile()

bool acav::SourceLocationIndex::hasFile ( FileID fileId) const

Check whether the current TU AST contains any indexed nodes for a file.

Definition at line 204 of file SourceLocationIndex.cpp.


The documentation for this class was generated from the following files: