Skip to content

Commit 1d37f5a

Browse files
simplify a bit
1 parent 636d69e commit 1d37f5a

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/djls-ide/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ djls-semantic = { workspace = true }
99
djls-templates = { workspace = true }
1010
djls-workspace = { workspace = true }
1111

12+
salsa = { workspace = true }
1213
tower-lsp-server = { workspace = true }
1314

14-
[dev-dependencies]
15-
1615
[lints]
1716
workspace = true

crates/djls-semantic/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub use builtins::django_builtin_specs;
88
pub use db::Db;
99
pub use db::ValidationErrorAccumulator;
1010
pub use errors::ValidationError;
11-
use salsa::Accumulator;
1211
pub use specs::ArgType;
1312
pub use specs::EndTag;
1413
pub use specs::IntermediateTag;
@@ -18,6 +17,8 @@ pub use specs::TagSpec;
1817
pub use specs::TagSpecs;
1918
pub use validation::TagValidator;
2019

20+
use salsa::Accumulator;
21+
2122
/// Validate a Django template node list and return validation errors.
2223
///
2324
/// This function runs the TagValidator on the parsed node list to check for:
@@ -35,6 +36,6 @@ pub fn validate_nodelist(db: &dyn Db, nodelist: djls_templates::NodeList<'_>) {
3536
let validation_errors = TagValidator::new(db, nodelist).validate();
3637

3738
for error in validation_errors {
38-
db::ValidationErrorAccumulator(error).accumulate(db);
39+
ValidationErrorAccumulator(error).accumulate(db);
3940
}
4041
}

crates/djls-templates/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,13 @@ pub fn parse_template(db: &dyn Db, file: SourceFile) -> Option<NodeList<'_>> {
105105
Ok((nodelist, errors)) => {
106106
for error in errors {
107107
let template_error = TemplateError::Parser(error.to_string());
108-
accumulate_error(db, &template_error, nodelist.line_offsets(db));
108+
TemplateErrorAccumulator(template_error).accumulate(db);
109109
}
110110
nodelist
111111
}
112112
Err(err) => {
113113
let template_error = TemplateError::Parser(err.to_string());
114-
let empty_offsets = LineOffsets::default();
115-
accumulate_error(db, &template_error, &empty_offsets);
114+
TemplateErrorAccumulator(template_error).accumulate(db);
116115

117116
let empty_nodelist = Vec::new();
118117
let empty_offsets = LineOffsets::default();
@@ -122,9 +121,3 @@ pub fn parse_template(db: &dyn Db, file: SourceFile) -> Option<NodeList<'_>> {
122121

123122
Some(nodelist)
124123
}
125-
126-
fn accumulate_error(db: &dyn Db, error: &TemplateError, _line_offsets: &LineOffsets) {
127-
use crate::db::TemplateErrorAccumulator;
128-
129-
TemplateErrorAccumulator(error.clone()).accumulate(db);
130-
}

0 commit comments

Comments
 (0)