From ccd1b0800a5de5e046e6e9a4b6f49030c1ce3639 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 28 Nov 2019 12:50:26 +0300 Subject: Rename Source -> InFile --- crates/ra_hir_def/src/adt.rs | 6 +++--- crates/ra_hir_def/src/attr.rs | 6 +++--- crates/ra_hir_def/src/body.rs | 14 +++++++------- crates/ra_hir_def/src/body/scope.rs | 6 +++--- crates/ra_hir_def/src/diagnostics.rs | 6 +++--- crates/ra_hir_def/src/lib.rs | 26 +++++++++++++------------- crates/ra_hir_def/src/nameres.rs | 14 +++++++------- crates/ra_hir_def/src/nameres/raw.rs | 6 +++--- crates/ra_hir_def/src/path.rs | 4 ++-- 9 files changed, 44 insertions(+), 44 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 3666529b0..3d21dedee 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use hir_expand::{ either::Either, name::{AsName, Name}, - Source, + InFile, }; use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; @@ -88,7 +88,7 @@ impl EnumData { impl HasChildSource for EnumId { type ChildId = LocalEnumVariantId; type Value = ast::EnumVariant; - fn child_source(&self, db: &impl DefDatabase) -> Source> { + fn child_source(&self, db: &impl DefDatabase) -> InFile> { let src = self.source(db); let mut trace = Trace::new_for_map(); lower_enum(&mut trace, &src.value); @@ -145,7 +145,7 @@ impl HasChildSource for VariantId { type ChildId = LocalStructFieldId; type Value = Either; - fn child_source(&self, db: &impl DefDatabase) -> Source> { + fn child_source(&self, db: &impl DefDatabase) -> InFile> { let src = match self { VariantId::EnumVariantId(it) => { // I don't really like the fact that we call into parent source diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index fffb22201..83783ac7a 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -2,7 +2,7 @@ use std::{ops, sync::Arc}; -use hir_expand::{either::Either, hygiene::Hygiene, AstId, Source}; +use hir_expand::{either::Either, hygiene::Hygiene, AstId, InFile}; use mbe::ast_to_token_tree; use ra_syntax::{ ast::{self, AstNode, AttrsOwner}, @@ -68,7 +68,7 @@ impl Attrs { } } - fn from_attrs_owner(db: &impl DefDatabase, owner: Source<&dyn AttrsOwner>) -> Attrs { + fn from_attrs_owner(db: &impl DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs { let hygiene = Hygiene::new(db, owner.file_id); Attrs::new(owner.value, &hygiene) } @@ -157,7 +157,7 @@ where N: ast::AttrsOwner, D: DefDatabase, { - let src = Source::new(src.file_id(), src.to_node(db)); + let src = InFile::new(src.file_id(), src.to_node(db)); Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index a57a0176d..f21937f10 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -6,7 +6,7 @@ pub mod scope; use std::{ops::Index, sync::Arc}; use hir_expand::{ - either::Either, hygiene::Hygiene, AstId, HirFileId, MacroDefId, MacroFileKind, Source, + either::Either, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind, }; use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::{ast, AstNode, AstPtr}; @@ -73,8 +73,8 @@ impl Expander { std::mem::forget(mark); } - fn to_source(&self, value: T) -> Source { - Source { file_id: self.current_file_id, value } + fn to_source(&self, value: T) -> InFile { + InFile { file_id: self.current_file_id, value } } fn parse_path(&mut self, path: ast::Path) -> Option { @@ -115,10 +115,10 @@ pub struct Body { } pub type ExprPtr = Either, AstPtr>; -pub type ExprSource = Source; +pub type ExprSource = InFile; pub type PatPtr = Either, AstPtr>; -pub type PatSource = Source; +pub type PatSource = InFile; /// An item body together with the mapping from syntax nodes to HIR expression /// IDs. This is needed to go from e.g. a position in a file to the HIR @@ -205,7 +205,7 @@ impl BodySourceMap { self.expr_map_back.get(expr).copied() } - pub fn node_expr(&self, node: Source<&ast::Expr>) -> Option { + pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option { let src = node.map(|it| Either::A(AstPtr::new(it))); self.expr_map.get(&src).cloned() } @@ -214,7 +214,7 @@ impl BodySourceMap { self.pat_map_back.get(pat).copied() } - pub fn node_pat(&self, node: Source<&ast::Pat>) -> Option { + pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option { let src = node.map(|it| Either::A(AstPtr::new(it))); self.pat_map.get(&src).cloned() } diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 625aa39dd..ab6599b23 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -171,7 +171,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope #[cfg(test)] mod tests { - use hir_expand::{name::AsName, Source}; + use hir_expand::{name::AsName, InFile}; use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; use test_utils::{assert_eq_text, covers, extract_offset}; @@ -211,7 +211,7 @@ mod tests { let (_body, source_map) = db.body_with_source_map(function.into()); let expr_id = source_map - .node_expr(Source { file_id: file_id.into(), value: &marker.into() }) + .node_expr(InFile { file_id: file_id.into(), value: &marker.into() }) .unwrap(); let scope = scopes.scope_for(expr_id); @@ -318,7 +318,7 @@ mod tests { let expr_scope = { let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap(); let expr_id = - source_map.node_expr(Source { file_id: file_id.into(), value: &expr_ast }).unwrap(); + source_map.node_expr(InFile { file_id: file_id.into(), value: &expr_ast }).unwrap(); scopes.scope_for(expr_id).unwrap() }; diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index eda9b2269..095498429 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -6,7 +6,7 @@ use hir_expand::diagnostics::Diagnostic; use ra_db::RelativePathBuf; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; -use hir_expand::{HirFileId, Source}; +use hir_expand::{HirFileId, InFile}; #[derive(Debug)] pub struct UnresolvedModule { @@ -19,8 +19,8 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn source(&self) -> Source { - Source { file_id: self.file, value: self.decl.into() } + fn source(&self) -> InFile { + InFile { file_id: self.file, value: self.decl.into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index bc5530896..9d89692bf 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -36,7 +36,7 @@ mod marks; use std::hash::{Hash, Hasher}; -use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source}; +use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, InFile, MacroDefId}; use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; use ra_db::{impl_intern_key, salsa, CrateId}; use ra_syntax::{ast, AstNode}; @@ -105,10 +105,10 @@ pub trait AstItemDef: salsa::InternKey + Clone { let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) }; Self::intern(ctx.db, loc) } - fn source(self, db: &(impl AstDatabase + InternDatabase)) -> Source { + fn source(self, db: &(impl AstDatabase + InternDatabase)) -> InFile { let loc = self.lookup_intern(db); let value = loc.ast_id.to_node(db); - Source { file_id: loc.ast_id.file_id(), value } + InFile { file_id: loc.ast_id.file_id(), value } } fn module(self, db: &impl InternDatabase) -> ModuleId { let loc = self.lookup_intern(db); @@ -517,42 +517,42 @@ impl HasModule for StaticLoc { pub trait HasSource { type Value; - fn source(&self, db: &impl db::DefDatabase) -> Source; + fn source(&self, db: &impl db::DefDatabase) -> InFile; } impl HasSource for FunctionLoc { type Value = ast::FnDef; - fn source(&self, db: &impl db::DefDatabase) -> Source { + fn source(&self, db: &impl db::DefDatabase) -> InFile { let node = self.ast_id.to_node(db); - Source::new(self.ast_id.file_id(), node) + InFile::new(self.ast_id.file_id(), node) } } impl HasSource for TypeAliasLoc { type Value = ast::TypeAliasDef; - fn source(&self, db: &impl db::DefDatabase) -> Source { + fn source(&self, db: &impl db::DefDatabase) -> InFile { let node = self.ast_id.to_node(db); - Source::new(self.ast_id.file_id(), node) + InFile::new(self.ast_id.file_id(), node) } } impl HasSource for ConstLoc { type Value = ast::ConstDef; - fn source(&self, db: &impl db::DefDatabase) -> Source { + fn source(&self, db: &impl db::DefDatabase) -> InFile { let node = self.ast_id.to_node(db); - Source::new(self.ast_id.file_id(), node) + InFile::new(self.ast_id.file_id(), node) } } impl HasSource for StaticLoc { type Value = ast::StaticDef; - fn source(&self, db: &impl db::DefDatabase) -> Source { + fn source(&self, db: &impl db::DefDatabase) -> InFile { let node = self.ast_id.to_node(db); - Source::new(self.ast_id.file_id(), node) + InFile::new(self.ast_id.file_id(), node) } } @@ -562,5 +562,5 @@ pub trait HasChildSource { fn child_source( &self, db: &impl db::DefDatabase, - ) -> Source>; + ) -> InFile>; } diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 2359386c2..1b369ea11 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -58,8 +58,8 @@ mod tests; use std::sync::Arc; use hir_expand::{ - ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, MacroDefId, - Source, + ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, InFile, + MacroDefId, }; use once_cell::sync::Lazy; use ra_arena::Arena; @@ -261,21 +261,21 @@ impl ModuleData { pub fn definition_source( &self, db: &impl DefDatabase, - ) -> Source> { + ) -> InFile> { if let Some(file_id) = self.definition { let sf = db.parse(file_id).tree(); - return Source::new(file_id.into(), Either::A(sf)); + return InFile::new(file_id.into(), Either::A(sf)); } let decl = self.declaration.unwrap(); - Source::new(decl.file_id(), Either::B(decl.to_node(db))) + InFile::new(decl.file_id(), Either::B(decl.to_node(db))) } /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. /// `None` for the crate root. - pub fn declaration_source(&self, db: &impl DefDatabase) -> Option> { + pub fn declaration_source(&self, db: &impl DefDatabase) -> Option> { let decl = self.declaration?; let value = decl.to_node(db); - Some(Source { file_id: decl.file_id(), value }) + Some(InFile { file_id: decl.file_id(), value }) } } diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 6eb106094..5196b67ca 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -22,8 +22,8 @@ use ra_syntax::{ use test_utils::tested_by; use crate::{ - attr::Attrs, db::DefDatabase, path::Path, trace::Trace, FileAstId, HirFileId, LocalImportId, - Source, + attr::Attrs, db::DefDatabase, path::Path, trace::Trace, FileAstId, HirFileId, InFile, + LocalImportId, }; /// `RawItems` is a set of top-level items in a file (except for impls). @@ -313,7 +313,7 @@ impl RawItemsCollector { let mut buf = Vec::new(); Path::expand_use_item( - Source { value: use_item, file_id: self.file_id }, + InFile { value: use_item, file_id: self.file_id }, &self.hygiene, |path, use_tree, is_glob, alias| { let import_data = ImportData { diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 6810a26db..10688df4d 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -13,7 +13,7 @@ use ra_syntax::{ AstNode, }; -use crate::{type_ref::TypeRef, Source}; +use crate::{type_ref::TypeRef, InFile}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Path { @@ -67,7 +67,7 @@ pub enum PathKind { impl Path { /// Calls `cb` with all paths, represented by this use item. pub(crate) fn expand_use_item( - item_src: Source, + item_src: InFile, hygiene: &Hygiene, mut cb: impl FnMut(Path, &ast::UseTree, bool, Option), ) { -- cgit v1.2.3