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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/
### Removed - for now removed features
### Fixed - for any bug fixes
### Security - in case of vulnerabilities
[${version}]: https://github.com/joshuadavidthomas/django-bird/releases/tag/v${version}
[${version}]: https://github.com/joshuadavidthomas/django-language-server/releases/tag/v${version}
-->

## [Unreleased]

### Changed

- Bumped Rust toolchain from 1.88 to 1.90

## [5.2.0]

### Added
Expand Down
62 changes: 31 additions & 31 deletions crates/djls-ide/src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,40 +386,40 @@ fn generate_tag_name_completions(

// First, check if we should suggest end tags
// If partial starts with "end", prioritize end tags
if partial.starts_with("end") && tag_specs.is_some() {
let specs = tag_specs.unwrap();

// Add all end tags that match the partial
for (opener_name, spec) in specs {
if let Some(end_tag) = &spec.end_tag {
if end_tag.name.starts_with(partial) {
// Create a completion for the end tag
let mut insert_text = String::new();
if needs_space {
insert_text.push(' ');
}
insert_text.push_str(&end_tag.name);
if partial.starts_with("end") {
if let Some(specs) = tag_specs {
// Add all end tags that match the partial
for (opener_name, spec) in specs {
if let Some(end_tag) = &spec.end_tag {
if end_tag.name.starts_with(partial) {
// Create a completion for the end tag
let mut insert_text = String::new();
if needs_space {
insert_text.push(' ');
}
insert_text.push_str(&end_tag.name);

// Add closing based on what's already present
match closing {
ClosingBrace::PartialClose | ClosingBrace::None => {
insert_text.push_str(" %}");
// Add closing based on what's already present
match closing {
ClosingBrace::PartialClose | ClosingBrace::None => {
insert_text.push_str(" %}");
}
ClosingBrace::FullClose => {} // No closing needed
}
ClosingBrace::FullClose => {} // No closing needed
}

completions.push(lsp_types::CompletionItem {
label: end_tag.name.to_string(),
kind: Some(lsp_types::CompletionItemKind::KEYWORD),
detail: Some(format!("End tag for {opener_name}")),
text_edit: Some(tower_lsp_server::lsp_types::CompletionTextEdit::Edit(
lsp_types::TextEdit::new(replacement_range, insert_text.clone()),
)),
insert_text_format: Some(lsp_types::InsertTextFormat::PLAIN_TEXT),
filter_text: Some(end_tag.name.to_string()),
sort_text: Some(format!("0_{}", end_tag.name.as_ref())), // Priority sort
..Default::default()
});
completions.push(lsp_types::CompletionItem {
label: end_tag.name.to_string(),
kind: Some(lsp_types::CompletionItemKind::KEYWORD),
detail: Some(format!("End tag for {opener_name}")),
text_edit: Some(tower_lsp_server::lsp_types::CompletionTextEdit::Edit(
lsp_types::TextEdit::new(replacement_range, insert_text.clone()),
)),
insert_text_format: Some(lsp_types::InsertTextFormat::PLAIN_TEXT),
filter_text: Some(end_tag.name.to_string()),
sort_text: Some(format!("0_{}", end_tag.name.as_ref())), // Priority sort
..Default::default()
});
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/djls-project/src/django.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub fn django_available(db: &dyn ProjectDb, project: Project) -> bool {

/// Get the Django settings module name for the current project.
///
/// Returns the settings_module_override from project, or inspector result,
/// or DJANGO_SETTINGS_MODULE env var, or attempts to detect it.
/// Returns the `settings_module_override` from project, or inspector result,
/// or `DJANGO_SETTINGS_MODULE` env var, or attempts to detect it.
#[salsa::tracked]
pub fn django_settings_module(db: &dyn ProjectDb, project: Project) -> Option<String> {
// Check project override first
Expand Down
2 changes: 1 addition & 1 deletion crates/djls-project/src/django/templatetags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::Project;
/// Get template tags for the current project by querying the inspector.
///
/// This tracked function calls the inspector to retrieve Django template tags
/// and parses the JSON response into a TemplateTags struct.
/// and parses the JSON response into a `TemplateTags` struct.
#[salsa::tracked]
pub fn get_templatetags(db: &dyn ProjectDb, _project: Project) -> Option<TemplateTags> {
let json_str = inspector_run(db, Query::Templatetags)?;
Expand Down
4 changes: 4 additions & 0 deletions crates/djls-project/src/inspector/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum Query {

#[derive(Serialize, Deserialize)]
#[allow(clippy::struct_field_names)]
#[allow(dead_code)]
pub struct PythonEnvironmentQueryData {
pub sys_base_prefix: Utf8PathBuf,
pub sys_executable: Utf8PathBuf,
Expand All @@ -24,6 +25,7 @@ pub struct PythonEnvironmentQueryData {

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[allow(dead_code)]
pub enum VersionReleaseLevel {
Alpha,
Beta,
Expand All @@ -32,11 +34,13 @@ pub enum VersionReleaseLevel {
}

#[derive(Serialize, Deserialize)]
#[allow(dead_code)]
pub struct TemplateTagQueryData {
pub templatetags: Vec<TemplateTag>,
}

#[derive(Serialize, Deserialize)]
#[allow(dead_code)]
pub struct TemplateTag {
pub name: String,
pub module: String,
Expand Down
4 changes: 2 additions & 2 deletions crates/djls-project/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl fmt::Display for PythonEnvironment {
///
/// This Salsa tracked function discovers the Python environment based on:
/// 1. Explicit venv path from project config
/// 2. VIRTUAL_ENV environment variable
/// 2. `VIRTUAL_ENV` environment variable
/// 3. Common venv directories in project root (.venv, venv, env, .env)
/// 4. System Python as fallback
#[salsa::tracked]
Expand Down Expand Up @@ -607,7 +607,7 @@ mod tests {
use super::*;
use crate::inspector::pool::InspectorPool;

/// Test implementation of ProjectDb for unit tests
/// Test implementation of `ProjectDb` for unit tests
#[salsa::db]
#[derive(Clone)]
struct TestDatabase {
Expand Down
3 changes: 3 additions & 0 deletions crates/djls-semantic/src/blocks/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use super::tree::BlockTree;
// TODO: centralize salsa struct snapshots so this mess can be shared

#[derive(Serialize)]
#[allow(dead_code)]
pub struct BlockTreeSnapshot {
roots: Vec<u32>,
root_ids: Vec<u32>,
Expand Down Expand Up @@ -143,6 +144,7 @@ impl From<&BlockTree> for BlockTreeSnapshot {

#[derive(Serialize)]
#[serde(tag = "kind")]
#[allow(dead_code)]
pub enum BlockSnapshot {
Container {
container_span: Span,
Expand All @@ -156,6 +158,7 @@ pub enum BlockSnapshot {

#[derive(Serialize)]
#[serde(tag = "node")]
#[allow(dead_code)]
pub enum BlockNodeSnapshot {
Branch {
block_id: u32,
Expand Down
2 changes: 2 additions & 0 deletions crates/djls-semantic/src/blocks/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl BlockTree {
}
}

#[allow(dead_code)]
pub fn roots(&self) -> &Vec<BlockId> {
&self.roots
}
Expand All @@ -25,6 +26,7 @@ impl BlockTree {
&mut self.roots
}

#[allow(dead_code)]
pub fn blocks(&self) -> &Blocks {
&self.blocks
}
Expand Down
2 changes: 1 addition & 1 deletion crates/djls-semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use templatetags::TagSpecs;

/// Validate a Django template node list and return validation errors.
///
/// This function runs the TagValidator on the parsed node list to check for:
/// This function runs the `TagValidator` on the parsed node list to check for:
/// - Unclosed block tags
/// - Mismatched tag pairs
/// - Orphaned intermediate tags
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.88"
channel = "1.90"