pub struct ModuleIssue<'a> { /* private fields */ }
Expand description
An individual diagnostic issue in the ModuleDiagnostics collection.
Created by the DiagnosticsIter iterator, it represents a view into the issue object owned by the collection.
Implementations§
Source§impl<'a> ModuleIssue<'a>
impl<'a> ModuleIssue<'a>
Sourcepub fn code(&self) -> IssueCode
pub fn code(&self) -> IssueCode
Returns an IssueCode object that describes the class of issues to which this issue belongs.
From this IssueCode object, you can obtain additional metadata about this class, or convert the class into a numeric code value.
Sourcepub fn severity(&self) -> IssueSeverity
pub fn severity(&self) -> IssueSeverity
Indicates whether this issue is a hard error or a warning.
Equivalent to issue.code().severity()
.
Sourcepub fn short_message(&self) -> String
pub fn short_message(&self) -> String
Returns a short description of the class of issues to which this issue belongs.
Equivalent to issue.code().to_string()
.
Sourcepub fn verbose_message(&self, text: &ModuleText<'_>) -> String
pub fn verbose_message(&self, text: &ModuleText<'_>) -> String
Returns an issue-specific text message.
Unlike ModuleIssue::short_message, this message considers the full context of the issue and its relation to the source code. Both ModuleDiagnostics::highlight and ModuleIssue::highlight use this text when annotating the source code snippet.
Sourcepub fn origin(&self, text: &ModuleText<'_>) -> ScriptOrigin
pub fn origin(&self, text: &ModuleText<'_>) -> ScriptOrigin
Returns a reference to the source code fragment where the issue appears.
You can use the to_site_span function to convert the returned object into an absolute character index range, or to_position_span to convert it into a line-column range.
Sourcepub fn quickfix(&self) -> Option<IssueQuickfix>
pub fn quickfix(&self) -> Option<IssueQuickfix>
Returns a quick-fix suggestion that could potentially resolve the underlying issue.
Some diagnostic issues can be addressed directly based on heuristic assumptions. For example, if the user misspells a variable name, the IssueQuickfix might suggest a replacement for the identifier.
If the function returns None
, it means there is no quick fix for this
issue that can currently be inferred heuristically. Future versions of
Ad Astra may provide more quick-fix options.
This function is primarily useful for code editor extensions, such as refactoring/quick-fix actions.
Sourcepub fn highlight<'b>(&self, text: &'b ModuleText<'_>) -> ScriptSnippet<'b>
pub fn highlight<'b>(&self, text: &'b ModuleText<'_>) -> ScriptSnippet<'b>
Returns a script snippet that highlights a source code fragment related to the underlying issue, annotating it with the diagnostic message.
This function is similar to ModuleDiagnostics::highlight, but it highlights only a single issue and does not include a footer with summary metadata.
Sourcepub fn depth(&self) -> DiagnosticsDepth
pub fn depth(&self) -> DiagnosticsDepth
Returns a numeric value indicating the level of diagnostic analysis depth to which this issue belongs.
Equivalent to issue.code().depth()
.
See DiagnosticsDepth for more details.