Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,8 @@ insta.workspace = true
utils = { workspace = true, features = ["test-support"] }

[features]
default = ["server-file-watcher"]
# Server OS file watching (off for wasm).
server-file-watcher = ["vfs/notify-backend"]
profile-trace = ["dep:tracing-chrome"]
user-config-schema = ["dep:schemars"]
10 changes: 5 additions & 5 deletions crates/hir/src/base_db/change.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use salsa::Durability;
use triomphe::Arc;
use vfs::ChangedFile;
use vfs::{Change as VfsChange, ChangedFile};

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

match changed_file.change_kind {
vfs::ChangeKind::Create(_, _) => {
match &changed_file.change {
VfsChange::Create(_, _) => {
files_changed |= files.insert(file_id);
}
vfs::ChangeKind::Delete => {
VfsChange::Delete => {
files.remove(&file_id);
files_changed = true;
}
vfs::ChangeKind::Modify(_, _) => {}
VfsChange::Modify(_, _) => {}
}

let text = changed_file.text().unwrap_or_else(|| Arc::from(""));
Expand Down
8 changes: 4 additions & 4 deletions crates/hir/src/base_db/source_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syntax::{
};
use triomphe::Arc;
use utils::{line_index::TextSize, path_identity::PathIdentityIndex};
use vfs::{FileId, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId};

use crate::base_db::{
compilation_plan::{self, CompilationPlan},
Expand Down Expand Up @@ -643,8 +643,8 @@ mod tests {
salsa::{self, Durability},
};

const TOP: FileId = FileId(0);
const MANIFEST: FileId = FileId(1);
const TOP: FileId = FileId::from_raw(0);
const MANIFEST: FileId = FileId::from_raw(1);
const ROOT: SourceRootId = SourceRootId(0);

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

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod tests {

#[test]
fn as_file_returns_source_file_when_hir_file_is_real_file() {
let file_id = FileId(7);
let file_id = FileId::from_raw(7);

let hir_file_id = HirFileId::from(file_id);

Expand Down
6 changes: 3 additions & 3 deletions crates/hir/src/hir_def/macro_file/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use utils::{
line_index::{TextRange, TextSize},
paths::{AbsPathBuf, Utf8PathBuf},
};
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};

use super::*;
use crate::{
Expand All @@ -30,7 +30,7 @@ use crate::{
file::HirFileId,
};

const TOP: FileId = FileId(0);
const TOP: FileId = FileId::from_raw(0);
const ROOT: SourceRootId = SourceRootId(0);
const PROFILE: CompilationProfileId = CompilationProfileId(0);

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

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/hir/src/preproc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use utils::{
line_index::{TextRange, TextSize},
paths::{AbsPathBuf, Utf8PathBuf},
};
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};

use super::*;
use crate::{
Expand All @@ -33,10 +33,10 @@ use crate::{
source_map::IsSrc,
};

const TOP: FileId = FileId(0);
const HEADER: FileId = FileId(1);
const LEAF: FileId = FileId(2);
const MANIFEST: FileId = FileId(3);
const TOP: FileId = FileId::from_raw(0);
const HEADER: FileId = FileId::from_raw(1);
const LEAF: FileId = FileId::from_raw(2);
const MANIFEST: FileId = FileId::from_raw(3);
const ROOT: SourceRootId = SourceRootId(0);
const PROFILE: CompilationProfileId = CompilationProfileId(0);

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

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/hir/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ mod tests {
get::GetRef,
paths::{AbsPathBuf, Utf8PathBuf},
};
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};

use crate::{
base_db::{
Expand All @@ -710,7 +710,7 @@ mod tests {
symbol::{DefKind, DefLoc, NameContext},
};

const TOP: FileId = FileId(0);
const TOP: FileId = FileId::from_raw(0);
const ROOT: SourceRootId = SourceRootId(0);
const PROFILE: CompilationProfileId = CompilationProfileId(0);

Expand All @@ -730,7 +730,7 @@ mod tests {

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/hir/src/semantics/pathres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ mod tests {
use smol_str::SmolStr;
use triomphe::Arc;
use utils::paths::{AbsPathBuf, Utf8PathBuf};
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};

use super::*;
use crate::{
Expand All @@ -323,7 +323,7 @@ mod tests {
symbol::{DefKind, NameContext},
};

const TOP: FileId = FileId(0);
const TOP: FileId = FileId::from_raw(0);
const ROOT: SourceRootId = SourceRootId(0);
const PROFILE: CompilationProfileId = CompilationProfileId(0);

Expand All @@ -343,7 +343,7 @@ mod tests {

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/hir/src/type_infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ mod tests {
use smol_str::SmolStr;
use triomphe::Arc;
use utils::paths::{AbsPathBuf, Utf8PathBuf};
use vfs::{FileId, FileSet, VfsPath, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId, FileSet, VfsPath};

use super::*;
use crate::{
Expand All @@ -878,7 +878,7 @@ mod tests {
symbol::{DefLoc, NameContext},
};

const TOP: FileId = FileId(0);
const TOP: FileId = FileId::from_raw(0);
const ROOT: SourceRootId = SourceRootId(0);
const PROFILE: CompilationProfileId = CompilationProfileId(0);

Expand All @@ -898,7 +898,7 @@ mod tests {

impl FileLoader for TestDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
SourceRootDb::source_root(self, source_root_id).resolve_path(path)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Analysis {
let plan = db.compilation_plan_for_profile(Some(profile_id));
let mut file_ids = plan.roots.clone();
file_ids.extend(plan.include_only.iter().copied());
file_ids.sort_unstable_by_key(|file_id| file_id.0);
file_ids.sort_unstable_by_key(|file_id| file_id.index());
file_ids.dedup();
file_ids
})
Expand Down
15 changes: 4 additions & 11 deletions crates/ide/src/code_action/tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::{fmt::Write, fs, path::Path};

use hir::base_db::{change::Change, source_root::SourceRoot};
use triomphe::Arc;
use utils::{
lines::LineEnding,
text_edit::{TextRange, TextSize},
};
use vfs::{ChangeKind, ChangedFile, FileId, FileSet, VfsPath};
use utils::text_edit::{TextRange, TextSize};
use vfs::{ChangedFile, FileId, FileSet, VfsPath};

use super::*;
use crate::db::root_db::RootDb;
Expand Down Expand Up @@ -113,16 +109,13 @@ fn db_with_file(text: &str) -> (RootDb, FileId, TextSize) {
}

fn db_with_text(text: &str) -> (RootDb, FileId) {
let file_id = FileId(0);
let file_id = FileId::from_raw(0);
let mut file_set = FileSet::default();
file_set.insert(file_id, VfsPath::new_virtual_path("/test.sv".to_owned()));

let mut change = Change::new();
change.set_roots(vec![SourceRoot::new_local(file_set)]);
change.add_changed_file(ChangedFile {
file_id,
change_kind: ChangeKind::Create(Arc::from(text), LineEnding::Unix),
});
change.add_changed_file(ChangedFile::create(file_id, text));

let mut db = RootDb::new(None);
db.apply_change(change);
Expand Down
12 changes: 4 additions & 8 deletions crates/ide/src/completion/engine/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::path::Path;

use hir::base_db::{change::Change, source_root::SourceRoot};
use triomphe::Arc;
use utils::{lines::LineEnding, text_edit::TextSize};
use vfs::{ChangeKind, ChangedFile, FileId, FileSet, VfsPath};
use utils::text_edit::TextSize;
use vfs::{ChangedFile, FileId, FileSet, VfsPath};

use super::*;
use crate::{
Expand All @@ -18,7 +17,7 @@ fn setup_with_path(text: &str, path: &str) -> (AnalysisHost, FilePosition) {
let mut owned = text;
owned = owned.replace(marker, "");

let file_id = FileId(0);
let file_id = FileId::from_raw(0);
let path = VfsPath::new_virtual_path(path.to_string());

let mut file_set = FileSet::default();
Expand All @@ -27,10 +26,7 @@ fn setup_with_path(text: &str, path: &str) -> (AnalysisHost, FilePosition) {

let mut change = Change::new();
change.set_roots(vec![root]);
change.add_changed_file(ChangedFile {
file_id,
change_kind: ChangeKind::Create(Arc::from(owned.as_str()), LineEnding::Unix),
});
change.add_changed_file(ChangedFile::create(file_id, owned.as_str()));

let mut host = AnalysisHost::default();
host.apply_change(change);
Expand Down
4 changes: 2 additions & 2 deletions crates/ide/src/db/root_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use hir::{
},
};
use triomphe::Arc;
use vfs::{FileId, anchored_path::AnchoredPath};
use vfs::{AnchoredPath, FileId};

use crate::db::{
line_index_db::LineIndexDbStorage, workspace_symbol_index_db::WorkspaceSymbolIndexDbStorage,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl fmt::Debug for RootDb {

impl FileLoader for RootDb {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
let source_root_id = SourceRootDb::source_root_id(self, path.anchor_id);
let source_root_id = SourceRootDb::source_root_id(self, path.anchor);
let source_root = SourceRootDb::source_root(self, source_root_id);
source_root.resolve_path(path)
}
Expand Down
12 changes: 4 additions & 8 deletions crates/ide/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,14 @@ mod tests {
symbol::DefKind,
};
use syntax::SyntaxNodeExt;
use triomphe::Arc;
use utils::{lines::LineEnding, text_edit::TextSize};
use vfs::{ChangeKind, ChangedFile, FileId, FileSet, VfsPath};
use utils::text_edit::TextSize;
use vfs::{ChangedFile, FileId, FileSet, VfsPath};

use super::*;
use crate::{analysis_host::AnalysisHost, db::root_db::RootDb};

fn host_with_file(text: &str) -> (AnalysisHost, FileId) {
let file_id = FileId(0);
let file_id = FileId::from_raw(0);
let path = VfsPath::new_virtual_path("/test.v".to_string());

let mut file_set = FileSet::default();
Expand All @@ -383,10 +382,7 @@ mod tests {

let mut change = Change::new();
change.set_roots(vec![root]);
change.add_changed_file(ChangedFile {
file_id,
change_kind: ChangeKind::Create(Arc::from(text), LineEnding::Unix),
});
change.add_changed_file(ChangedFile::create(file_id, text));

let mut host = AnalysisHost::default();
host.apply_change(change);
Expand Down
Loading
Loading