summaryrefslogtreecommitdiff
path: root/cli/ops/errors.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-08-28 17:08:24 +0200
committerGitHub <noreply@github.com>2020-08-28 17:08:24 +0200
commit7e946858a4a0a03c1461590c6fc8a315738a627a (patch)
tree5a6a391fead573b85fb905bb5c4ea8287dc18d13 /cli/ops/errors.rs
parent31f32ed8c4082d36ad2a4ea460366c0d57a5ddbc (diff)
refactor: migrate ops to new dispatch wrapper (#7118)
Diffstat (limited to 'cli/ops/errors.rs')
-rw-r--r--cli/ops/errors.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/cli/ops/errors.rs b/cli/ops/errors.rs
index b9405fe54..558f9af2a 100644
--- a/cli/ops/errors.rs
+++ b/cli/ops/errors.rs
@@ -1,23 +1,26 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-use super::dispatch_json::{Deserialize, JsonOp, Value};
+use super::dispatch_json::{Deserialize, Value};
use crate::diagnostics::Diagnostic;
use crate::source_maps::get_orig_position;
use crate::source_maps::CachedMaps;
use crate::state::State;
use deno_core::CoreIsolate;
use deno_core::ErrBox;
+use deno_core::ResourceTable;
use deno_core::ZeroCopyBuf;
use std::collections::HashMap;
use std::rc::Rc;
pub fn init(i: &mut CoreIsolate, s: &Rc<State>) {
+ let t = &CoreIsolate::state(i).borrow().resource_table.clone();
+
i.register_op(
"op_apply_source_map",
- s.stateful_json_op(op_apply_source_map),
+ s.stateful_json_op_sync(t, op_apply_source_map),
);
i.register_op(
"op_format_diagnostic",
- s.stateful_json_op(op_format_diagnostic),
+ s.stateful_json_op_sync(t, op_format_diagnostic),
);
}
@@ -30,10 +33,11 @@ struct ApplySourceMap {
}
fn op_apply_source_map(
- state: &Rc<State>,
+ state: &State,
+ _resource_table: &mut ResourceTable,
args: Value,
_zero_copy: &mut [ZeroCopyBuf],
-) -> Result<JsonOp, ErrBox> {
+) -> Result<Value, ErrBox> {
let args: ApplySourceMap = serde_json::from_value(args)?;
let mut mappings_map: CachedMaps = HashMap::new();
@@ -46,18 +50,19 @@ fn op_apply_source_map(
&state.global_state.ts_compiler,
);
- Ok(JsonOp::Sync(json!({
+ Ok(json!({
"fileName": orig_file_name,
"lineNumber": orig_line_number as u32,
"columnNumber": orig_column_number as u32,
- })))
+ }))
}
fn op_format_diagnostic(
- _state: &Rc<State>,
+ _state: &State,
+ _resource_table: &mut ResourceTable,
args: Value,
_zero_copy: &mut [ZeroCopyBuf],
-) -> Result<JsonOp, ErrBox> {
+) -> Result<Value, ErrBox> {
let diagnostic = serde_json::from_value::<Diagnostic>(args)?;
- Ok(JsonOp::Sync(json!(diagnostic.to_string())))
+ Ok(json!(diagnostic.to_string()))
}