Don't use the canonical path for diagnostics

This commit is contained in:
Olivier Goffart 2020-12-28 15:07:49 +01:00
parent 36ea03ecff
commit 57804b64a3
2 changed files with 17 additions and 5 deletions

View file

@ -234,7 +234,13 @@ impl<'a> TypeLoader<'a> {
}
};
self.load_file(&path_canon, source_code, build_diagnostics).await;
self.load_file(
&path_canon,
SourceFile::new(path.to_owned()),
source_code,
build_diagnostics,
)
.await;
let _ok = self.all_documents.currently_loading.remove(path_canon.as_path());
assert!(_ok);
Some(path_canon)
@ -246,13 +252,14 @@ impl<'a> TypeLoader<'a> {
pub async fn load_file(
&mut self,
path: &Path,
source_path: SourceFile,
source_code: String,
build_diagnostics: &mut BuildDiagnostics,
) {
let (dependency_doc, mut dependency_diagnostics) =
crate::parser::parse(source_code, Some(&path));
crate::parser::parse(source_code, Some(&source_path));
dependency_diagnostics.current_path = SourceFile::new(path.to_owned());
dependency_diagnostics.current_path = source_path;
if dependency_diagnostics.has_error() {
build_diagnostics.add(dependency_diagnostics);

View file

@ -192,9 +192,14 @@ fn reload_document(
document_cache.newline_offsets.insert(uri.clone(), newline_offsets);
let path = Path::new(uri.path());
let path = path.canonicalize().unwrap_or_else(|_| path.to_owned());
let path_canon = path.canonicalize().unwrap_or_else(|_| path.to_owned());
let mut diag = BuildDiagnostics::default();
spin_on::spin_on(document_cache.documents.load_file(&path, content, &mut diag));
spin_on::spin_on(document_cache.documents.load_file(
&path_canon,
sixtyfps_compilerlib::diagnostics::SourceFile::new(path.to_owned()),
content,
&mut diag,
));
for file_diag in diag.into_iter() {
if file_diag.current_path.is_relative() {