diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-01-04 18:54:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 18:54:54 -0500 |
commit | 0ee64ad84726f7c91842c6a2dab0cb6a96dead4b (patch) | |
tree | 50d42e65d1f1d1e6b1cffc4e9f38f3e2a5d1dd59 /cli/tools | |
parent | 319f6074761421b797db71bf10f6171516e3d92a (diff) |
fix: upgrade deno_ast to 0.23 (#17269)
Closes #17172
Closes #15669
Closes #8529
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/fmt.rs | 15 | ||||
-rw-r--r-- | cli/tools/repl/editor.rs | 8 | ||||
-rw-r--r-- | cli/tools/repl/session.rs | 5 |
3 files changed, 25 insertions, 3 deletions
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 3cfec9019..d146c958e 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -327,7 +327,20 @@ async fn check_source_files( not_formatted_files_count.fetch_add(1, Ordering::Relaxed); let _g = output_lock.lock(); warn!("Error checking: {}", file_path.to_string_lossy()); - warn!(" {}", e); + warn!( + "{}", + format!("{}", e) + .split('\n') + .map(|l| { + if l.trim().is_empty() { + String::new() + } else { + format!(" {}", l) + } + }) + .collect::<Vec<_>>() + .join("\n") + ); } } Ok(()) diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index fbdda3f5c..a40b6fcd1 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -2,8 +2,10 @@ use crate::colors; use deno_ast::swc::parser::error::SyntaxError; +use deno_ast::swc::parser::token::BinOpToken; use deno_ast::swc::parser::token::Token; use deno_ast::swc::parser::token::Word; +use deno_ast::view::AssignOp; use deno_core::anyhow::Context as _; use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; @@ -235,6 +237,12 @@ impl Validator for EditorHelper { for item in deno_ast::lex(ctx.input(), deno_ast::MediaType::TypeScript) { if let deno_ast::TokenOrComment::Token(token) = item.inner { match token { + Token::BinOp(BinOpToken::Div) + | Token::AssignOp(AssignOp::DivAssign) => { + // it's too complicated to write code to detect regular expression literals + // which are no longer tokenized, so if a `/` or `/=` happens, then we bail + return Ok(ValidationResult::Valid(None)); + } Token::BackQuote => in_template = !in_template, Token::LParen | Token::LBracket diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index 0c0563ab8..f6bbf9b9c 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -193,12 +193,13 @@ impl ReplSession { line: &str, ) -> EvaluationOutput { fn format_diagnostic(diagnostic: &deno_ast::Diagnostic) -> String { + let display_position = diagnostic.display_position(); format!( "{}: {} at {}:{}", colors::red("parse error"), diagnostic.message(), - diagnostic.display_position.line_number, - diagnostic.display_position.column_number, + display_position.line_number, + display_position.column_number, ) } |