use std::path::{Path, PathBuf};
use tower_lsp::lsp_types::Url;
pub use leekscript_rs::line_col_utf16_to_byte;
#[must_use]
pub fn parse_uri(uri: &str) -> Option<Url> {
Url::parse(uri).ok()
}
pub fn uri_to_path(uri: &str) -> Option<PathBuf> {
let url = parse_uri(uri)?;
if url.scheme() != "file" {
return None;
}
url.to_file_path().ok()
}
#[allow(dead_code)]
#[must_use]
pub fn path_to_uri(path: &Path) -> Option<Url> {
Url::from_file_path(path).ok()
}
pub fn apply_content_changes(
state: &crate::document::DocumentState,
content_changes: Vec<tower_lsp::lsp_types::TextDocumentContentChangeEvent>,
) -> (String, Option<leekscript_rs::TextEdit>) {
leekscript_rs::apply_content_changes(state, content_changes)
}