From eaf1df26e9903772d40df30dd70c75c38d8cb887 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 2 Mar 2019 15:14:37 +0300 Subject: rename syntax-mapping -> source-map --- crates/ra_hir/src/code_model_api.rs | 8 ++++---- crates/ra_hir/src/db.rs | 4 ++-- crates/ra_hir/src/expr.rs | 22 +++++++++++----------- crates/ra_hir/src/expr/scope.rs | 4 ++-- crates/ra_hir/src/ty/tests.rs | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index da0f1ec94..f8521e895 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -9,7 +9,7 @@ use crate::{ HirDatabase, PersistentHirDatabase, type_ref::TypeRef, nameres::{ModuleScope, Namespace, lower::ImportId}, - expr::{Body, BodySyntaxMapping}, + expr::{Body, BodySourceMap}, ty::InferenceResult, adt::{EnumVariantId, StructFieldId, VariantDef}, generics::GenericParams, @@ -483,8 +483,8 @@ impl Function { self.signature(db).name.clone() } - pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Arc { - db.body_syntax_mapping(*self) + pub fn body_source_map(&self, db: &impl HirDatabase) -> Arc { + db.body_source_map(*self) } pub fn body(&self, db: &impl HirDatabase) -> Arc { @@ -497,7 +497,7 @@ impl Function { pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping { let scopes = db.expr_scopes(*self); - let syntax_mapping = db.body_syntax_mapping(*self); + let syntax_mapping = db.body_source_map(*self); ScopesWithSyntaxMapping { scopes, syntax_mapping } } diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ec848f1b2..cb1c24561 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -108,8 +108,8 @@ pub trait HirDatabase: PersistentHirDatabase { #[salsa::invoke(crate::expr::body_hir)] fn body_hir(&self, func: Function) -> Arc; - #[salsa::invoke(crate::expr::body_syntax_mapping)] - fn body_syntax_mapping(&self, func: Function) -> Arc; + #[salsa::invoke(crate::expr::body_source_map)] + fn body_source_map(&self, func: Function) -> Arc; #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] fn impls_in_crate(&self, krate: Crate) -> Arc; diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index aa39d28ed..b1398411b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -49,7 +49,7 @@ pub struct Body { /// a structure that is agnostic to the actual positions of expressions in the /// file, so that we don't recompute types whenever some whitespace is typed. #[derive(Debug, Eq, PartialEq)] -pub struct BodySyntaxMapping { +pub struct BodySourceMap { body: Arc, expr_syntax_mapping: FxHashMap, expr_syntax_mapping_back: ArenaMap, @@ -78,8 +78,8 @@ impl Body { self.pats.iter() } - pub fn syntax_mapping(&self, db: &impl HirDatabase) -> Arc { - db.body_syntax_mapping(self.owner) + pub fn syntax_mapping(&self, db: &impl HirDatabase) -> Arc { + db.body_source_map(self.owner) } } @@ -119,7 +119,7 @@ impl Index for Body { } } -impl BodySyntaxMapping { +impl BodySourceMap { pub fn expr_syntax(&self, expr: ExprId) -> Option { self.expr_syntax_mapping_back.get(expr).cloned() } @@ -468,7 +468,7 @@ impl Pat { // Queries pub(crate) fn body_hir(db: &impl HirDatabase, func: Function) -> Arc { - Arc::clone(&body_syntax_mapping(db, func).body) + Arc::clone(&body_source_map(db, func).body) } struct ExprCollector { @@ -910,7 +910,7 @@ impl ExprCollector { self.body_expr = Some(body); } - fn into_body_syntax_mapping(self) -> BodySyntaxMapping { + fn into_body_source_map(self) -> BodySourceMap { let body = Body { owner: self.owner, exprs: self.exprs, @@ -918,7 +918,7 @@ impl ExprCollector { params: self.params, body_expr: self.body_expr.expect("A body should have been collected"), }; - BodySyntaxMapping { + BodySourceMap { body: Arc::new(body), expr_syntax_mapping: self.expr_syntax_mapping, expr_syntax_mapping_back: self.expr_syntax_mapping_back, @@ -928,18 +928,18 @@ impl ExprCollector { } } -pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, func: Function) -> Arc { +pub(crate) fn body_source_map(db: &impl HirDatabase, func: Function) -> Arc { let mut collector = ExprCollector::new(func); // TODO: consts, etc. collector.collect_fn_body(&func.source(db).1); - Arc::new(collector.into_body_syntax_mapping()) + Arc::new(collector.into_body_source_map()) } #[cfg(test)] -pub(crate) fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> BodySyntaxMapping { +pub(crate) fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> BodySourceMap { let mut collector = ExprCollector::new(function); collector.collect_fn_body(node); - collector.into_body_syntax_mapping() + collector.into_body_source_map() } diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index bb8d50db8..bb919dcfa 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -11,7 +11,7 @@ use ra_arena::{Arena, RawId, impl_arena_id}; use crate::{ Name, AsName, Function, - expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}, + expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySourceMap}, HirDatabase, }; @@ -109,7 +109,7 @@ impl ExprScopes { #[derive(Debug, Clone, PartialEq, Eq)] pub struct ScopesWithSyntaxMapping { - pub syntax_mapping: Arc, + pub syntax_mapping: Arc, pub scopes: Arc, } diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 8de46a29e..2fdfb54f4 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -1045,11 +1045,11 @@ fn test() { fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { let func = source_binder::function_from_position(db, pos).unwrap(); - let body_syntax_mapping = func.body_syntax_mapping(db); + let body_source_map = func.body_source_map(db); let inference_result = func.infer(db); let (_, syntax) = func.source(db); let node = algo::find_node_at_offset::(syntax.syntax(), pos.offset).unwrap(); - let expr = body_syntax_mapping.node_expr(node).unwrap(); + let expr = body_source_map.node_expr(node).unwrap(); let ty = &inference_result[expr]; ty.to_string() } @@ -1061,17 +1061,17 @@ fn infer(content: &str) -> String { for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); let inference_result = func.infer(&db); - let body_syntax_mapping = func.body_syntax_mapping(&db); + let body_source_map = func.body_source_map(&db); let mut types = Vec::new(); for (pat, ty) in inference_result.type_of_pat.iter() { - let syntax_ptr = match body_syntax_mapping.pat_syntax(pat) { + let syntax_ptr = match body_source_map.pat_syntax(pat) { Some(sp) => sp, None => continue, }; types.push((syntax_ptr, ty)); } for (expr, ty) in inference_result.type_of_expr.iter() { - let syntax_ptr = match body_syntax_mapping.expr_syntax(expr) { + let syntax_ptr = match body_source_map.expr_syntax(expr) { Some(sp) => sp, None => continue, }; -- cgit v1.2.3