summaryrefslogtreecommitdiff
path: root/cli/ast.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-10-23 11:50:15 +1100
committerGitHub <noreply@github.com>2020-10-23 11:50:15 +1100
commit7e2c7fb6c5454e30158d74e1a5786183ea391f07 (patch)
tree42402aa26a0422b9c46d1d441598dbe803b8ed15 /cli/ast.rs
parent9fa59f0ca8164f5e02ba2a2fa90b6fdbce5c1afb (diff)
refactor(cli): migrate run and cache to new infrastructure (#7996)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/ast.rs')
-rw-r--r--cli/ast.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/ast.rs b/cli/ast.rs
index 95f243717..78cafca1b 100644
--- a/cli/ast.rs
+++ b/cli/ast.rs
@@ -72,6 +72,18 @@ impl Into<Location> for swc_common::Loc {
}
}
+impl Into<ModuleSpecifier> for Location {
+ fn into(self) -> ModuleSpecifier {
+ ModuleSpecifier::resolve_url_or_path(&self.filename).unwrap()
+ }
+}
+
+impl std::fmt::Display for Location {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "{}:{}:{}", self.filename, self.line, self.col)
+ }
+}
+
/// A buffer for collecting diagnostic messages from the AST parser.
#[derive(Debug)]
pub struct DiagnosticBuffer(Vec<String>);