aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-11 08:49:39 +0100
committerGitHub <[email protected]>2019-10-11 08:49:39 +0100
commitf70c54ccfbf25a0d9c136c9176f5e17a4cf0e13a (patch)
treeab289f447399dca72e9d9d0193265ad51ccf6c82 /crates/ra_ide_api/src
parentef6ccd75e0961956cb8bd07c59382f85da1dadd3 (diff)
parente44c7ce2004913d3e928bc03df64647c6059ae0e (diff)
Merge #1994
1994: remove last traces of source roots from hir r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs11
1 files changed, 9 insertions, 2 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};
14use ra_text_edit::{TextEdit, TextEditBuilder}; 14use ra_text_edit::{TextEdit, TextEditBuilder};
15use relative_path::RelativePath;
15 16
16use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; 17use 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(),