Skip to content

Commit ccf3329

Browse files
introduce salsa and integrate into djls-project crate (#139)
1 parent 0c041e2 commit ccf3329

File tree

11 files changed

+896
-670
lines changed

11 files changed

+896
-670
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/
3030
- **Internal**: Moved task queueing functionality to `djls-server` crate, renamed from `Worker` to `Queue`, and simplified API.
3131
- **Internal**: Improved Python environment handling, including refactored activation logic.
3232
- **Internal**: Centralized Python linking build logic into a shared `djls-dev` crate to reduce duplication.
33+
- **Internal (djls-project)**: Started Salsa integration for incremental computation with database structure and initial Python environment discovery functionality.
3334

3435
## [5.2.0a0]
3536

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async-trait = "0.1"
1515
pyo3 = "0.24"
1616
pyo3-async-runtimes = "0.24"
1717
pyo3-build-config = "0.24"
18+
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "7edce6e248f35c8114b4b021cdb474a3fb2813b3" }
1819
serde = { version = "1.0", features = ["derive"] }
1920
serde_json = "1.0"
2021
tempfile = "3.19"

crates/djls-project/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ default = []
99

1010
[dependencies]
1111
pyo3 = { workspace = true }
12+
salsa = { workspace = true }
1213
tower-lsp-server = { workspace = true, features = ["proposed"] }
1314

1415
which = "7.0.1"

crates/djls-project/src/db.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use crate::meta::ProjectMetadata;
2+
3+
#[salsa::db]
4+
pub trait Db: salsa::Database {
5+
fn metadata(&self) -> &ProjectMetadata;
6+
}
7+
8+
#[salsa::db]
9+
#[derive(Clone)]
10+
pub struct ProjectDatabase {
11+
storage: salsa::Storage<ProjectDatabase>,
12+
metadata: ProjectMetadata,
13+
}
14+
15+
impl ProjectDatabase {
16+
pub fn new(metadata: ProjectMetadata) -> Self {
17+
let storage = salsa::Storage::new(None);
18+
19+
Self { storage, metadata }
20+
}
21+
}
22+
23+
#[salsa::db]
24+
impl Db for ProjectDatabase {
25+
fn metadata(&self) -> &ProjectMetadata {
26+
&self.metadata
27+
}
28+
}
29+
30+
#[salsa::db]
31+
impl salsa::Database for ProjectDatabase {}

0 commit comments

Comments
 (0)