Skip to content

Commit

Permalink
refactor(diagnostic): 1 diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed May 10, 2024
1 parent 9525653 commit 5dd98a1
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 450 deletions.
2 changes: 2 additions & 0 deletions crates/oxc_diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ pub use crate::{
pub type Error = miette::Error;
pub type Severity = miette::Severity;
pub type Report = miette::Report;
pub type OxcDiagnostic = miette::MietteDiagnostic;

pub type Result<T> = std::result::Result<T, Error>;

use miette::Diagnostic;
pub use miette::LabeledSpan;
use thiserror::Error;

#[derive(Debug, Error, Diagnostic)]
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_parser/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> ParserImpl<'a> {
fn test_escaped_keyword(&mut self, kind: Kind) {
if self.cur_token().escaped() && kind.is_all_keyword() {
let span = self.cur_token().span();
self.error(diagnostics::EscapedKeyword(span));
self.error(diagnostics::escaped_keyword(span));
}
}

Expand Down Expand Up @@ -158,7 +158,7 @@ impl<'a> ParserImpl<'a> {
pub(crate) fn asi(&mut self) -> Result<()> {
if !self.can_insert_semicolon() {
let span = Span::new(self.prev_token_end, self.cur_token().start);
return Err(diagnostics::AutoSemicolonInsertion(span).into());
return Err(diagnostics::auto_semicolon_insertion(span).into());
}
if self.at(Kind::Semicolon) {
self.advance(Kind::Semicolon);
Expand All @@ -179,7 +179,7 @@ impl<'a> ParserImpl<'a> {
if !self.at(kind) {
let range = self.cur_token().span();
return Err(
diagnostics::ExpectToken(kind.to_str(), self.cur_kind().to_str(), range).into()
diagnostics::expect_token(kind.to_str(), self.cur_kind().to_str(), range).into()
);
}
Ok(())
Expand Down

0 comments on commit 5dd98a1

Please sign in to comment.