diff options
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r-- | cli/lsp/tsc.rs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index e236eee0a..eba3c5b3e 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -44,6 +44,7 @@ use deno_core::ModuleSpecifier; use deno_core::OpState; use deno_core::RuntimeOptions; use deno_runtime::tokio_util::create_basic_runtime; +use lazy_regex::lazy_regex; use once_cell::sync::Lazy; use regex::Captures; use regex::Regex; @@ -65,24 +66,18 @@ use tower_lsp::jsonrpc::Result as LspResult; use tower_lsp::lsp_types as lsp; static BRACKET_ACCESSOR_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r#"^\[['"](.+)[\['"]\]$"#).unwrap()); -static CAPTION_RE: Lazy<Regex> = Lazy::new(|| { - Regex::new(r"<caption>(.*?)</caption>\s*\r?\n((?:\s|\S)*)").unwrap() -}); -static CODEBLOCK_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r"^\s*[~`]{3}").unwrap()); -static EMAIL_MATCH_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r"(.+)\s<([-.\w]+@[-.\w]+)>").unwrap()); -static HTTP_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r#"(?i)^https?:"#).unwrap()); -static JSDOC_LINKS_RE: Lazy<Regex> = Lazy::new(|| { - Regex::new(r"(?i)\{@(link|linkplain|linkcode) (https?://[^ |}]+?)(?:[| ]([^{}\n]+?))?\}").unwrap() -}); -static PART_KIND_MODIFIER_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r",|\s+").unwrap()); -static PART_RE: Lazy<Regex> = - Lazy::new(|| Regex::new(r"^(\S+)\s*-?\s*").unwrap()); -static SCOPE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"scope_(\d)").unwrap()); + lazy_regex!(r#"^\[['"](.+)[\['"]\]$"#); +static CAPTION_RE: Lazy<Regex> = + lazy_regex!(r"<caption>(.*?)</caption>\s*\r?\n((?:\s|\S)*)"); +static CODEBLOCK_RE: Lazy<Regex> = lazy_regex!(r"^\s*[~`]{3}"); +static EMAIL_MATCH_RE: Lazy<Regex> = lazy_regex!(r"(.+)\s<([-.\w]+@[-.\w]+)>"); +static HTTP_RE: Lazy<Regex> = lazy_regex!(r#"(?i)^https?:"#); +static JSDOC_LINKS_RE: Lazy<Regex> = lazy_regex!( + r"(?i)\{@(link|linkplain|linkcode) (https?://[^ |}]+?)(?:[| ]([^{}\n]+?))?\}" +); +static PART_KIND_MODIFIER_RE: Lazy<Regex> = lazy_regex!(r",|\s+"); +static PART_RE: Lazy<Regex> = lazy_regex!(r"^(\S+)\s*-?\s*"); +static SCOPE_RE: Lazy<Regex> = lazy_regex!(r"scope_(\d)"); const FILE_EXTENSION_KIND_MODIFIERS: &[&str] = &[".d.ts", ".ts", ".tsx", ".js", ".jsx", ".json"]; |