55//
66//
77
8+ use aether_path:: FilePath ;
89use anyhow:: anyhow;
910use serde_json:: Value ;
1011use stdext:: result:: ResultExt ;
@@ -184,7 +185,7 @@ pub(crate) fn handle_folding_range(
184185 state : & WorldState ,
185186) -> LspResult < Option < Vec < FoldingRange > > > {
186187 let uri = & params. text_document . uri ;
187- let document = state. get_document ( uri) ?;
188+ let document = state. get_document ( & FilePath :: from_url ( uri) ) ?;
188189 match folding_range ( document) {
189190 Ok ( foldings) => Ok ( Some ( foldings) ) ,
190191 Err ( err) => {
@@ -210,7 +211,7 @@ pub(crate) fn handle_completion(
210211) -> LspResult < Option < CompletionResponse > > {
211212 // Get reference to document.
212213 let uri = params. text_document_position . text_document . uri ;
213- let document = state. get_document ( & uri) ?;
214+ let document = state. get_document ( & FilePath :: from_url ( & uri) ) ?;
214215
215216 let position = params. text_document_position . position ;
216217 let point = document. tree_sitter_point_from_lsp_position ( position) ?;
@@ -243,7 +244,7 @@ pub(crate) fn handle_completion_resolve(mut item: CompletionItem) -> LspResult<C
243244#[ tracing:: instrument( level = "info" , skip_all) ]
244245pub ( crate ) fn handle_hover ( params : HoverParams , state : & WorldState ) -> LspResult < Option < Hover > > {
245246 let uri = params. text_document_position_params . text_document . uri ;
246- let document = state. get_document ( & uri) ?;
247+ let document = state. get_document ( & FilePath :: from_url ( & uri) ) ?;
247248
248249 let position = params. text_document_position_params . position ;
249250 let point = document. tree_sitter_point_from_lsp_position ( position) ?;
@@ -278,7 +279,7 @@ pub(crate) fn handle_signature_help(
278279 state : & WorldState ,
279280) -> LspResult < Option < SignatureHelp > > {
280281 let uri = params. text_document_position_params . text_document . uri ;
281- let document = state. get_document ( & uri) ?;
282+ let document = state. get_document ( & FilePath :: from_url ( & uri) ) ?;
282283
283284 let position = params. text_document_position_params . position ;
284285 let point = document. tree_sitter_point_from_lsp_position ( position) ?;
@@ -308,7 +309,7 @@ pub(crate) fn handle_goto_definition(
308309 state : & WorldState ,
309310) -> LspResult < Option < GotoDefinitionResponse > > {
310311 let uri = & params. text_document_position_params . text_document . uri ;
311- let document = state. get_document ( uri) ?;
312+ let document = state. get_document ( & FilePath :: from_url ( uri) ) ?;
312313
313314 Ok ( goto_definition ( document, params) . log_err ( ) . flatten ( ) )
314315}
@@ -318,7 +319,7 @@ pub(crate) fn handle_selection_range(
318319 params : SelectionRangeParams ,
319320 state : & WorldState ,
320321) -> LspResult < Option < Vec < SelectionRange > > > {
321- let document = state. get_document ( & params. text_document . uri ) ?;
322+ let document = state. get_document ( & FilePath :: from_url ( & params. text_document . uri ) ) ?;
322323
323324 // Get tree-sitter points to return selection ranges for
324325 let points = params
@@ -382,7 +383,7 @@ pub(crate) fn handle_statement_range(
382383 params : StatementRangeParams ,
383384 state : & WorldState ,
384385) -> LspResult < Option < StatementRangeResponse > > {
385- let document = state. get_document ( & params. text_document . uri ) ?;
386+ let document = state. get_document ( & FilePath :: from_url ( & params. text_document . uri ) ) ?;
386387 let point = document. tree_sitter_point_from_lsp_position ( params. position ) ?;
387388 statement_range ( document, point)
388389}
@@ -392,7 +393,7 @@ pub(crate) fn handle_help_topic(
392393 params : HelpTopicParams ,
393394 state : & WorldState ,
394395) -> LspResult < Option < HelpTopicResponse > > {
395- let document = state. get_document ( & params. text_document . uri ) ?;
396+ let document = state. get_document ( & FilePath :: from_url ( & params. text_document . uri ) ) ?;
396397 let point = document. tree_sitter_point_from_lsp_position ( params. position ) ?;
397398 help_topic ( point, document)
398399}
@@ -403,7 +404,7 @@ pub(crate) fn handle_indent(
403404 state : & WorldState ,
404405) -> LspResult < Option < Vec < TextEdit > > > {
405406 let ctxt = params. text_document_position ;
406- let doc = state. get_document ( & ctxt. text_document . uri ) ?;
407+ let doc = state. get_document ( & FilePath :: from_url ( & ctxt. text_document . uri ) ) ?;
407408 let point = doc. tree_sitter_point_from_lsp_position ( ctxt. position ) ?;
408409
409410 indent_edit ( doc, point. row )
@@ -416,7 +417,7 @@ pub(crate) fn handle_code_action(
416417 state : & WorldState ,
417418) -> LspResult < Option < CodeActionResponse > > {
418419 let uri = params. text_document . uri ;
419- let doc = state. get_document ( & uri) ?;
420+ let doc = state. get_document ( & FilePath :: from_url ( & uri) ) ?;
420421 let range = doc. tree_sitter_range_from_lsp_range ( params. range ) ?;
421422
422423 let code_actions = code_actions ( & uri, doc, range, & lsp_state. capabilities ) ;
0 commit comments