mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-07 10:50:40 +00:00
lint clippy and fmt
This commit is contained in:
parent
79a0c4cb4f
commit
db5f3aac65
5 changed files with 49 additions and 56 deletions
|
@ -2,7 +2,6 @@ use std::future::Future;
|
|||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::RwLock;
|
||||
use serde_json;
|
||||
use tower_lsp_server::jsonrpc::Result as LspResult;
|
||||
use tower_lsp_server::lsp_types::CompletionOptions;
|
||||
use tower_lsp_server::lsp_types::CompletionParams;
|
||||
|
@ -282,31 +281,28 @@ impl LanguageServer for DjangoLanguageServer {
|
|||
}
|
||||
|
||||
async fn execute_command(&self, params: ExecuteCommandParams) -> LspResult<Option<serde_json::Value>> {
|
||||
match params.command.as_str() {
|
||||
"djls/dumpState" => {
|
||||
tracing::info!("Executing djls/dumpState command");
|
||||
if params.command.as_str() == "djls/dumpState" {
|
||||
tracing::info!("Executing djls/dumpState command");
|
||||
|
||||
// Check if debug mode is enabled
|
||||
if std::env::var("DJLS_DEBUG").is_err() {
|
||||
tracing::warn!("djls/dumpState command requires DJLS_DEBUG environment variable");
|
||||
return Ok(Some(serde_json::json!({
|
||||
"error": "Debug mode not enabled. Set DJLS_DEBUG environment variable."
|
||||
})));
|
||||
}
|
||||
|
||||
let result = self.with_session(|session| {
|
||||
session.dump_debug_state()
|
||||
}).await;
|
||||
|
||||
Ok(Some(serde_json::json!({
|
||||
"success": true,
|
||||
"message": result
|
||||
})))
|
||||
}
|
||||
_ => {
|
||||
tracing::warn!("Unknown command: {}", params.command);
|
||||
Ok(None)
|
||||
// Check if debug mode is enabled
|
||||
if std::env::var("DJLS_DEBUG").is_err() {
|
||||
tracing::warn!("djls/dumpState command requires DJLS_DEBUG environment variable");
|
||||
return Ok(Some(serde_json::json!({
|
||||
"error": "Debug mode not enabled. Set DJLS_DEBUG environment variable."
|
||||
})));
|
||||
}
|
||||
|
||||
let result = self.with_session(|session| {
|
||||
session.dump_debug_state()
|
||||
}).await;
|
||||
|
||||
Ok(Some(serde_json::json!({
|
||||
"success": true,
|
||||
"message": result
|
||||
})))
|
||||
} else {
|
||||
tracing::warn!("Unknown command: {}", params.command);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ use djls_project::DjangoProject;
|
|||
use salsa::StorageHandle;
|
||||
use tower_lsp_server::lsp_types::ClientCapabilities;
|
||||
use tower_lsp_server::lsp_types::InitializeParams;
|
||||
use serde_json;
|
||||
|
||||
use crate::db::ServerDatabase;
|
||||
use crate::workspace::Store;
|
||||
|
@ -124,13 +123,13 @@ impl Session {
|
|||
});
|
||||
|
||||
match fs::write(&filename, serde_json::to_string_pretty(&debug_info).unwrap_or_else(|_| "{}".to_string())) {
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
tracing::info!("Debug state dumped to: {}", filename);
|
||||
format!("Debug state written to: {}", filename)
|
||||
format!("Debug state written to: {filename}")
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to write debug state: {}", e);
|
||||
format!("Failed to write debug state: {}", e)
|
||||
format!("Failed to write debug state: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,4 +117,3 @@ pub struct TemplateTagContext {
|
|||
pub closing_brace: ClosingBrace,
|
||||
pub needs_leading_space: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -168,9 +168,9 @@ impl FileSystem {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation of the `vfs::FileSystem` trait for VfsPath compatibility.
|
||||
/// Implementation of the `vfs::FileSystem` trait for `VfsPath` compatibility.
|
||||
///
|
||||
/// This trait implementation allows our custom FileSystem to be used with VfsPath
|
||||
/// This trait implementation allows our custom `FileSystem` to be used with `VfsPath`
|
||||
/// while maintaining the dual-layer architecture. All operations respect the
|
||||
/// memory-over-physical priority, ensuring LSP semantics are preserved even when
|
||||
/// accessed through the generic VFS interface.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use super::fs::FileSystem;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use serde_json;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use anyhow::Result;
|
||||
|
@ -79,7 +78,7 @@ impl Store {
|
|||
&relative_path.to_string_lossy(),
|
||||
content
|
||||
) {
|
||||
eprintln!("Warning: Failed to write file to VFS: {}", e);
|
||||
eprintln!("Warning: Failed to write file to VFS: {e}");
|
||||
// Continue with normal processing despite VFS error
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ impl Store {
|
|||
|
||||
// Write updated content back to VFS
|
||||
if let Err(e) = self.vfs.write_string(&relative_path_str, &updated_content) {
|
||||
eprintln!("Warning: Failed to write to VFS: {}", e);
|
||||
eprintln!("Warning: Failed to write to VFS: {e}");
|
||||
}
|
||||
|
||||
// Update document metadata (just version)
|
||||
|
@ -146,7 +145,7 @@ impl Store {
|
|||
|
||||
// Discard any unsaved changes in VFS (clean up memory layer)
|
||||
if let Err(e) = self.vfs.discard_changes(&relative_path_str) {
|
||||
eprintln!("Warning: Failed to discard VFS changes on close: {}", e);
|
||||
eprintln!("Warning: Failed to discard VFS changes on close: {e}");
|
||||
// Continue with document removal despite VFS error
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ impl Store {
|
|||
|
||||
// Discard changes in VFS (clear memory layer so reads return disk content)
|
||||
if let Err(e) = self.vfs.discard_changes(&relative_path_str) {
|
||||
eprintln!("Warning: Failed to discard VFS changes on save: {}", e);
|
||||
eprintln!("Warning: Failed to discard VFS changes on save: {e}");
|
||||
// Continue normally - this is not a critical error
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ impl Store {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Apply text changes to content (similar to TextDocument::with_changes but for strings)
|
||||
/// Apply text changes to content (similar to `TextDocument::with_changes` but for strings)
|
||||
fn apply_changes_to_content(
|
||||
&self,
|
||||
mut content: String,
|
||||
|
@ -338,7 +337,7 @@ impl Store {
|
|||
}
|
||||
}
|
||||
|
||||
/// Debug method to expose VFS state (only enabled with DJLS_DEBUG)
|
||||
/// Debug method to expose VFS state (only enabled with `DJLS_DEBUG`)
|
||||
pub fn debug_vfs_state(&self) -> serde_json::Value {
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -405,13 +404,13 @@ impl Store {
|
|||
})
|
||||
}
|
||||
|
||||
/// Debug method to expose Store state (only enabled with DJLS_DEBUG)
|
||||
/// Debug method to expose Store state (only enabled with `DJLS_DEBUG`)
|
||||
pub fn debug_store_state(&self) -> serde_json::Value {
|
||||
use std::collections::HashMap;
|
||||
|
||||
let mut documents_info = HashMap::new();
|
||||
|
||||
for (uri, _doc) in &self.documents {
|
||||
for uri in self.documents.keys() {
|
||||
documents_info.insert(uri.clone(), serde_json::json!({
|
||||
"version": self.versions.get(uri),
|
||||
"tracked": true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue