ability to set suggestions on lints (#6535)

* fix the lint tests which were not compiling

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* apply sugggestions for offsetplanes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* diagnostics and suggestions for offset planes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-28 12:07:10 -07:00
committed by GitHub
parent 2e754f2a11
commit 94452cce88
10 changed files with 339 additions and 266 deletions

View File

@ -1,4 +1,5 @@
use indexmap::IndexMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tower_lsp::lsp_types::{Diagnostic, DiagnosticSeverity};
@ -228,13 +229,10 @@ impl IntoDiagnostic for KclErrorWithOutputs {
fn to_lsp_diagnostics(&self, code: &str) -> Vec<Diagnostic> {
let message = self.error.get_message();
let source_ranges = self.error.source_ranges();
println!("self: {:?}", self);
source_ranges
.into_iter()
.map(|source_range| {
println!("source_range: {:?}", source_range);
println!("filenames: {:?}", self.filenames);
let source = self
.source_files
.get(&source_range.module_id())
@ -658,10 +656,19 @@ pub enum Tag {
None,
}
#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS)]
#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS, PartialEq, Eq, JsonSchema)]
#[ts(export)]
pub struct Suggestion {
pub title: String,
pub insert: String,
pub source_range: SourceRange,
}
pub type LspSuggestion = (Suggestion, tower_lsp::lsp_types::Range);
impl Suggestion {
pub fn to_lsp_edit(&self, code: &str) -> LspSuggestion {
let range = self.source_range.to_lsp_range(code);
(self.clone(), range)
}
}