Skip to content

Commit dcf1ccd

Browse files
authored
fix(lsp): cold terminal requests; vendor rust-analyzer VFS (#301)
2 parents 31b64c7 + 28d7da4 commit dcf1ccd

63 files changed

Lines changed: 2064 additions & 2333 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,8 @@ insta.workspace = true
137137
utils = { workspace = true, features = ["test-support"] }
138138

139139
[features]
140+
default = ["server-file-watcher"]
141+
# Server OS file watching (off for wasm).
142+
server-file-watcher = ["vfs/notify-backend"]
140143
profile-trace = ["dep:tracing-chrome"]
141144
user-config-schema = ["dep:schemars"]

crates/hir/src/base_db/change.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use salsa::Durability;
22
use triomphe::Arc;
3-
use vfs::ChangedFile;
3+
use vfs::{Change as VfsChange, ChangedFile};
44

55
use crate::base_db::{
66
project::{PreprocessConfig, SharedProjectConfig},
@@ -66,15 +66,15 @@ impl Change {
6666
.path_for_file(&file_id)
6767
.and_then(|path| path.as_abs_path().map(ToOwned::to_owned));
6868

69-
match changed_file.change_kind {
70-
vfs::ChangeKind::Create(_, _) => {
69+
match &changed_file.change {
70+
VfsChange::Create(_, _) => {
7171
files_changed |= files.insert(file_id);
7272
}
73-
vfs::ChangeKind::Delete => {
73+
VfsChange::Delete => {
7474
files.remove(&file_id);
7575
files_changed = true;
7676
}
77-
vfs::ChangeKind::Modify(_, _) => {}
77+
VfsChange::Modify(_, _) => {}
7878
}
7979

8080
let text = changed_file.text().unwrap_or_else(|| Arc::from(""));

crates/hir/src/base_db/source_db.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use syntax::{
55
};
66
use triomphe::Arc;
77
use utils::{line_index::TextSize, path_identity::PathIdentityIndex};
8-
use vfs::{FileId, anchored_path::AnchoredPath};
8+
use vfs::{AnchoredPath, FileId};
99

1010
use crate::base_db::{
1111
compilation_plan::{self, CompilationPlan},
@@ -643,8 +643,8 @@ mod tests {
643643
salsa::{self, Durability},
644644
};
645645

646-
const TOP: FileId = FileId(0);
647-
const MANIFEST: FileId = FileId(1);
646+
const TOP: FileId = FileId::from_raw(0);
647+
const MANIFEST: FileId = FileId::from_raw(1);
648648
const ROOT: SourceRootId = SourceRootId(0);
649649

650650
#[salsa::database(SourceDbStorage, SourceRootDbStorage)]
@@ -663,7 +663,7 @@ mod tests {
663663

664664
impl FileLoader for TestDb {
665665
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
666-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
666+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
667667
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
668668
}
669669
}

crates/hir/src/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mod tests {
3737

3838
#[test]
3939
fn as_file_returns_source_file_when_hir_file_is_real_file() {
40-
let file_id = FileId(7);
40+
let file_id = FileId::from_raw(7);
4141

4242
let hir_file_id = HirFileId::from(file_id);
4343

crates/hir/src/hir_def/macro_file/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use utils::{
1212
line_index::{TextRange, TextSize},
1313
paths::{AbsPathBuf, Utf8PathBuf},
1414
};
15-
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
15+
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};
1616

1717
use super::*;
1818
use crate::{
@@ -30,7 +30,7 @@ use crate::{
3030
file::HirFileId,
3131
};
3232

33-
const TOP: FileId = FileId(0);
33+
const TOP: FileId = FileId::from_raw(0);
3434
const ROOT: SourceRootId = SourceRootId(0);
3535
const PROFILE: CompilationProfileId = CompilationProfileId(0);
3636

@@ -50,7 +50,7 @@ impl fmt::Debug for TestDb {
5050

5151
impl FileLoader for TestDb {
5252
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
53-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
53+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
5454
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
5555
}
5656
}

crates/hir/src/preproc/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use utils::{
77
line_index::{TextRange, TextSize},
88
paths::{AbsPathBuf, Utf8PathBuf},
99
};
10-
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
10+
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};
1111

1212
use super::*;
1313
use crate::{
@@ -33,10 +33,10 @@ use crate::{
3333
source_map::IsSrc,
3434
};
3535

36-
const TOP: FileId = FileId(0);
37-
const HEADER: FileId = FileId(1);
38-
const LEAF: FileId = FileId(2);
39-
const MANIFEST: FileId = FileId(3);
36+
const TOP: FileId = FileId::from_raw(0);
37+
const HEADER: FileId = FileId::from_raw(1);
38+
const LEAF: FileId = FileId::from_raw(2);
39+
const MANIFEST: FileId = FileId::from_raw(3);
4040
const ROOT: SourceRootId = SourceRootId(0);
4141
const PROFILE: CompilationProfileId = CompilationProfileId(0);
4242

@@ -56,7 +56,7 @@ impl fmt::Debug for TestDb {
5656

5757
impl FileLoader for TestDb {
5858
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
59-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
59+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
6060
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
6161
}
6262
}

crates/hir/src/scope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ mod tests {
690690
get::GetRef,
691691
paths::{AbsPathBuf, Utf8PathBuf},
692692
};
693-
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
693+
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};
694694

695695
use crate::{
696696
base_db::{
@@ -710,7 +710,7 @@ mod tests {
710710
symbol::{DefKind, DefLoc, NameContext},
711711
};
712712

713-
const TOP: FileId = FileId(0);
713+
const TOP: FileId = FileId::from_raw(0);
714714
const ROOT: SourceRootId = SourceRootId(0);
715715
const PROFILE: CompilationProfileId = CompilationProfileId(0);
716716

@@ -730,7 +730,7 @@ mod tests {
730730

731731
impl FileLoader for TestDb {
732732
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
733-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
733+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
734734
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
735735
}
736736
}

crates/hir/src/semantics/pathres.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ mod tests {
302302
use smol_str::SmolStr;
303303
use triomphe::Arc;
304304
use utils::paths::{AbsPathBuf, Utf8PathBuf};
305-
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
305+
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};
306306

307307
use super::*;
308308
use crate::{
@@ -323,7 +323,7 @@ mod tests {
323323
symbol::{DefKind, NameContext},
324324
};
325325

326-
const TOP: FileId = FileId(0);
326+
const TOP: FileId = FileId::from_raw(0);
327327
const ROOT: SourceRootId = SourceRootId(0);
328328
const PROFILE: CompilationProfileId = CompilationProfileId(0);
329329

@@ -343,7 +343,7 @@ mod tests {
343343

344344
impl FileLoader for TestDb {
345345
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
346-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
346+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
347347
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
348348
}
349349
}

crates/hir/src/type_infer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ mod tests {
858858
use smol_str::SmolStr;
859859
use triomphe::Arc;
860860
use utils::paths::{AbsPathBuf, Utf8PathBuf};
861-
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
861+
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};
862862

863863
use super::*;
864864
use crate::{
@@ -878,7 +878,7 @@ mod tests {
878878
symbol::{DefLoc, NameContext},
879879
};
880880

881-
const TOP: FileId = FileId(0);
881+
const TOP: FileId = FileId::from_raw(0);
882882
const ROOT: SourceRootId = SourceRootId(0);
883883
const PROFILE: CompilationProfileId = CompilationProfileId(0);
884884

@@ -898,7 +898,7 @@ mod tests {
898898

899899
impl FileLoader for TestDb {
900900
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
901-
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
901+
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
902902
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
903903
}
904904
}

crates/ide/src/analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Analysis {
142142
let plan = db.compilation_plan_for_profile(Some(profile_id));
143143
let mut file_ids = plan.roots.clone();
144144
file_ids.extend(plan.include_only.iter().copied());
145-
file_ids.sort_unstable_by_key(|file_id| file_id.0);
145+
file_ids.sort_unstable_by_key(|file_id| file_id.index());
146146
file_ids.dedup();
147147
file_ids
148148
})

0 commit comments

Comments
 (0)