Rust: no longer reload files into the RootDatabase

Files were reloaded to handle cases were there was no content
for a file_id, causing a panic. Missing contents was caused by
files that did not contain valid UTF-8 data. These are skipped
by rust-analyzer when it is loading data into the RootDatabase.
This commit is contained in:
Arthur Baars
2024-10-25 18:37:11 +02:00
parent b112a9b31e
commit 57cdda3405
2 changed files with 2 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ mod translate;
pub mod trap;
fn extract(
rust_analyzer: &mut rust_analyzer::RustAnalyzer,
rust_analyzer: &rust_analyzer::RustAnalyzer,
archiver: &Archiver,
traps: &trap::TrapFileProvider,
file: &std::path::Path,

View File

@@ -1,7 +1,6 @@
use itertools::Itertools;
use log::{debug, info};
use ra_ap_base_db::SourceDatabase;
use ra_ap_base_db::SourceDatabaseFileInputExt;
use ra_ap_hir::Semantics;
use ra_ap_ide_db::RootDatabase;
use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
@@ -57,7 +56,7 @@ impl RustAnalyzer {
}
}
}
pub fn parse(&mut self, path: &Path) -> ParseResult<'_> {
pub fn parse(&self, path: &Path) -> ParseResult<'_> {
let mut errors = Vec::new();
let input = match std::fs::read(path) {
Ok(data) => data,
@@ -78,7 +77,6 @@ impl RustAnalyzer {
.map(VfsPath::from)
.and_then(|x| vfs.file_id(&x))
{
db.set_file_text(file_id, &input);
let semantics = Semantics::new(db);
let file_id = EditionedFileId::current_edition(file_id);