Skip to content

Commit

Permalink
Provide statement source name in API (#71)
Browse files Browse the repository at this point in the history
* Provide statement source name in API

* Avoid cloning!

* Inline, fmt.

* Unneeded lifetime

Co-authored-by: Mario Carneiro <[email protected]>
  • Loading branch information
tirix and digama0 authored Feb 15, 2022
1 parent 360e7b1 commit 7954d40
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,13 @@ impl Database {
self.parse_result().statement(addr)
}

/// Get the name of the source file for a given statement.
#[inline]
#[must_use]
pub fn statement_source_name(&self, addr: StatementAddress) -> &str {
&self.parse_result().source_info(addr.segment_id).name
}

/// Iterates over all the statements
#[must_use]
pub fn statements(&self) -> impl DoubleEndedIterator<Item = StatementRef<'_>> + Clone + '_ {
Expand Down

0 comments on commit 7954d40

Please sign in to comment.