ACAV 69797fb42a2b
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.
AstViewNode * getFirstNodeContainedInRange (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 135 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 237 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 266 of file SourceLocationIndex.cpp.

◆ getFileCount()

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

Get number of files in index.

Definition at line 173 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 284 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 273 of file SourceLocationIndex.cpp.

◆ getTotalIntervals()

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

Get total number of intervals across all files.

Definition at line 296 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 304 of file SourceLocationIndex.cpp.


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