48 bool contains(
unsigned line,
unsigned column)
const;
65 IntervalTree() =
default;
66 ~IntervalTree() =
default;
69 IntervalTree(
const IntervalTree &) =
delete;
70 IntervalTree &operator=(
const IntervalTree &) =
delete;
83 std::vector<AstViewNode *>
query(
unsigned line,
unsigned column)
const;
92 unsigned endLine,
unsigned endColumn)
const;
95 std::size_t
size()
const {
return intervals_.size(); }
98 std::vector<Interval> intervals_;
99 bool finalized_ =
false;
108class SourceLocationIndex {
110 SourceLocationIndex() =
default;
111 ~SourceLocationIndex() =
default;
114 SourceLocationIndex(
const SourceLocationIndex &) =
delete;
115 SourceLocationIndex &operator=(
const SourceLocationIndex &) =
delete;
131 unsigned column)
const;
141 unsigned beginColumn,
143 unsigned endColumn)
const;
155 std::map<FileID, IntervalTree> trees_;
Centralized file registry with path-to-FileID mapping.
std::size_t FileID
Type-safe identifier for registered files. 0 is reserved for invalid.
Represents node in AST tree hierarchy.
AstViewNode * queryFirstContained(unsigned beginLine, unsigned beginColumn, unsigned endLine, unsigned endColumn) const
Find first interval fully contained within a range.
void finalize()
Sort intervals by start position (call once after all inserts).
std::size_t size() const
Get total number of intervals.
std::vector< AstViewNode * > query(unsigned line, unsigned column) const
Find all intervals containing a point.
void insert(Interval interval)
Add interval to collection (not sorted yet).
void finalize()
Finalize all interval trees (call after all nodes added).
void addNode(AstViewNode *node)
Add node to index.
std::size_t getFileCount() const
Get number of files in index.
std::vector< AstViewNode * > getNodesAt(FileID fileId, unsigned line, unsigned column) const
Query nodes at specific source position.
bool hasFile(FileID fileId) const
Check whether the current TU AST contains any indexed nodes for a file.
std::size_t getTotalIntervals() const
Get total number of intervals across all files.
AstViewNode * getFirstNodeContainedInRange(FileID fileId, unsigned beginLine, unsigned beginColumn, unsigned endLine, unsigned endColumn) const
Query first node fully contained within a range.
Represents an interval in source code with associated AST node.
bool operator<(const Interval &other) const
Compare intervals by start position for sorting.
bool contains(unsigned line, unsigned column) const
Check if interval contains a point.