Skip to content

Commit 4309637

Browse files
committed
temp
1 parent 324555b commit 4309637

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

sqlmesh/lsp/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff 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."""

sqlmesh/lsp/reference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
)

sqlmesh/lsp/uri.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff 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})"

0 commit comments

Comments
 (0)