mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
swtich lsp server to vfs
This commit is contained in:
parent
6a755ed83a
commit
a5ef8ad05b
14 changed files with 235 additions and 399 deletions
|
|
@ -43,14 +43,17 @@ impl AnalysisHostImpl {
|
|||
pub fn apply_change(&mut self, change: AnalysisChange) {
|
||||
log::info!("apply_change {:?}", change);
|
||||
// self.gc_syntax_trees();
|
||||
for root_id in change.new_roots {
|
||||
self.db
|
||||
.query_mut(ra_db::SourceRootQuery)
|
||||
.set(root_id, Default::default());
|
||||
}
|
||||
|
||||
for (root_id, root_change) in change.roots_changed {
|
||||
self.apply_root_change(root_id, root_change);
|
||||
}
|
||||
for (file_id, text) in change.files_changed {
|
||||
self.db
|
||||
.query_mut(ra_db::FileTextQuery)
|
||||
.set(file_id, Arc::new(text))
|
||||
self.db.query_mut(ra_db::FileTextQuery).set(file_id, text)
|
||||
}
|
||||
if !change.libraries_added.is_empty() {
|
||||
let mut libraries = Vec::clone(&self.db.libraries());
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@ pub use ra_db::{
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct AnalysisChange {
|
||||
new_roots: Vec<SourceRootId>,
|
||||
roots_changed: FxHashMap<SourceRootId, RootChange>,
|
||||
files_changed: Vec<(FileId, String)>,
|
||||
files_changed: Vec<(FileId, Arc<String>)>,
|
||||
libraries_added: Vec<LibraryData>,
|
||||
crate_graph: Option<CrateGraph>,
|
||||
}
|
||||
|
|
@ -93,6 +94,9 @@ impl AnalysisChange {
|
|||
pub fn new() -> AnalysisChange {
|
||||
AnalysisChange::default()
|
||||
}
|
||||
pub fn add_root(&mut self, root_id: SourceRootId) {
|
||||
self.new_roots.push(root_id);
|
||||
}
|
||||
pub fn add_file(
|
||||
&mut self,
|
||||
root_id: SourceRootId,
|
||||
|
|
@ -111,7 +115,7 @@ impl AnalysisChange {
|
|||
.added
|
||||
.push(file);
|
||||
}
|
||||
pub fn change_file(&mut self, file_id: FileId, new_text: String) {
|
||||
pub fn change_file(&mut self, file_id: FileId, new_text: Arc<String>) {
|
||||
self.files_changed.push((file_id, new_text))
|
||||
}
|
||||
pub fn remove_file(&mut self, root_id: SourceRootId, file_id: FileId, path: RelativePathBuf) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue