mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(oxc_diagnostics): s/PError/Error
This commit is contained in:
parent
eaeafa0a82
commit
915518b614
5 changed files with 17 additions and 17 deletions
|
|
@ -6,15 +6,15 @@ use std::{cell::RefCell, ops::Deref, rc::Rc};
|
|||
pub use miette;
|
||||
pub use thiserror;
|
||||
|
||||
pub type PError = miette::Error;
|
||||
pub type Error = miette::Error;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, PError>;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Diagnostics(Rc<RefCell<Vec<PError>>>);
|
||||
pub struct Diagnostics(Rc<RefCell<Vec<Error>>>);
|
||||
|
||||
impl Deref for Diagnostics {
|
||||
type Target = Rc<RefCell<Vec<PError>>>;
|
||||
type Target = Rc<RefCell<Vec<Error>>>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
|
|
@ -24,7 +24,7 @@ impl Deref for Diagnostics {
|
|||
impl Diagnostics {
|
||||
/// # Panics
|
||||
#[must_use]
|
||||
pub fn into_inner(self) -> Vec<PError> {
|
||||
pub fn into_inner(self) -> Vec<Error> {
|
||||
Rc::try_unwrap(self.0).unwrap().into_inner()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use oxc_diagnostics::PError;
|
||||
use oxc_diagnostics::Error;
|
||||
use oxc_semantic::Semantic;
|
||||
|
||||
pub struct LintContext<'a> {
|
||||
semantic: Rc<Semantic<'a>>,
|
||||
|
||||
diagnostics: RefCell<Vec<PError>>,
|
||||
diagnostics: RefCell<Vec<Error>>,
|
||||
}
|
||||
|
||||
impl<'a> LintContext<'a> {
|
||||
|
|
@ -14,7 +14,7 @@ impl<'a> LintContext<'a> {
|
|||
Self { semantic, diagnostics: RefCell::new(vec![]) }
|
||||
}
|
||||
|
||||
pub fn into_diagnostics(self) -> Vec<PError> {
|
||||
pub fn into_diagnostics(self) -> Vec<Error> {
|
||||
self.diagnostics.into_inner()
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ impl<'a> LintContext<'a> {
|
|||
&self.semantic
|
||||
}
|
||||
|
||||
pub fn diagnostic<T: Into<PError>>(&self, diagnostic: T) {
|
||||
pub fn diagnostic<T: Into<Error>>(&self, diagnostic: T) {
|
||||
self.diagnostics.borrow_mut().push(diagnostic.into());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ mod rules;
|
|||
|
||||
use std::rc::Rc;
|
||||
|
||||
use oxc_diagnostics::PError;
|
||||
use oxc_diagnostics::Error;
|
||||
use oxc_semantic::Semantic;
|
||||
|
||||
use crate::{context::LintContext, rules::RuleEnum};
|
||||
|
|
@ -31,7 +31,7 @@ impl Linter {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn run(&self, semantic: &Rc<Semantic>) -> Vec<PError> {
|
||||
pub fn run(&self, semantic: &Rc<Semantic>) -> Vec<Error> {
|
||||
let ctx = LintContext::new(semantic.clone());
|
||||
|
||||
for node in semantic.nodes().iter() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub use kind::Kind;
|
|||
use number::{parse_big_int, parse_float, parse_int};
|
||||
use oxc_allocator::{Allocator, String};
|
||||
use oxc_ast::{ast::RegExpFlags, Atom, SourceType, Span};
|
||||
use oxc_diagnostics::{Diagnostics, PError};
|
||||
use oxc_diagnostics::{Diagnostics, Error};
|
||||
use simd::{SkipMultilineComment, SkipWhitespace};
|
||||
use string_builder::AutoCow;
|
||||
pub use token::{RegExp, Token, TokenValue};
|
||||
|
|
@ -243,7 +243,7 @@ impl<'a> Lexer<'a> {
|
|||
}
|
||||
|
||||
// ---------- Private Methods ---------- //
|
||||
fn error<T: Into<PError>>(&mut self, error: T) {
|
||||
fn error<T: Into<Error>>(&mut self, error: T) {
|
||||
self.errors.borrow_mut().push(error.into());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ mod lexer;
|
|||
|
||||
use oxc_allocator::Allocator;
|
||||
use oxc_ast::{ast::Program, context::Context, AstBuilder, SourceType, Span};
|
||||
use oxc_diagnostics::{Diagnostics, PError, Result};
|
||||
use oxc_diagnostics::{Diagnostics, Error, Result};
|
||||
|
||||
use crate::{
|
||||
lexer::{Kind, Lexer, Token},
|
||||
|
|
@ -27,7 +27,7 @@ use crate::{
|
|||
#[derive(Debug)]
|
||||
pub struct ParserReturn<'a> {
|
||||
pub program: Program<'a>,
|
||||
pub errors: Vec<PError>,
|
||||
pub errors: Vec<Error>,
|
||||
}
|
||||
|
||||
pub struct Parser<'a> {
|
||||
|
|
@ -118,7 +118,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
/// Check for Flow declaration if the file cannot be parsed.
|
||||
/// The declaration must be [on the first line before any code](https://flow.org/en/docs/usage/#toc-prepare-your-code-for-flow)
|
||||
fn flow_error(&self) -> Option<PError> {
|
||||
fn flow_error(&self) -> Option<Error> {
|
||||
if self.source_type.is_javascript()
|
||||
&& (self.source.starts_with("// @flow") || self.source.starts_with("/* @flow */"))
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
/// Push a Syntax Error
|
||||
fn error<T: Into<PError>>(&mut self, error: T) {
|
||||
fn error<T: Into<Error>>(&mut self, error: T) {
|
||||
self.errors.borrow_mut().push(error.into());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue