mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-12 13:26:51 +00:00
feat: Add detailed logging for document handling and diagnostics publishing
This commit is contained in:
parent
dcc8615aeb
commit
c5d306e4db
1 changed files with 43 additions and 1 deletions
|
@ -30,8 +30,12 @@ impl Store {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let uri = params.text_document.uri.clone();
|
let uri = params.text_document.uri.clone();
|
||||||
client
|
client
|
||||||
.log_message(MessageType::INFO, &format!("Opening document: {}", uri))
|
.log_message(
|
||||||
|
MessageType::INFO,
|
||||||
|
&format!("Opening document: {} (version: {})", uri, params.text_document.version)
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let document = TextDocument::new(
|
let document = TextDocument::new(
|
||||||
uri.to_string(), // Use the cloned URI
|
uri.to_string(), // Use the cloned URI
|
||||||
params.text_document.text,
|
params.text_document.text,
|
||||||
|
@ -39,8 +43,23 @@ impl Store {
|
||||||
params.text_document.language_id,
|
params.text_document.language_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
client
|
||||||
|
.log_message(
|
||||||
|
MessageType::INFO,
|
||||||
|
&format!("Created document with {} lines", document.line_count())
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
self.add_document(document);
|
self.add_document(document);
|
||||||
|
client
|
||||||
|
.log_message(MessageType::INFO, "Document added to store")
|
||||||
|
.await;
|
||||||
|
|
||||||
self.publish_diagnostics(uri.as_str(), client).await?; // Use the cloned URI
|
self.publish_diagnostics(uri.as_str(), client).await?; // Use the cloned URI
|
||||||
|
client
|
||||||
|
.log_message(MessageType::INFO, "Diagnostics published successfully")
|
||||||
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +67,34 @@ impl Store {
|
||||||
if let Some(document) = self.get_document(uri) {
|
if let Some(document) = self.get_document(uri) {
|
||||||
let diagnostics = Diagnostics::generate_for_document(document);
|
let diagnostics = Diagnostics::generate_for_document(document);
|
||||||
client
|
client
|
||||||
|
.log_message(
|
||||||
|
MessageType::INFO,
|
||||||
|
&format!("Publishing {} diagnostics for {}", diagnostics.len(), uri)
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Err(e) = client
|
||||||
.publish_diagnostics(
|
.publish_diagnostics(
|
||||||
Url::parse(uri).unwrap(),
|
Url::parse(uri).unwrap(),
|
||||||
diagnostics,
|
diagnostics,
|
||||||
Some(document.version),
|
Some(document.version),
|
||||||
)
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
client
|
||||||
|
.log_message(
|
||||||
|
MessageType::ERROR,
|
||||||
|
&format!("Failed to publish diagnostics: {}", e)
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
return Err(anyhow!("Failed to publish diagnostics: {}", e));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client
|
||||||
|
.log_message(
|
||||||
|
MessageType::WARNING,
|
||||||
|
&format!("No document found for {}", uri)
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue