pub struct Issue {
pub level: Level,
pub code: Option<String>,
pub message: String,
pub notes: Vec<String>,
pub help: Option<String>,
pub link: Option<String>,
pub annotations: Vec<Annotation>,
pub suggestions: Vec<(SourceIdentifier, FixPlan)>,
}Expand description
Represents an issue identified in the code.
Fields§
§level: LevelThe severity level of the issue.
code: Option<String>An optional code associated with the issue.
message: StringThe main message describing the issue.
notes: Vec<String>Additional notes related to the issue.
help: Option<String>An optional help message suggesting possible solutions or further actions.
link: Option<String>An optional link to external resources for more information about the issue.
annotations: Vec<Annotation>Annotations associated with the issue, providing additional context or highlighting specific code spans.
suggestions: Vec<(SourceIdentifier, FixPlan)>Modification suggestions that can be applied to fix the issue.
Implementations§
Source§impl Issue
impl Issue
Sourcepub fn new(level: Level, message: impl Into<String>) -> Self
pub fn new(level: Level, message: impl Into<String>) -> Self
Creates a new issue with the given level and message.
§Examples
use mago_reporting::{Issue, Level};
let issue = Issue::new(Level::Error, "This is an error");Sourcepub fn error(message: impl Into<String>) -> Self
pub fn error(message: impl Into<String>) -> Self
Creates a new error issue with the given message.
§Examples
use mago_reporting::Issue;
let issue = Issue::error("This is an error");Sourcepub fn warning(message: impl Into<String>) -> Self
pub fn warning(message: impl Into<String>) -> Self
Creates a new warning issue with the given message.
§Examples
use mago_reporting::Issue;
let issue = Issue::warning("This is a warning");Sourcepub fn help(message: impl Into<String>) -> Self
pub fn help(message: impl Into<String>) -> Self
Creates a new help issue with the given message.
§Examples
use mago_reporting::Issue;
let issue = Issue::help("This is a help message");Sourcepub fn note(message: impl Into<String>) -> Self
pub fn note(message: impl Into<String>) -> Self
Creates a new note issue with the given message.
§Examples
use mago_reporting::Issue;
let issue = Issue::note("This is a note");Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Adds a code to this issue.
§Examples
use mago_reporting::{Issue, Level};
let issue = Issue::error("This is an error").with_code("E0001");Sourcepub fn with_annotation(self, annotation: Annotation) -> Self
pub fn with_annotation(self, annotation: Annotation) -> Self
Add an annotation to this issue.
§Examples
use mago_reporting::{Issue, Annotation, AnnotationKind};
use mago_span::Span;
use mago_span::Position;
let start = Position::dummy(0);
let end = Position::dummy(5);
let span = Span::new(start, end);
let issue = Issue::error("This is an error").with_annotation(Annotation::primary(span));pub fn with_annotations( self, annotation: impl IntoIterator<Item = Annotation>, ) -> Self
Sourcepub fn with_note(self, note: impl Into<String>) -> Self
pub fn with_note(self, note: impl Into<String>) -> Self
Add a note to this issue.
§Examples
use mago_reporting::Issue;
let issue = Issue::error("This is an error").with_note("This is a note");Sourcepub fn with_help(self, help: impl Into<String>) -> Self
pub fn with_help(self, help: impl Into<String>) -> Self
Add a help message to this issue.
This is useful for providing additional context to the user on how to resolve the issue.
§Examples
use mago_reporting::Issue;
let issue = Issue::error("This is an error").with_help("This is a help message");Sourcepub fn with_link(self, link: impl Into<String>) -> Self
pub fn with_link(self, link: impl Into<String>) -> Self
Add a link to this issue.
§Examples
use mago_reporting::Issue;
let issue = Issue::error("This is an error").with_link("https://example.com");Sourcepub fn with_suggestion(self, source: SourceIdentifier, plan: FixPlan) -> Self
pub fn with_suggestion(self, source: SourceIdentifier, plan: FixPlan) -> Self
Add a code modification suggestion to this issue.
Sourcepub fn take_suggestions(&mut self) -> Vec<(SourceIdentifier, FixPlan)>
pub fn take_suggestions(&mut self) -> Vec<(SourceIdentifier, FixPlan)>
Take the code modification suggestion from this issue.