Skip to content

Commit

Permalink
Removed 'convert_uri_to_slice_formated_url' ('url_to_file_path' does …
Browse files Browse the repository at this point in the history
…the same thing).
  • Loading branch information
InsertCreativityHere committed Jan 16, 2024
1 parent 95b9692 commit c59a63d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions server/src/hover.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) ZeroC, Inc.

use crate::utils::convert_uri_to_slice_formated_url;
use crate::utils::url_to_file_path;
use slicec::{
compilation_state::CompilationState,
grammar::{Element, Enum, Primitive, Symbol, TypeRef, TypeRefDefinition, Types},
Expand All @@ -14,7 +14,7 @@ pub fn try_into_hover_result(
uri: Url,
position: Position,
) -> tower_lsp::jsonrpc::Result<Hover> {
let file = convert_uri_to_slice_formated_url(uri)
let file = url_to_file_path(&uri)
.and_then(|p| state.files.get(&p))
.expect("Could not convert URI to Slice formatted URL for hover request");

Expand Down
4 changes: 2 additions & 2 deletions server/src/jump_definition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) ZeroC, Inc.

use crate::utils::convert_uri_to_slice_formated_url;
use crate::utils::url_to_file_path;
use slicec::{
compilation_state::CompilationState,
grammar::{
Expand All @@ -14,7 +14,7 @@ use slicec::{
use tower_lsp::lsp_types::{Position, Url};

pub fn get_definition_span(state: &CompilationState, uri: Url, position: Position) -> Option<Span> {
let file_path = convert_uri_to_slice_formated_url(uri)?;
let file_path = url_to_file_path(&uri)?;

// Attempt to retrieve the file from the state
let file = state.files.get(&file_path)?;
Expand Down
13 changes: 2 additions & 11 deletions server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,12 @@ where
}
}

// This helper function converts a Url from tower_lsp into a string that can be used to
// retrieve a file from the compilation state from slicec.
pub fn convert_uri_to_slice_formated_url(uri: Url) -> Option<String> {
Some(
uri.to_file_path()
.ok()?
.to_str()?
.to_owned(),
)
}

pub fn convert_slice_url_to_uri(url: &str) -> Option<Url> {
Url::from_file_path(url).ok()
}

// This helper function converts a Url from tower_lsp into a string that can be used to
// retrieve a file from the compilation state from slicec.
pub fn url_to_file_path(url: &Url) -> Option<String> {
Some(url.to_file_path().ok()?.to_str()?.to_owned())
}

0 comments on commit c59a63d

Please sign in to comment.