From e44c7ce2004913d3e928bc03df64647c6059ae0e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 9 Oct 2019 14:27:37 +0300 Subject: remove last traces of source roots from hir --- crates/ra_ide_api/src/diagnostics.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_api/src') 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::{ Location, SyntaxNode, TextRange, T, }; use ra_text_edit::{TextEdit, TextEditBuilder}; +use relative_path::RelativePath; use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; @@ -47,8 +48,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec }) }) .on::(|d| { - let source_root = db.file_source_root(d.source().file_id.original_file(db)); - let create_file = FileSystemEdit::CreateFile { source_root, path: d.candidate.clone() }; + let original_file = d.source().file_id.original_file(db); + let source_root = db.file_source_root(original_file); + let path = db + .file_relative_path(original_file) + .parent() + .unwrap_or_else(|| RelativePath::new("")) + .join(&d.candidate); + let create_file = FileSystemEdit::CreateFile { source_root, path }; let fix = SourceChange::file_system_edit("create module", create_file); res.borrow_mut().push(Diagnostic { range: d.highlight_range(), -- cgit v1.2.3