Skip to content

Commit

Permalink
feat(lsp): keep track of project file location
Browse files Browse the repository at this point in the history
Extend the `mabo-project` crate to additional store the location from
wheret the project file was loaded.

This is currently used to log the location in the LPS when loading a
folder and searching for Mabo projects in it.
  • Loading branch information
dnaka91 committed Jan 8, 2024
1 parent e56dd8d commit baca562
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/mabo-lsp/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ pub fn initialize(
.root_uri
.and_then(|root| mabo_project::discover(root.path()).ok())
{
for path in projects.into_iter().flat_map(|project| project.files) {
for path in projects
.into_iter()
.inspect(|project| debug!(path = as_debug!(project.project_path); "found project"))
.flat_map(|project| project.files)
{
let Ok(text) = std::fs::read_to_string(&path) else {
error!(path = as_debug!(path); "failed reading file content");
continue;
Expand Down
3 changes: 3 additions & 0 deletions crates/mabo-project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ pub struct Package {
pub struct Project {
/// Parsed content of the `Mabo.toml` project file.
pub project_file: ProjectFile,
/// Location of the `Mabo.toml` project file.
pub project_path: PathBuf,
/// Resolved final list of files to process.
pub files: Vec<PathBuf>,
}
Expand Down Expand Up @@ -163,6 +165,7 @@ fn load_project(base: &Path, file: &Path) -> Result<Project> {

Ok(Project {
project_file,
project_path: file.to_owned(),
files,
})
}
Expand Down

0 comments on commit baca562

Please sign in to comment.