From 915518b614b18331688968b34273328339f10bce Mon Sep 17 00:00:00 2001 From: Boshen Date: Sun, 26 Feb 2023 01:36:59 +0800 Subject: [PATCH] refactor(oxc_diagnostics): s/PError/Error --- crates/oxc_diagnostics/src/lib.rs | 10 +++++----- crates/oxc_linter/src/context.rs | 8 ++++---- crates/oxc_linter/src/lib.rs | 4 ++-- crates/oxc_parser/src/lexer/mod.rs | 4 ++-- crates/oxc_parser/src/lib.rs | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/oxc_diagnostics/src/lib.rs b/crates/oxc_diagnostics/src/lib.rs index 5236c0502..a4bfb102b 100644 --- a/crates/oxc_diagnostics/src/lib.rs +++ b/crates/oxc_diagnostics/src/lib.rs @@ -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 = std::result::Result; +pub type Result = std::result::Result; #[derive(Debug, Default, Clone)] -pub struct Diagnostics(Rc>>); +pub struct Diagnostics(Rc>>); impl Deref for Diagnostics { - type Target = Rc>>; + type Target = Rc>>; 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 { + pub fn into_inner(self) -> Vec { Rc::try_unwrap(self.0).unwrap().into_inner() } } diff --git a/crates/oxc_linter/src/context.rs b/crates/oxc_linter/src/context.rs index fcfffb4ce..2412392a1 100644 --- a/crates/oxc_linter/src/context.rs +++ b/crates/oxc_linter/src/context.rs @@ -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>, - diagnostics: RefCell>, + diagnostics: RefCell>, } impl<'a> LintContext<'a> { @@ -14,7 +14,7 @@ impl<'a> LintContext<'a> { Self { semantic, diagnostics: RefCell::new(vec![]) } } - pub fn into_diagnostics(self) -> Vec { + pub fn into_diagnostics(self) -> Vec { self.diagnostics.into_inner() } @@ -23,7 +23,7 @@ impl<'a> LintContext<'a> { &self.semantic } - pub fn diagnostic>(&self, diagnostic: T) { + pub fn diagnostic>(&self, diagnostic: T) { self.diagnostics.borrow_mut().push(diagnostic.into()); } } diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 68f78fbc5..dc15ea997 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -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) -> Vec { + pub fn run(&self, semantic: &Rc) -> Vec { let ctx = LintContext::new(semantic.clone()); for node in semantic.nodes().iter() { diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index 5ee672621..4d3e20493 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -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>(&mut self, error: T) { + fn error>(&mut self, error: T) { self.errors.borrow_mut().push(error.into()); } diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index e33076d90..b23056928 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -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, + pub errors: Vec, } 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 { + fn flow_error(&self) -> Option { 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>(&mut self, error: T) { + fn error>(&mut self, error: T) { self.errors.borrow_mut().push(error.into()); }