From 7954d40969162d364eda52ef581223c90323b90d Mon Sep 17 00:00:00 2001 From: tirix <5831830+tirix@users.noreply.github.com> Date: Tue, 15 Feb 2022 12:37:52 +0800 Subject: [PATCH] Provide statement source name in API (#71) * Provide statement source name in API * Avoid cloning! * Inline, fmt. * Unneeded lifetime Co-authored-by: Mario Carneiro --- src/database.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/database.rs b/src/database.rs index 9a437a3..dd72b5a 100644 --- a/src/database.rs +++ b/src/database.rs @@ -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> + Clone + '_ {