summaryrefslogtreecommitdiff
path: root/cli/lsp/documents.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-12-19 02:44:42 +0530
committerGitHub <noreply@github.com>2021-12-18 16:14:42 -0500
commit6de53b631fcdb96d72639b6d2db3592d5fa8498d (patch)
tree9a93d868f5f434a4898f212cb6bd53e65ca49ce0 /cli/lsp/documents.rs
parent3db18bf9e6466c74efd9052df4d372ea0b581154 (diff)
refactor: use `once_cell` instead of `lazy_static` (#13135)
Diffstat (limited to 'cli/lsp/documents.rs')
-rw-r--r--cli/lsp/documents.rs48
1 files changed, 34 insertions, 14 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index 9e4a74ff2..1125d381f 100644
--- a/cli/lsp/documents.rs
+++ b/cli/lsp/documents.rs
@@ -24,6 +24,7 @@ use deno_core::url;
use deno_core::ModuleSpecifier;
use deno_graph::Module;
use lspower::lsp;
+use once_cell::sync::Lazy;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
@@ -35,20 +36,39 @@ use std::str::FromStr;
use std::sync::Arc;
use std::time::SystemTime;
-lazy_static::lazy_static! {
- static ref JS_HEADERS: HashMap<String, String> = ([
- ("content-type".to_string(), "application/javascript".to_string())
- ]).iter().cloned().collect();
- static ref JSX_HEADERS: HashMap<String, String> = ([
- ("content-type".to_string(), "text/jsx".to_string())
- ]).iter().cloned().collect();
- static ref TS_HEADERS: HashMap<String, String> = ([
- ("content-type".to_string(), "application/typescript".to_string())
- ]).iter().cloned().collect();
- static ref TSX_HEADERS: HashMap<String, String> = ([
- ("content-type".to_string(), "text/tsx".to_string())
- ]).iter().cloned().collect();
-}
+static JS_HEADERS: Lazy<HashMap<String, String>> = Lazy::new(|| {
+ ([(
+ "content-type".to_string(),
+ "application/javascript".to_string(),
+ )])
+ .iter()
+ .cloned()
+ .collect()
+});
+
+static JSX_HEADERS: Lazy<HashMap<String, String>> = Lazy::new(|| {
+ ([("content-type".to_string(), "text/jsx".to_string())])
+ .iter()
+ .cloned()
+ .collect()
+});
+
+static TS_HEADERS: Lazy<HashMap<String, String>> = Lazy::new(|| {
+ ([(
+ "content-type".to_string(),
+ "application/typescript".to_string(),
+ )])
+ .iter()
+ .cloned()
+ .collect()
+});
+
+static TSX_HEADERS: Lazy<HashMap<String, String>> = Lazy::new(|| {
+ ([("content-type".to_string(), "text/tsx".to_string())])
+ .iter()
+ .cloned()
+ .collect()
+});
/// The default parser from `deno_graph` does not include the configuration
/// options we require here, and so implementing an empty struct that provides