diff options
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/call_info.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/expand.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/expand_macro.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/hover.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/impls.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/parent_module.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/references.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/references/classify.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/runnables.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 6 |
16 files changed, 41 insertions, 41 deletions
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index d559dc4d0..b3c323d38 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs | |||
@@ -18,7 +18,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
18 | // Find the calling expression and it's NameRef | 18 | // Find the calling expression and it's NameRef |
19 | let calling_node = FnCallNode::with_node(&syntax, position.offset)?; | 19 | let calling_node = FnCallNode::with_node(&syntax, position.offset)?; |
20 | let name_ref = calling_node.name_ref()?; | 20 | let name_ref = calling_node.name_ref()?; |
21 | let name_ref = hir::Source::new(position.file_id.into(), name_ref.syntax()); | 21 | let name_ref = hir::InFile::new(position.file_id.into(), name_ref.syntax()); |
22 | 22 | ||
23 | let analyzer = hir::SourceAnalyzer::new(db, name_ref, None); | 23 | let analyzer = hir::SourceAnalyzer::new(db, name_ref, None); |
24 | let (mut call_info, has_self) = match &calling_node { | 24 | let (mut call_info, has_self) = match &calling_node { |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index b8345c91d..ca0a483d4 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -54,13 +54,13 @@ impl<'a> CompletionContext<'a> { | |||
54 | let src = hir::ModuleSource::from_position(db, position); | 54 | let src = hir::ModuleSource::from_position(db, position); |
55 | let module = hir::Module::from_definition( | 55 | let module = hir::Module::from_definition( |
56 | db, | 56 | db, |
57 | hir::Source { file_id: position.file_id.into(), value: src }, | 57 | hir::InFile { file_id: position.file_id.into(), value: src }, |
58 | ); | 58 | ); |
59 | let token = | 59 | let token = |
60 | original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; | 60 | original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; |
61 | let analyzer = hir::SourceAnalyzer::new( | 61 | let analyzer = hir::SourceAnalyzer::new( |
62 | db, | 62 | db, |
63 | hir::Source::new(position.file_id.into(), &token.parent()), | 63 | hir::InFile::new(position.file_id.into(), &token.parent()), |
64 | Some(position.offset), | 64 | Some(position.offset), |
65 | ); | 65 | ); |
66 | let mut ctx = CompletionContext { | 66 | let mut ctx = CompletionContext { |
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index cc1ccab4b..c50a70d99 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -96,7 +96,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
96 | }); | 96 | }); |
97 | let source_file = db.parse(file_id).tree(); | 97 | let source_file = db.parse(file_id).tree(); |
98 | let src = | 98 | let src = |
99 | hir::Source { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) }; | 99 | hir::InFile { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) }; |
100 | if let Some(m) = hir::Module::from_definition(db, src) { | 100 | if let Some(m) = hir::Module::from_definition(db, src) { |
101 | m.diagnostics(db, &mut sink); | 101 | m.diagnostics(db, &mut sink); |
102 | }; | 102 | }; |
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 6ac60722b..61dca14ac 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir::{AssocItem, Either, FieldSource, HasSource, ModuleSource, Source}; | 3 | use hir::{AssocItem, Either, FieldSource, HasSource, InFile, ModuleSource}; |
4 | use ra_db::{FileId, SourceDatabase}; | 4 | use ra_db::{FileId, SourceDatabase}; |
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | ast::{self, DocCommentsOwner, NameOwner}, | 6 | ast::{self, DocCommentsOwner, NameOwner}, |
@@ -141,7 +141,7 @@ impl NavigationTarget { | |||
141 | /// Allows `NavigationTarget` to be created from a `NameOwner` | 141 | /// Allows `NavigationTarget` to be created from a `NameOwner` |
142 | pub(crate) fn from_named( | 142 | pub(crate) fn from_named( |
143 | db: &RootDatabase, | 143 | db: &RootDatabase, |
144 | node: Source<&dyn ast::NameOwner>, | 144 | node: InFile<&dyn ast::NameOwner>, |
145 | docs: Option<String>, | 145 | docs: Option<String>, |
146 | description: Option<String>, | 146 | description: Option<String>, |
147 | ) -> NavigationTarget { | 147 | ) -> NavigationTarget { |
diff --git a/crates/ra_ide/src/expand.rs b/crates/ra_ide/src/expand.rs index 2f1abf509..216d5cfec 100644 --- a/crates/ra_ide/src/expand.rs +++ b/crates/ra_ide/src/expand.rs | |||
@@ -1,13 +1,13 @@ | |||
1 | //! Utilities to work with files, produced by macros. | 1 | //! Utilities to work with files, produced by macros. |
2 | use std::iter::successors; | 2 | use std::iter::successors; |
3 | 3 | ||
4 | use hir::Source; | 4 | use hir::InFile; |
5 | use ra_db::FileId; | 5 | use ra_db::FileId; |
6 | use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken}; | 6 | use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken}; |
7 | 7 | ||
8 | use crate::{db::RootDatabase, FileRange}; | 8 | use crate::{db::RootDatabase, FileRange}; |
9 | 9 | ||
10 | pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> FileRange { | 10 | pub(crate) fn original_range(db: &RootDatabase, node: InFile<&SyntaxNode>) -> FileRange { |
11 | let expansion = match node.file_id.expansion_info(db) { | 11 | let expansion = match node.file_id.expansion_info(db) { |
12 | None => { | 12 | None => { |
13 | return FileRange { | 13 | return FileRange { |
@@ -44,8 +44,8 @@ pub(crate) fn descend_into_macros( | |||
44 | db: &RootDatabase, | 44 | db: &RootDatabase, |
45 | file_id: FileId, | 45 | file_id: FileId, |
46 | token: SyntaxToken, | 46 | token: SyntaxToken, |
47 | ) -> Source<SyntaxToken> { | 47 | ) -> InFile<SyntaxToken> { |
48 | let src = Source::new(file_id.into(), token); | 48 | let src = InFile::new(file_id.into(), token); |
49 | 49 | ||
50 | successors(Some(src), |token| { | 50 | successors(Some(src), |token| { |
51 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; | 51 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; |
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index abc602244..862c03304 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs | |||
@@ -22,7 +22,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option< | |||
22 | let name_ref = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)?; | 22 | let name_ref = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)?; |
23 | let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?; | 23 | let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?; |
24 | 24 | ||
25 | let source = hir::Source::new(position.file_id.into(), mac.syntax()); | 25 | let source = hir::InFile::new(position.file_id.into(), mac.syntax()); |
26 | let expanded = expand_macro_recur(db, source, source.with_value(&mac))?; | 26 | let expanded = expand_macro_recur(db, source, source.with_value(&mac))?; |
27 | 27 | ||
28 | // FIXME: | 28 | // FIXME: |
@@ -34,8 +34,8 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option< | |||
34 | 34 | ||
35 | fn expand_macro_recur( | 35 | fn expand_macro_recur( |
36 | db: &RootDatabase, | 36 | db: &RootDatabase, |
37 | source: hir::Source<&SyntaxNode>, | 37 | source: hir::InFile<&SyntaxNode>, |
38 | macro_call: hir::Source<&ast::MacroCall>, | 38 | macro_call: hir::InFile<&ast::MacroCall>, |
39 | ) -> Option<SyntaxNode> { | 39 | ) -> Option<SyntaxNode> { |
40 | let analyzer = hir::SourceAnalyzer::new(db, source, None); | 40 | let analyzer = hir::SourceAnalyzer::new(db, source, None); |
41 | let expansion = analyzer.expand(db, macro_call)?; | 41 | let expansion = analyzer.expand(db, macro_call)?; |
@@ -46,7 +46,7 @@ fn expand_macro_recur( | |||
46 | let mut replaces = FxHashMap::default(); | 46 | let mut replaces = FxHashMap::default(); |
47 | 47 | ||
48 | for child in children.into_iter() { | 48 | for child in children.into_iter() { |
49 | let node = hir::Source::new(macro_file_id, &child); | 49 | let node = hir::InFile::new(macro_file_id, &child); |
50 | if let Some(new_node) = expand_macro_recur(db, source, node) { | 50 | if let Some(new_node) = expand_macro_recur(db, source, node) { |
51 | // Replace the whole node if it is root | 51 | // Replace the whole node if it is root |
52 | // `replace_descendants` will not replace the parent node | 52 | // `replace_descendants` will not replace the parent node |
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index c10a6c844..76a741207 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir::{db::AstDatabase, Source}; | 3 | use hir::{db::AstDatabase, InFile}; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | ast::{self, DocCommentsOwner}, | 5 | ast::{self, DocCommentsOwner}, |
6 | match_ast, AstNode, SyntaxNode, | 6 | match_ast, AstNode, SyntaxNode, |
@@ -58,7 +58,7 @@ impl ReferenceResult { | |||
58 | 58 | ||
59 | pub(crate) fn reference_definition( | 59 | pub(crate) fn reference_definition( |
60 | db: &RootDatabase, | 60 | db: &RootDatabase, |
61 | name_ref: Source<&ast::NameRef>, | 61 | name_ref: InFile<&ast::NameRef>, |
62 | ) -> ReferenceResult { | 62 | ) -> ReferenceResult { |
63 | use self::ReferenceResult::*; | 63 | use self::ReferenceResult::*; |
64 | 64 | ||
@@ -94,7 +94,7 @@ pub(crate) fn reference_definition( | |||
94 | 94 | ||
95 | pub(crate) fn name_definition( | 95 | pub(crate) fn name_definition( |
96 | db: &RootDatabase, | 96 | db: &RootDatabase, |
97 | name: Source<&ast::Name>, | 97 | name: InFile<&ast::Name>, |
98 | ) -> Option<Vec<NavigationTarget>> { | 98 | ) -> Option<Vec<NavigationTarget>> { |
99 | let parent = name.value.syntax().parent()?; | 99 | let parent = name.value.syntax().parent()?; |
100 | 100 | ||
@@ -115,7 +115,7 @@ pub(crate) fn name_definition( | |||
115 | None | 115 | None |
116 | } | 116 | } |
117 | 117 | ||
118 | fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<NavigationTarget> { | 118 | fn named_target(db: &RootDatabase, node: InFile<&SyntaxNode>) -> Option<NavigationTarget> { |
119 | match_ast! { | 119 | match_ast! { |
120 | match (node.value) { | 120 | match (node.value) { |
121 | ast::StructDef(it) => { | 121 | ast::StructDef(it) => { |
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 260a7b869..d8185c688 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -227,7 +227,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { | |||
227 | .take_while(|it| it.text_range() == leaf_node.text_range()) | 227 | .take_while(|it| it.text_range() == leaf_node.text_range()) |
228 | .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; | 228 | .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; |
229 | let analyzer = | 229 | let analyzer = |
230 | hir::SourceAnalyzer::new(db, hir::Source::new(frange.file_id.into(), &node), None); | 230 | hir::SourceAnalyzer::new(db, hir::InFile::new(frange.file_id.into(), &node), None); |
231 | let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) | 231 | let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) |
232 | { | 232 | { |
233 | ty | 233 | ty |
diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs index aa480e399..9b165ee2a 100644 --- a/crates/ra_ide/src/impls.rs +++ b/crates/ra_ide/src/impls.rs | |||
@@ -16,7 +16,7 @@ pub(crate) fn goto_implementation( | |||
16 | let src = hir::ModuleSource::from_position(db, position); | 16 | let src = hir::ModuleSource::from_position(db, position); |
17 | let module = hir::Module::from_definition( | 17 | let module = hir::Module::from_definition( |
18 | db, | 18 | db, |
19 | hir::Source { file_id: position.file_id.into(), value: src }, | 19 | hir::InFile { file_id: position.file_id.into(), value: src }, |
20 | )?; | 20 | )?; |
21 | 21 | ||
22 | if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) { | 22 | if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) { |
@@ -42,15 +42,15 @@ fn impls_for_def( | |||
42 | ) -> Option<Vec<NavigationTarget>> { | 42 | ) -> Option<Vec<NavigationTarget>> { |
43 | let ty = match node { | 43 | let ty = match node { |
44 | ast::NominalDef::StructDef(def) => { | 44 | ast::NominalDef::StructDef(def) => { |
45 | let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; | 45 | let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() }; |
46 | hir::Struct::from_source(db, src)?.ty(db) | 46 | hir::Struct::from_source(db, src)?.ty(db) |
47 | } | 47 | } |
48 | ast::NominalDef::EnumDef(def) => { | 48 | ast::NominalDef::EnumDef(def) => { |
49 | let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; | 49 | let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() }; |
50 | hir::Enum::from_source(db, src)?.ty(db) | 50 | hir::Enum::from_source(db, src)?.ty(db) |
51 | } | 51 | } |
52 | ast::NominalDef::UnionDef(def) => { | 52 | ast::NominalDef::UnionDef(def) => { |
53 | let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; | 53 | let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() }; |
54 | hir::Union::from_source(db, src)?.ty(db) | 54 | hir::Union::from_source(db, src)?.ty(db) |
55 | } | 55 | } |
56 | }; | 56 | }; |
@@ -73,7 +73,7 @@ fn impls_for_trait( | |||
73 | node: &ast::TraitDef, | 73 | node: &ast::TraitDef, |
74 | module: hir::Module, | 74 | module: hir::Module, |
75 | ) -> Option<Vec<NavigationTarget>> { | 75 | ) -> Option<Vec<NavigationTarget>> { |
76 | let src = hir::Source { file_id: position.file_id.into(), value: node.clone() }; | 76 | let src = hir::InFile { file_id: position.file_id.into(), value: node.clone() }; |
77 | let tr = hir::Trait::from_source(db, src)?; | 77 | let tr = hir::Trait::from_source(db, src)?; |
78 | 78 | ||
79 | let krate = module.krate(); | 79 | let krate = module.krate(); |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 45149bf0c..59eced9d7 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -38,7 +38,7 @@ fn get_inlay_hints( | |||
38 | node: &SyntaxNode, | 38 | node: &SyntaxNode, |
39 | max_inlay_hint_length: Option<usize>, | 39 | max_inlay_hint_length: Option<usize>, |
40 | ) -> Option<Vec<InlayHint>> { | 40 | ) -> Option<Vec<InlayHint>> { |
41 | let analyzer = SourceAnalyzer::new(db, hir::Source::new(file_id.into(), node), None); | 41 | let analyzer = SourceAnalyzer::new(db, hir::InFile::new(file_id.into(), node), None); |
42 | match_ast! { | 42 | match_ast! { |
43 | match node { | 43 | match node { |
44 | ast::LetStmt(it) => { | 44 | ast::LetStmt(it) => { |
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 6027e7d54..616d69fce 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs | |||
@@ -10,7 +10,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na | |||
10 | let src = hir::ModuleSource::from_position(db, position); | 10 | let src = hir::ModuleSource::from_position(db, position); |
11 | let module = match hir::Module::from_definition( | 11 | let module = match hir::Module::from_definition( |
12 | db, | 12 | db, |
13 | hir::Source { file_id: position.file_id.into(), value: src }, | 13 | hir::InFile { file_id: position.file_id.into(), value: src }, |
14 | ) { | 14 | ) { |
15 | None => return Vec::new(), | 15 | None => return Vec::new(), |
16 | Some(it) => it, | 16 | Some(it) => it, |
@@ -23,7 +23,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na | |||
23 | pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | 23 | pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { |
24 | let src = hir::ModuleSource::from_file_id(db, file_id); | 24 | let src = hir::ModuleSource::from_file_id(db, file_id); |
25 | let module = | 25 | let module = |
26 | match hir::Module::from_definition(db, hir::Source { file_id: file_id.into(), value: src }) | 26 | match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src }) |
27 | { | 27 | { |
28 | Some(it) => it, | 28 | Some(it) => it, |
29 | None => return Vec::new(), | 29 | None => return Vec::new(), |
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 21a1ea69e..3e7bfd872 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -14,7 +14,7 @@ mod name_definition; | |||
14 | mod rename; | 14 | mod rename; |
15 | mod search_scope; | 15 | mod search_scope; |
16 | 16 | ||
17 | use hir::Source; | 17 | use hir::InFile; |
18 | use once_cell::unsync::Lazy; | 18 | use once_cell::unsync::Lazy; |
19 | use ra_db::{SourceDatabase, SourceDatabaseExt}; | 19 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
20 | use ra_prof::profile; | 20 | use ra_prof::profile; |
@@ -107,12 +107,12 @@ fn find_name<'a>( | |||
107 | position: FilePosition, | 107 | position: FilePosition, |
108 | ) -> Option<RangeInfo<(String, NameDefinition)>> { | 108 | ) -> Option<RangeInfo<(String, NameDefinition)>> { |
109 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { | 109 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { |
110 | let def = classify_name(db, Source::new(position.file_id.into(), &name))?; | 110 | let def = classify_name(db, InFile::new(position.file_id.into(), &name))?; |
111 | let range = name.syntax().text_range(); | 111 | let range = name.syntax().text_range(); |
112 | return Some(RangeInfo::new(range, (name.text().to_string(), def))); | 112 | return Some(RangeInfo::new(range, (name.text().to_string(), def))); |
113 | } | 113 | } |
114 | let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?; | 114 | let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?; |
115 | let def = classify_name_ref(db, Source::new(position.file_id.into(), &name_ref))?; | 115 | let def = classify_name_ref(db, InFile::new(position.file_id.into(), &name_ref))?; |
116 | let range = name_ref.syntax().text_range(); | 116 | let range = name_ref.syntax().text_range(); |
117 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) | 117 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) |
118 | } | 118 | } |
@@ -144,7 +144,7 @@ fn process_definition( | |||
144 | continue; | 144 | continue; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | if let Some(d) = classify_name_ref(db, Source::new(file_id.into(), &name_ref)) { | 147 | if let Some(d) = classify_name_ref(db, InFile::new(file_id.into(), &name_ref)) { |
148 | if d == def { | 148 | if d == def { |
149 | refs.push(FileRange { file_id, range }); | 149 | refs.push(FileRange { file_id, range }); |
150 | } | 150 | } |
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index 5cea805ec..b716d32e5 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Functions that are used to classify an element from its definition or reference. | 1 | //! Functions that are used to classify an element from its definition or reference. |
2 | 2 | ||
3 | use hir::{FromSource, Module, ModuleSource, PathResolution, Source, SourceAnalyzer}; | 3 | use hir::{FromSource, InFile, Module, ModuleSource, PathResolution, SourceAnalyzer}; |
4 | use ra_prof::profile; | 4 | use ra_prof::profile; |
5 | use ra_syntax::{ast, match_ast, AstNode}; | 5 | use ra_syntax::{ast, match_ast, AstNode}; |
6 | use test_utils::tested_by; | 6 | use test_utils::tested_by; |
@@ -11,7 +11,7 @@ use super::{ | |||
11 | }; | 11 | }; |
12 | use crate::db::RootDatabase; | 12 | use crate::db::RootDatabase; |
13 | 13 | ||
14 | pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Option<NameDefinition> { | 14 | pub(crate) fn classify_name(db: &RootDatabase, name: InFile<&ast::Name>) -> Option<NameDefinition> { |
15 | let _p = profile("classify_name"); | 15 | let _p = profile("classify_name"); |
16 | let parent = name.value.syntax().parent()?; | 16 | let parent = name.value.syntax().parent()?; |
17 | 17 | ||
@@ -117,7 +117,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti | |||
117 | 117 | ||
118 | pub(crate) fn classify_name_ref( | 118 | pub(crate) fn classify_name_ref( |
119 | db: &RootDatabase, | 119 | db: &RootDatabase, |
120 | name_ref: Source<&ast::NameRef>, | 120 | name_ref: InFile<&ast::NameRef>, |
121 | ) -> Option<NameDefinition> { | 121 | ) -> Option<NameDefinition> { |
122 | let _p = profile("classify_name_ref"); | 122 | let _p = profile("classify_name_ref"); |
123 | 123 | ||
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index d58496049..ea6b354c2 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -55,7 +55,7 @@ fn rename_mod( | |||
55 | ) -> Option<SourceChange> { | 55 | ) -> Option<SourceChange> { |
56 | let mut source_file_edits = Vec::new(); | 56 | let mut source_file_edits = Vec::new(); |
57 | let mut file_system_edits = Vec::new(); | 57 | let mut file_system_edits = Vec::new(); |
58 | let module_src = hir::Source { file_id: position.file_id.into(), value: ast_module.clone() }; | 58 | let module_src = hir::InFile { file_id: position.file_id.into(), value: ast_module.clone() }; |
59 | if let Some(module) = hir::Module::from_declaration(db, module_src) { | 59 | if let Some(module) = hir::Module::from_declaration(db, module_src) { |
60 | let src = module.definition_source(db); | 60 | let src = module.definition_source(db); |
61 | let file_id = src.file_id.original_file(db); | 61 | let file_id = src.file_id.original_file(db); |
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 8039a5164..e213e1a06 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir::Source; | 3 | use hir::InFile; |
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | use ra_db::SourceDatabase; | 5 | use ra_db::SourceDatabase; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
@@ -66,8 +66,8 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti | |||
66 | return None; | 66 | return None; |
67 | } | 67 | } |
68 | let range = module.syntax().text_range(); | 68 | let range = module.syntax().text_range(); |
69 | let src = hir::ModuleSource::from_child_node(db, Source::new(file_id.into(), &module.syntax())); | 69 | let src = hir::ModuleSource::from_child_node(db, InFile::new(file_id.into(), &module.syntax())); |
70 | let module = hir::Module::from_definition(db, Source::new(file_id.into(), src))?; | 70 | let module = hir::Module::from_definition(db, InFile::new(file_id.into(), src))?; |
71 | 71 | ||
72 | let path = module.path_to_root(db).into_iter().rev().filter_map(|it| it.name(db)).join("::"); | 72 | let path = module.path_to_root(db).into_iter().rev().filter_map(|it| it.name(db)).join("::"); |
73 | Some(Runnable { range, kind: RunnableKind::TestMod { path } }) | 73 | Some(Runnable { range, kind: RunnableKind::TestMod { path } }) |
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 9a3e4c82f..e6a79541f 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use rustc_hash::{FxHashMap, FxHashSet}; | 3 | use rustc_hash::{FxHashMap, FxHashSet}; |
4 | 4 | ||
5 | use hir::{Name, Source}; | 5 | use hir::{InFile, Name}; |
6 | use ra_db::SourceDatabase; | 6 | use ra_db::SourceDatabase; |
7 | use ra_prof::profile; | 7 | use ra_prof::profile; |
8 | use ra_syntax::{ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T}; | 8 | use ra_syntax::{ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T}; |
@@ -81,7 +81,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
81 | 81 | ||
82 | let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap(); | 82 | let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap(); |
83 | let name_kind = | 83 | let name_kind = |
84 | classify_name_ref(db, Source::new(file_id.into(), &name_ref)).map(|d| d.kind); | 84 | classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind); |
85 | 85 | ||
86 | if let Some(Local(local)) = &name_kind { | 86 | if let Some(Local(local)) = &name_kind { |
87 | if let Some(name) = local.name(db) { | 87 | if let Some(name) = local.name(db) { |
@@ -95,7 +95,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
95 | NAME => { | 95 | NAME => { |
96 | let name = node.as_node().cloned().and_then(ast::Name::cast).unwrap(); | 96 | let name = node.as_node().cloned().and_then(ast::Name::cast).unwrap(); |
97 | let name_kind = | 97 | let name_kind = |
98 | classify_name(db, Source::new(file_id.into(), &name)).map(|d| d.kind); | 98 | classify_name(db, InFile::new(file_id.into(), &name)).map(|d| d.kind); |
99 | 99 | ||
100 | if let Some(Local(local)) = &name_kind { | 100 | if let Some(Local(local)) = &name_kind { |
101 | if let Some(name) = local.name(db) { | 101 | if let Some(name) = local.name(db) { |