Skip to content

Commit

Permalink
Add Body::range_for_any() function
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: robertoaloi

Differential Revision: D55746858

fbshipit-source-id: e980d335919e757ebce6a72c3d60153b71cb359c
  • Loading branch information
alanz authored and facebook-github-bot committed Apr 5, 2024
1 parent bb97a02 commit 261ca49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/hir/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ impl Body {
}
}

pub fn range_for_any(&self, sema: &Semantic, id: AnyExprId) -> Option<TextRange> {
let body_map = self.get_body_map(sema)?;
let ast = body_map.any(id)?;
Some(ast.range())
}

pub fn print_any_expr(&self, db: &dyn InternDatabase, expr: AnyExprId) -> String {
match expr {
AnyExprId::Expr(expr_id) => pretty::print_expr(db, self, expr_id),
Expand Down

0 comments on commit 261ca49

Please sign in to comment.