feat: resolve projects by lockDatabase (#1142)

* feat: implement lock-based project resolution

* feat: first working example
This commit is contained in:
Myriad-Dreamin 2025-01-20 14:51:09 +08:00 committed by GitHub
parent 89c178295a
commit 6d1e40d3a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 460 additions and 65 deletions

View file

@ -24,6 +24,7 @@ pub mod signature;
pub use signature::*;
pub mod semantic_tokens;
pub use semantic_tokens::*;
use tinymist_std::ImmutPath;
use tinymist_world::vfs::WorkspaceResolver;
use tinymist_world::WorldDeps;
use typst::syntax::Source;
@ -76,6 +77,10 @@ pub trait LspWorldExt {
/// Get all depended file ids of a compilation, inclusively.
/// Note: must be called after compilation.
fn depended_files(&self) -> EcoVec<FileId>;
/// Get all depended paths in file system of a compilation, inclusively.
/// Note: must be called after compilation.
fn depended_fs_paths(&self) -> EcoVec<ImmutPath>;
}
impl LspWorldExt for tinymist_project::LspWorld {
@ -109,6 +114,16 @@ impl LspWorldExt for tinymist_project::LspWorld {
});
deps
}
fn depended_fs_paths(&self) -> EcoVec<ImmutPath> {
let mut deps = EcoVec::new();
self.iter_dependencies(&mut |file_id| {
if let Ok(path) = self.path_for_id(file_id) {
deps.push(path.as_path().into());
}
});
deps
}
}
#[cfg(test)]