fix: Resolve compilation errors and improve diagnostics handling

This commit is contained in:
Josh Thomas 2025-01-07 11:50:03 -06:00
parent 8f448508d0
commit 085627fe32
3 changed files with 24 additions and 18 deletions

View file

@ -7,20 +7,27 @@ impl Diagnostics {
pub fn generate_for_document(document: &TextDocument) -> Vec<Diagnostic> {
let mut diagnostics = Vec::new();
// TODO: Add actual diagnostic logic here
// For now, let's just add a placeholder diagnostic
if document.get_text().contains("TODO") {
diagnostics.push(Diagnostic {
range: Range {
start: Position { line: 0, character: 0 },
end: Position { line: 0, character: 5 },
},
severity: Some(DiagnosticSeverity::INFORMATION),
code: Some(NumberOrString::String("django.todo".to_string())),
source: Some("Django LSP".to_string()),
message: "Found TODO comment".to_string(),
..Default::default()
});
// Simple example: Check for TODO comments
for (line_num, line) in document.get_text().lines().enumerate() {
if let Some(col) = line.find("TODO") {
diagnostics.push(Diagnostic {
range: Range {
start: Position {
line: line_num as u32,
character: col as u32
},
end: Position {
line: line_num as u32,
character: (col + 4) as u32
},
},
severity: Some(DiagnosticSeverity::INFORMATION),
code: Some(NumberOrString::String("django.todo".to_string())),
source: Some("Django LSP".to_string()),
message: "Found TODO comment".to_string(),
..Default::default()
});
}
}
diagnostics