From 9105892ec8b454571c56883eace557eee25b3301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 22 Jun 2021 01:45:41 +0200 Subject: refactor: unify JavaScript script execution method (#11043) This commit renames "JsRuntime::execute" to "JsRuntime::execute_script". Additionally same renames were applied to methods on "deno_runtime::Worker" and "deno_runtime::WebWorker". A new macro was added to "deno_core" called "located_script_name" which returns the name of Rust file alongside line no and col no of that call site. This macro is useful in combination with "JsRuntime::execute_script" and allows to provide accurate place where "one-off" JavaScript scripts are executed for internal runtime functions. Co-authored-by: Nayeem Rahman --- cli/lsp/tsc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cli/lsp') diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 83958fde2..ec2276cb4 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -20,6 +20,7 @@ use crate::tsc::ResolveArgs; use deno_core::error::anyhow; use deno_core::error::custom_error; use deno_core::error::AnyError; +use deno_core::located_script_name; use deno_core::op_sync; use deno_core::resolve_url; use deno_core::serde::de; @@ -2264,7 +2265,7 @@ fn start( let init_config = json!({ "debug": debug, "rootUri": root_uri }); let init_src = format!("globalThis.serverInit({});", init_config); - runtime.execute("[native code]", &init_src) + runtime.execute_script(&located_script_name!(), &init_src) } #[derive(Debug, Serialize)] @@ -2649,7 +2650,7 @@ pub fn request( }; let mark = performance.mark("request", Some(request_params.clone())); let request_src = format!("globalThis.serverRequest({});", request_params); - runtime.execute("[native_code]", &request_src)?; + runtime.execute_script(&located_script_name!(), &request_src)?; let op_state = runtime.op_state(); let mut op_state = op_state.borrow_mut(); -- cgit v1.2.3