-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add code for diagnostic. #3096
add code for diagnostic. #3096
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ pub enum OffsetEncoding { | |
|
||
pub mod util { | ||
use super::*; | ||
use helix_core::{Range, Rope, Transaction}; | ||
use helix_core::{diagnostic::NumberOrString, Range, Rope, Transaction}; | ||
|
||
/// Converts a diagnostic in the document to [`lsp::Diagnostic`]. | ||
/// | ||
|
@@ -78,11 +78,19 @@ pub mod util { | |
Error => lsp::DiagnosticSeverity::ERROR, | ||
}); | ||
|
||
let code = match diag.code.clone() { | ||
Some(x) => match x { | ||
NumberOrString::Number(x) => Some(lsp::NumberOrString::Number(x)), | ||
NumberOrString::String(x) => Some(lsp::NumberOrString::String(x)), | ||
}, | ||
None => None, | ||
}; | ||
Comment on lines
+81
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to clone? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks , String not support Copy ., i remove clone let code = match diag.code.as_ref() {
Some(x) => match x {
NumberOrString::Number(n) => Some(lsp::NumberOrString::Number(*n)),
NumberOrString::String(s) => Some(lsp::NumberOrString::String(s.to_string())),
},
None => None,
}; I not sure how to write is better, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, accidentally deleted a comment by @archseer. Please use clone, it's the same thing. |
||
|
||
// TODO: add support for Diagnostic.data | ||
lsp::Diagnostic::new( | ||
range_to_lsp_range(doc, range, offset_encoding), | ||
severity, | ||
None, | ||
code, | ||
None, | ||
diag.message.to_owned(), | ||
None, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to match
lsp_types
name usingNumberOrString
or would we be better off usingDiagnosticCode
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can express its meaning that is good.