Skip to content

Commit 1603052

Browse files
bors[bot]matklad
andauthored
Merge #2440
2440: Rename Source -> InFile r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 2702fa1 + ccd1b08 commit 1603052

36 files changed

+189
-189
lines changed

crates/ra_assists/src/assist_ctx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This module defines `AssistCtx` -- the API surface that is exposed to assists.
2-
use hir::{db::HirDatabase, SourceAnalyzer};
2+
use hir::{db::HirDatabase, InFile, SourceAnalyzer};
33
use ra_db::FileRange;
44
use ra_fmt::{leading_indent, reindent};
55
use ra_syntax::{
@@ -117,7 +117,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
117117
node: &SyntaxNode,
118118
offset: Option<TextUnit>,
119119
) -> SourceAnalyzer {
120-
SourceAnalyzer::new(self.db, hir::Source::new(self.frange.file_id.into(), node), offset)
120+
SourceAnalyzer::new(self.db, InFile::new(self.frange.file_id.into(), node), offset)
121121
}
122122

123123
pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement {

crates/ra_assists/src/assists/add_new.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use format_buf::format;
2-
use hir::{db::HirDatabase, FromSource};
2+
use hir::{db::HirDatabase, FromSource, InFile};
33
use join_to_string::join;
44
use ra_syntax::{
55
ast::{
@@ -141,7 +141,7 @@ fn find_struct_impl(
141141
})?;
142142

143143
let struct_ty = {
144-
let src = hir::Source { file_id: ctx.frange.file_id.into(), value: strukt.clone() };
144+
let src = InFile { file_id: ctx.frange.file_id.into(), value: strukt.clone() };
145145
hir::Struct::from_source(db, src).unwrap().ty(db)
146146
};
147147

@@ -152,7 +152,7 @@ fn find_struct_impl(
152152
return false;
153153
}
154154

155-
let src = hir::Source { file_id: ctx.frange.file_id.into(), value: impl_blk.clone() };
155+
let src = InFile { file_id: ctx.frange.file_id.into(), value: impl_blk.clone() };
156156
let blk = hir::ImplBlock::from_source(db, src).unwrap();
157157

158158
let same_ty = blk.target_ty(db) == struct_ty;

crates/ra_hir/src/code_model.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
db::{DefDatabase, HirDatabase},
3131
ty::display::HirFormatter,
3232
ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk},
33-
CallableDef, Either, HirDisplay, Name, Source,
33+
CallableDef, Either, HirDisplay, InFile, Name,
3434
};
3535

3636
/// hir::Crate describes a single crate. It's the main interface with which
@@ -118,7 +118,7 @@ impl ModuleSource {
118118
}
119119
}
120120

121-
pub fn from_child_node(db: &impl DefDatabase, child: Source<&SyntaxNode>) -> ModuleSource {
121+
pub fn from_child_node(db: &impl DefDatabase, child: InFile<&SyntaxNode>) -> ModuleSource {
122122
if let Some(m) =
123123
child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
124124
{
@@ -901,7 +901,7 @@ impl Local {
901901
Type { krate, ty: InEnvironment { value: ty, environment } }
902902
}
903903

904-
pub fn source(self, db: &impl HirDatabase) -> Source<Either<ast::BindPat, ast::SelfParam>> {
904+
pub fn source(self, db: &impl HirDatabase) -> InFile<Either<ast::BindPat, ast::SelfParam>> {
905905
let (_body, source_map) = db.body_with_source_map(self.parent.into());
906906
let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm...
907907
let root = src.file_syntax(db);

crates/ra_hir/src/code_model/src.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use crate::{
99
Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
1010
};
1111

12-
pub use hir_expand::Source;
12+
pub use hir_expand::InFile;
1313

1414
pub trait HasSource {
1515
type Ast;
16-
fn source(self, db: &impl DefDatabase) -> Source<Self::Ast>;
16+
fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast>;
1717
}
1818

1919
/// NB: Module is !HasSource, because it has two source nodes at the same time:
2020
/// definition and declaration.
2121
impl Module {
2222
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
23-
pub fn definition_source(self, db: &impl DefDatabase) -> Source<ModuleSource> {
23+
pub fn definition_source(self, db: &impl DefDatabase) -> InFile<ModuleSource> {
2424
let def_map = db.crate_def_map(self.id.krate);
2525
let src = def_map[self.id.local_id].definition_source(db);
2626
src.map(|it| match it {
@@ -31,15 +31,15 @@ impl Module {
3131

3232
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
3333
/// `None` for the crate root.
34-
pub fn declaration_source(self, db: &impl DefDatabase) -> Option<Source<ast::Module>> {
34+
pub fn declaration_source(self, db: &impl DefDatabase) -> Option<InFile<ast::Module>> {
3535
let def_map = db.crate_def_map(self.id.krate);
3636
def_map[self.id.local_id].declaration_source(db)
3737
}
3838
}
3939

4040
impl HasSource for StructField {
4141
type Ast = FieldSource;
42-
fn source(self, db: &impl DefDatabase) -> Source<FieldSource> {
42+
fn source(self, db: &impl DefDatabase) -> InFile<FieldSource> {
4343
let var = VariantId::from(self.parent);
4444
let src = var.child_source(db);
4545
src.map(|it| match it[self.id].clone() {
@@ -50,75 +50,75 @@ impl HasSource for StructField {
5050
}
5151
impl HasSource for Struct {
5252
type Ast = ast::StructDef;
53-
fn source(self, db: &impl DefDatabase) -> Source<ast::StructDef> {
53+
fn source(self, db: &impl DefDatabase) -> InFile<ast::StructDef> {
5454
self.id.source(db)
5555
}
5656
}
5757
impl HasSource for Union {
5858
type Ast = ast::UnionDef;
59-
fn source(self, db: &impl DefDatabase) -> Source<ast::UnionDef> {
59+
fn source(self, db: &impl DefDatabase) -> InFile<ast::UnionDef> {
6060
self.id.source(db)
6161
}
6262
}
6363
impl HasSource for Enum {
6464
type Ast = ast::EnumDef;
65-
fn source(self, db: &impl DefDatabase) -> Source<ast::EnumDef> {
65+
fn source(self, db: &impl DefDatabase) -> InFile<ast::EnumDef> {
6666
self.id.source(db)
6767
}
6868
}
6969
impl HasSource for EnumVariant {
7070
type Ast = ast::EnumVariant;
71-
fn source(self, db: &impl DefDatabase) -> Source<ast::EnumVariant> {
71+
fn source(self, db: &impl DefDatabase) -> InFile<ast::EnumVariant> {
7272
self.parent.id.child_source(db).map(|map| map[self.id].clone())
7373
}
7474
}
7575
impl HasSource for Function {
7676
type Ast = ast::FnDef;
77-
fn source(self, db: &impl DefDatabase) -> Source<ast::FnDef> {
77+
fn source(self, db: &impl DefDatabase) -> InFile<ast::FnDef> {
7878
self.id.lookup(db).source(db)
7979
}
8080
}
8181
impl HasSource for Const {
8282
type Ast = ast::ConstDef;
83-
fn source(self, db: &impl DefDatabase) -> Source<ast::ConstDef> {
83+
fn source(self, db: &impl DefDatabase) -> InFile<ast::ConstDef> {
8484
self.id.lookup(db).source(db)
8585
}
8686
}
8787
impl HasSource for Static {
8888
type Ast = ast::StaticDef;
89-
fn source(self, db: &impl DefDatabase) -> Source<ast::StaticDef> {
89+
fn source(self, db: &impl DefDatabase) -> InFile<ast::StaticDef> {
9090
self.id.lookup(db).source(db)
9191
}
9292
}
9393
impl HasSource for Trait {
9494
type Ast = ast::TraitDef;
95-
fn source(self, db: &impl DefDatabase) -> Source<ast::TraitDef> {
95+
fn source(self, db: &impl DefDatabase) -> InFile<ast::TraitDef> {
9696
self.id.source(db)
9797
}
9898
}
9999
impl HasSource for TypeAlias {
100100
type Ast = ast::TypeAliasDef;
101-
fn source(self, db: &impl DefDatabase) -> Source<ast::TypeAliasDef> {
101+
fn source(self, db: &impl DefDatabase) -> InFile<ast::TypeAliasDef> {
102102
self.id.lookup(db).source(db)
103103
}
104104
}
105105
impl HasSource for MacroDef {
106106
type Ast = ast::MacroCall;
107-
fn source(self, db: &impl DefDatabase) -> Source<ast::MacroCall> {
108-
Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
107+
fn source(self, db: &impl DefDatabase) -> InFile<ast::MacroCall> {
108+
InFile { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
109109
}
110110
}
111111
impl HasSource for ImplBlock {
112112
type Ast = ast::ImplBlock;
113-
fn source(self, db: &impl DefDatabase) -> Source<ast::ImplBlock> {
113+
fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> {
114114
self.id.source(db)
115115
}
116116
}
117117
impl HasSource for Import {
118118
type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
119119

120120
/// Returns the syntax of the last path segment corresponding to this import
121-
fn source(self, db: &impl DefDatabase) -> Source<Self::Ast> {
121+
fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> {
122122
let src = self.parent.definition_source(db);
123123
let (_, source_map) = db.raw_items_with_source_map(src.file_id);
124124
let root = db.parse_or_expand(src.file_id).unwrap();

0 commit comments

Comments
 (0)