Struct ModuleIssue

Source
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>

Source

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.

Source

pub fn severity(&self) -> IssueSeverity

Indicates whether this issue is a hard error or a warning.

Equivalent to issue.code().severity().

Source

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().

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Identifiable for ModuleIssue<'a>

Source§

fn id(&self) -> Id

Returns the globally unique identifier of the compilation unit to which this object belongs.

Auto Trait Implementations§

§

impl<'a> Freeze for ModuleIssue<'a>

§

impl<'a> RefUnwindSafe for ModuleIssue<'a>

§

impl<'a> Send for ModuleIssue<'a>

§

impl<'a> Sync for ModuleIssue<'a>

§

impl<'a> Unpin for ModuleIssue<'a>

§

impl<'a> UnwindSafe for ModuleIssue<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.