rslint_core

Struct Diagnostic

Source
pub struct Diagnostic {
    pub file_id: usize,
    pub severity: Severity,
    pub code: Option<String>,
    pub title: String,
    pub tag: Option<DiagnosticTag>,
    pub primary: Option<SubDiagnostic>,
    pub children: Vec<SubDiagnostic>,
    pub suggestions: Vec<CodeSuggestion>,
    pub footers: Vec<Footer>,
}
Expand description

A diagnostic message that can give information like errors or warnings.

Fields§

§file_id: usize§severity: Severity§code: Option<String>§title: String§tag: Option<DiagnosticTag>§primary: Option<SubDiagnostic>§children: Vec<SubDiagnostic>§suggestions: Vec<CodeSuggestion>§footers: Vec<Footer>

Implementations§

Source§

impl Diagnostic

Source

pub fn error( file_id: usize, code: impl Into<String>, title: impl Into<String>, ) -> Diagnostic

Creates a new Diagnostic with the Error severity.

Source

pub fn warning( file_id: usize, code: impl Into<String>, title: impl Into<String>, ) -> Diagnostic

Creates a new Diagnostic with the Warning severity.

Source

pub fn help( file_id: usize, code: impl Into<String>, title: impl Into<String>, ) -> Diagnostic

Creates a new Diagnostic with the Help severity.

Source

pub fn note( file_id: usize, code: impl Into<String>, title: impl Into<String>, ) -> Diagnostic

Creates a new Diagnostic with the Note severity.

Source

pub fn new( file_id: usize, severity: Severity, title: impl Into<String>, ) -> Diagnostic

Creates a new Diagnostic that will be used in a builder-like way to modify labels, and suggestions.

Source

pub fn new_with_code( file_id: usize, severity: Severity, title: impl Into<String>, code: Option<String>, ) -> Diagnostic

Creates a new Diagnostic with an error code that will be used in a builder-like way to modify labels, and suggestions.

Source

pub fn severity(self, severity: Severity) -> Diagnostic

Overwrites the severity of this diagnostic.

Source

pub fn deprecated(self) -> Diagnostic

Marks this diagnostic as deprecated code, which will be displayed in the language server.

This does not have any influence on the diagnostic rendering.

Source

pub fn unnecessary(self) -> Diagnostic

Marks this diagnostic as unnecessary code, which will be displayed in the language server.

This does not have any influence on the diagnostic rendering.

Source

pub fn label_in_file( self, severity: Severity, span: FileSpan, msg: String, ) -> Diagnostic

Attaches a label to this Diagnostic, that will point to another file that is provided.

Source

pub fn label( self, severity: Severity, span: impl Span, msg: impl Into<String>, ) -> Diagnostic

Attaches a label to this Diagnostic.

The given span has to be in the file that was provided while creating this Diagnostic.

Source

pub fn primary(self, span: impl Span, msg: impl Into<String>) -> Diagnostic

Attaches a primary label to this Diagnostic.

Source

pub fn secondary(self, span: impl Span, msg: impl Into<String>) -> Diagnostic

Attaches a secondary label to this Diagnostic.

Source

pub fn suggestion_in_file( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, file: usize, ) -> Diagnostic

Prints out a message that suggests a possible solution, that is in another file as this Diagnostic, to the error.

If the message plus the suggestion is longer than 25 chars, the suggestion is displayed as a new children of this Diagnostic, otherwise it will be inlined with the other labels.

A suggestion is displayed like:

try adding a `;`: console.log();

or in a separate multiline suggestion

The message should not contain the : because it’s added automatically. The suggestion will automatically be wrapped inside two backticks.

Source

pub fn suggestion( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, ) -> Diagnostic

Prints out a message that suggests a possible solution to the error.

If the message plus the suggestion is longer than 25 chars, the suggestion is displayed as a new children of this Diagnostic, otherwise it will be inlined with the other labels.

A suggestion is displayed like:

try adding a `;`: console.log();

or in a separate multiline suggestion

The message should not contain the : because it’s added automatically. The suggestion will automatically be wrapped inside two backticks.

Source

pub fn suggestion_full( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, ) -> Diagnostic

Add a suggestion which is always shown in the Full style.

Source

pub fn suggestion_inline( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, ) -> Diagnostic

Add a suggestion which is always shown in the Inline style.

Source

pub fn suggestion_no_code( self, span: impl Span, msg: &str, applicability: Applicability, ) -> Diagnostic

Add a suggestion which does not have a suggestion code.

Source

pub fn indel_suggestion( self, indels: impl IntoIterator<Item = Indel>, span: impl Span, msg: &str, applicability: Applicability, ) -> Diagnostic

Source

pub fn suggestion_with_labels( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, labels: impl IntoIterator<Item = impl Span>, ) -> Diagnostic

Add a suggestion with info labels which point to places in the suggestion.

The label ranges are relative to the start of the span, not relative to the original code

Source

pub fn suggestion_with_src_labels( self, span: impl Span, msg: &str, suggestion: impl Into<String>, applicability: Applicability, labels: impl IntoIterator<Item = impl Span>, ) -> Diagnostic

Add a suggestion with info labels which point to places in the suggestion.

The label ranges are relative to the source code, not relative to the original code

Source

pub fn footer(self, severity: Severity, msg: impl Into<String>) -> Diagnostic

Adds a footer to this Diagnostic, which will be displayed under the actual error.

Source

pub fn footer_help(self, msg: impl Into<String>) -> Diagnostic

Adds a footer to this Diagnostic, with the Help severity.

Source

pub fn footer_note(self, msg: impl Into<String>) -> Diagnostic

Adds a footer to this Diagnostic, with the Note severity.

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Diagnostic

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for Diagnostic

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Diagnostic

Source§

fn eq(&self, other: &Diagnostic) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Diagnostic

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> Erasable for T

Source§

const ACK_1_1_0: bool = true

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
Source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.