File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,7 +317,8 @@ def _diagnostic_to_lsp_diagnostic(
317317
318318 # Get rule definition location for diagnostics link
319319 rule_location = diagnostic .rule .get_definition_location ()
320- rule_uri = f"file://{ rule_location .file_path } #L{ rule_location .start_line } "
320+ rule_uri_wihout_extension = URI .from_path (rule_location .file_path )
321+ rule_uri = f"{ rule_uri_wihout_extension .value } #L{ rule_location .start_line } "
321322
322323 # Use URI format to create a link for "related information"
323324 return types .Diagnostic (
@@ -346,11 +347,9 @@ def _diagnostics_to_lsp_diagnostics(
346347 return lsp_diagnostics
347348
348349 @staticmethod
349- def _uri_to_path (uri : str ) -> str :
350+ def _uri_to_path (uri : str ) -> Path :
350351 """Convert a URI to a path."""
351- if uri .startswith ("file://" ):
352- return Path (uri [7 :]).resolve ().as_posix ()
353- return Path (uri ).resolve ().as_posix ()
352+ return URI (uri ).to_path ()
354353
355354 def start (self ) -> None :
356355 """Start the server with I/O transport."""
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ def get_model_definitions_for_a_path(
162162 # Check whether the path exists
163163 if not referenced_model_path .is_file ():
164164 continue
165- referenced_model_uri = f"file:// { referenced_model_path } "
165+ referenced_model_uri = URI . from_path ( referenced_model_path )
166166
167167 # Extract metadata for positioning
168168 table_meta = TokenPositionDetails .from_meta (table .this .meta )
@@ -179,7 +179,7 @@ def get_model_definitions_for_a_path(
179179
180180 references .append (
181181 Reference (
182- uri = referenced_model_uri ,
182+ uri = referenced_model_uri . value ,
183183 range = Range (start = start_pos , end = end_pos ),
184184 description = referenced_model .description ,
185185 )
Original file line number Diff line number Diff line change @@ -18,10 +18,7 @@ def __eq__(self, other: object) -> bool:
1818 if not isinstance (other , URI ):
1919 return False
2020 # Normalize paths for comparison to handle Windows paths
21- return (
22- Path (self .value .removeprefix ("file://" )).as_posix ()
23- == Path (other .value .removeprefix ("file://" )).as_posix ()
24- )
21+ return self .to_path () == other .to_path ()
2522
2623 def __repr__ (self ) -> str :
2724 return f"URI({ self .value } )"
You can’t perform that action at this time.
0 commit comments