mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:26:23 +00:00
ruff_db: move ParseDiagnostic
to old
submodule too
This should have been with the previous two commits, but I missed it.
This commit is contained in:
parent
b2e90c3f5c
commit
80be0a0115
4 changed files with 37 additions and 37 deletions
|
@ -1,14 +1,12 @@
|
|||
use std::borrow::Cow;
|
||||
use std::fmt::Formatter;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
use ruff_annotate_snippets::Level as AnnotateLevel;
|
||||
use ruff_python_parser::ParseError;
|
||||
use ruff_text_size::TextRange;
|
||||
|
||||
pub use crate::diagnostic::old::{
|
||||
OldDiagnosticTrait, OldDisplayDiagnostic, OldSecondaryDiagnosticMessage,
|
||||
OldDiagnosticTrait, OldDisplayDiagnostic, OldParseDiagnostic, OldSecondaryDiagnosticMessage,
|
||||
};
|
||||
use crate::files::File;
|
||||
|
||||
|
@ -245,33 +243,3 @@ impl DisplayDiagnosticConfig {
|
|||
DisplayDiagnosticConfig { color: yes }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OldParseDiagnostic {
|
||||
file: File,
|
||||
error: ParseError,
|
||||
}
|
||||
|
||||
impl OldParseDiagnostic {
|
||||
pub fn new(file: File, error: ParseError) -> Self {
|
||||
Self { file, error }
|
||||
}
|
||||
}
|
||||
|
||||
impl OldDiagnosticTrait for OldParseDiagnostic {
|
||||
fn id(&self) -> DiagnosticId {
|
||||
DiagnosticId::InvalidSyntax
|
||||
}
|
||||
|
||||
fn message(&self) -> Cow<str> {
|
||||
self.error.error.to_string().into()
|
||||
}
|
||||
|
||||
fn span(&self) -> Option<Span> {
|
||||
Some(Span::from(self.file).with_range(self.error.location))
|
||||
}
|
||||
|
||||
fn severity(&self) -> Severity {
|
||||
Severity::Error
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ use ruff_annotate_snippets::{
|
|||
Annotation as AnnotateAnnotation, Level as AnnotateLevel, Message as AnnotateMessage,
|
||||
Renderer as AnnotateRenderer, Snippet as AnnotateSnippet,
|
||||
};
|
||||
use ruff_python_parser::ParseError;
|
||||
use ruff_source_file::{OneIndexed, SourceCode};
|
||||
use ruff_text_size::TextRange;
|
||||
|
||||
use crate::{
|
||||
diagnostic::{DiagnosticId, DisplayDiagnosticConfig, Severity, Span},
|
||||
files::File,
|
||||
source::{line_index, source_text},
|
||||
Db,
|
||||
};
|
||||
|
@ -342,3 +344,33 @@ impl OldDiagnosticTrait for std::sync::Arc<dyn OldDiagnosticTrait> {
|
|||
(**self).severity()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OldParseDiagnostic {
|
||||
file: File,
|
||||
error: ParseError,
|
||||
}
|
||||
|
||||
impl OldParseDiagnostic {
|
||||
pub fn new(file: File, error: ParseError) -> Self {
|
||||
Self { file, error }
|
||||
}
|
||||
}
|
||||
|
||||
impl OldDiagnosticTrait for OldParseDiagnostic {
|
||||
fn id(&self) -> DiagnosticId {
|
||||
DiagnosticId::InvalidSyntax
|
||||
}
|
||||
|
||||
fn message(&self) -> Cow<str> {
|
||||
self.error.error.to_string().into()
|
||||
}
|
||||
|
||||
fn span(&self) -> Option<Span> {
|
||||
Some(Span::from(self.file).with_range(self.error.location))
|
||||
}
|
||||
|
||||
fn severity(&self) -> Severity {
|
||||
Severity::Error
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue