diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 11 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index 0435188c8..65f061443 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -12,6 +12,7 @@ use ra_syntax::{ | |||
12 | Location, SyntaxNode, TextRange, T, | 12 | Location, SyntaxNode, TextRange, T, |
13 | }; | 13 | }; |
14 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 14 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
15 | use relative_path::RelativePath; | ||
15 | 16 | ||
16 | use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; | 17 | use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; |
17 | 18 | ||
@@ -47,8 +48,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
47 | }) | 48 | }) |
48 | }) | 49 | }) |
49 | .on::<hir::diagnostics::UnresolvedModule, _>(|d| { | 50 | .on::<hir::diagnostics::UnresolvedModule, _>(|d| { |
50 | let source_root = db.file_source_root(d.source().file_id.original_file(db)); | 51 | let original_file = d.source().file_id.original_file(db); |
51 | let create_file = FileSystemEdit::CreateFile { source_root, path: d.candidate.clone() }; | 52 | let source_root = db.file_source_root(original_file); |
53 | let path = db | ||
54 | .file_relative_path(original_file) | ||
55 | .parent() | ||
56 | .unwrap_or_else(|| RelativePath::new("")) | ||
57 | .join(&d.candidate); | ||
58 | let create_file = FileSystemEdit::CreateFile { source_root, path }; | ||
52 | let fix = SourceChange::file_system_edit("create module", create_file); | 59 | let fix = SourceChange::file_system_edit("create module", create_file); |
53 | res.borrow_mut().push(Diagnostic { | 60 | res.borrow_mut().push(Diagnostic { |
54 | range: d.highlight_range(), | 61 | range: d.highlight_range(), |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index d0b1a8a2a..5cb67fb95 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -119,7 +119,7 @@ impl NavigationTarget { | |||
119 | 119 | ||
120 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 120 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
121 | let src = module.definition_source(db); | 121 | let src = module.definition_source(db); |
122 | let file_id = src.file_id.as_original_file(); | 122 | let file_id = src.file_id.original_file(db); |
123 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 123 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
124 | match src.ast { | 124 | match src.ast { |
125 | ModuleSource::SourceFile(node) => { | 125 | ModuleSource::SourceFile(node) => { |
@@ -139,7 +139,7 @@ impl NavigationTarget { | |||
139 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 139 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
140 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 140 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
141 | if let Some(src) = module.declaration_source(db) { | 141 | if let Some(src) = module.declaration_source(db) { |
142 | let file_id = src.file_id.as_original_file(); | 142 | let file_id = src.file_id.original_file(db); |
143 | return NavigationTarget::from_syntax( | 143 | return NavigationTarget::from_syntax( |
144 | file_id, | 144 | file_id, |
145 | name, | 145 | name, |
@@ -213,7 +213,7 @@ impl NavigationTarget { | |||
213 | ) -> NavigationTarget { | 213 | ) -> NavigationTarget { |
214 | let src = impl_block.source(db); | 214 | let src = impl_block.source(db); |
215 | NavigationTarget::from_syntax( | 215 | NavigationTarget::from_syntax( |
216 | src.file_id.as_original_file(), | 216 | src.file_id.original_file(db), |
217 | "impl".into(), | 217 | "impl".into(), |
218 | None, | 218 | None, |
219 | src.ast.syntax(), | 219 | src.ast.syntax(), |
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 84c2eb793..c95c47bf1 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -140,7 +140,7 @@ fn rename_mod( | |||
140 | let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() }; | 140 | let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() }; |
141 | if let Some(module) = hir::Module::from_declaration(db, module_src) { | 141 | if let Some(module) = hir::Module::from_declaration(db, module_src) { |
142 | let src = module.definition_source(db); | 142 | let src = module.definition_source(db); |
143 | let file_id = src.file_id.as_original_file(); | 143 | let file_id = src.file_id.original_file(db); |
144 | match src.ast { | 144 | match src.ast { |
145 | ModuleSource::SourceFile(..) => { | 145 | ModuleSource::SourceFile(..) => { |
146 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); | 146 | let mod_path: RelativePathBuf = db.file_relative_path(file_id); |