diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-06-22 01:45:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 01:45:41 +0200 |
commit | 9105892ec8b454571c56883eace557eee25b3301 (patch) | |
tree | 965d90e3a885c2f870f58eef921d8811a9a491b9 /cli/lsp/tsc.rs | |
parent | a5eb2dfc93afc2899ed6e1ad2b3e029157889f7c (diff) |
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 <nayeemrmn99@gmail.com>
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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(); |