diff options
author | Andreu Botella <andreu@andreubotella.com> | 2022-05-13 10:36:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 10:36:31 +0200 |
commit | 3e7afb8918fd0f6cedf839a7ebaae6aaee5e66ad (patch) | |
tree | 7fcc92da290889d3d2290f6e4902ac60685aae87 /cli/lsp | |
parent | 0ee76da07b12fba38962634e65853d73adf9d4c0 (diff) |
chore(runtime): Make some ops in ext and runtime infallible. (#14589)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/tsc.rs | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 0557179b6..27d32b2db 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -2489,10 +2489,7 @@ struct SpecifierArgs { } #[op] -fn op_exists( - state: &mut OpState, - args: SpecifierArgs, -) -> Result<bool, AnyError> { +fn op_exists(state: &mut OpState, args: SpecifierArgs) -> bool { let state = state.borrow_mut::<State>(); // we don't measure the performance of op_exists anymore because as of TS 4.5 // it is noisy with all the checking for custom libs, that we can't see the @@ -2504,10 +2501,9 @@ fn op_exists( // sometimes tsc tries to query invalid specifiers, especially when // something else isn't quite right, so instead of bubbling up the error // back to tsc, we simply swallow it and say the file doesn't exist - Err(_) => return Ok(false), + Err(_) => return false, }; - let result = state.state_snapshot.documents.exists(&specifier); - Ok(result) + state.state_snapshot.documents.exists(&specifier) } #[derive(Debug, Deserialize, Serialize)] @@ -2621,9 +2617,9 @@ fn op_get_text( } #[op] -fn op_is_cancelled(state: &mut OpState) -> Result<bool, AnyError> { +fn op_is_cancelled(state: &mut OpState) -> bool { let state = state.borrow_mut::<State>(); - Ok(state.token.is_cancelled()) + state.token.is_cancelled() } #[op] @@ -2676,27 +2672,22 @@ fn op_resolve( } #[op] -fn op_respond(state: &mut OpState, args: Response) -> Result<bool, AnyError> { +fn op_respond(state: &mut OpState, args: Response) -> bool { let state = state.borrow_mut::<State>(); state.response = Some(args); - Ok(true) + true } #[op] -fn op_script_names( - state: &mut OpState, - _args: Value, -) -> Result<Vec<ModuleSpecifier>, AnyError> { +fn op_script_names(state: &mut OpState) -> Vec<ModuleSpecifier> { let state = state.borrow_mut::<State>(); - Ok( - state - .state_snapshot - .documents - .documents(true, true) - .into_iter() - .map(|d| d.specifier().clone()) - .collect(), - ) + state + .state_snapshot + .documents + .documents(true, true) + .into_iter() + .map(|d| d.specifier().clone()) + .collect() } #[derive(Debug, Deserialize, Serialize)] @@ -3844,8 +3835,6 @@ mod tests { specifier: "/error/unknown:something/index.d.ts".to_string(), }, ); - assert!(actual.is_ok()); - let actual = actual.unwrap(); assert!(!actual); } |