diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-08-24 01:21:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-24 01:21:21 +0100 |
commit | 2ab4afc6b8e90f1315e0727c9b9c714c3667dc45 (patch) | |
tree | 05f07ba22d5d4a5f5120ab988320ad88ea20d542 /tests/util/server/src/fs.rs | |
parent | bbd3a7e637b0223647405adf76b23092ab957157 (diff) |
refactor(lsp): changes for lsp_types 0.97.0 (#25169)
Diffstat (limited to 'tests/util/server/src/fs.rs')
-rw-r--r-- | tests/util/server/src/fs.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/util/server/src/fs.rs b/tests/util/server/src/fs.rs index fc27e4485..47d0d61fa 100644 --- a/tests/util/server/src/fs.rs +++ b/tests/util/server/src/fs.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use lsp_types::Uri; use pretty_assertions::assert_eq; use std::borrow::Cow; use std::collections::HashSet; @@ -10,12 +11,13 @@ use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::process::Command; +use std::str::FromStr; use std::sync::Arc; use anyhow::Context; -use lsp_types::Url; use serde::de::DeserializeOwned; use serde::Serialize; +use url::Url; use crate::assertions::assert_wildcard_match; use crate::testdata_path; @@ -52,14 +54,22 @@ impl PathRef { PathRef(self.as_path().parent().unwrap().to_path_buf()) } - pub fn uri_dir(&self) -> Url { + pub fn url_dir(&self) -> Url { Url::from_directory_path(self.as_path()).unwrap() } - pub fn uri_file(&self) -> Url { + pub fn url_file(&self) -> Url { Url::from_file_path(self.as_path()).unwrap() } + pub fn uri_dir(&self) -> Uri { + Uri::from_str(self.url_dir().as_str()).unwrap() + } + + pub fn uri_file(&self) -> Uri { + Uri::from_str(self.url_file().as_str()).unwrap() + } + pub fn as_path(&self) -> &Path { self.0.as_path() } @@ -444,10 +454,14 @@ impl TempDir { })) } - pub fn uri(&self) -> Url { + pub fn url(&self) -> Url { Url::from_directory_path(self.path()).unwrap() } + pub fn uri(&self) -> Uri { + Uri::from_str(self.url().as_str()).unwrap() + } + pub fn path(&self) -> &PathRef { self.0.path() } |