Refactoring: Improve class naming and consolidate text coordinate representations

* Rename TextCoordinates -> TextCoordinateProvider
* Consolidate ls_util.LineCol, text_utils.TextCoords -> ls_util.TextCoordinates
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-09-23 14:03:42 +02:00
1 parent fa79a2260f
commit 26939c447f
4 files changed
+63 -80

No files matched your search

+4 -4
View File
@@ -22,7 +22,7 @@ import sys
import time
import solidlsp # noqa: F401 # imported first: solidlsp must resolve before serena.util.text_utils (known circular-import window)
from solidlsp.ls_utils import TextCoordinates, TextUtils
from solidlsp.ls_utils import TextCoordinateProvider, TextUtils
def generate_synthetic_content(num_lines: int, match_identifier: str, match_frequency: float = 0.15) -> str:
@@ -67,12 +67,12 @@ def resolve_before(content: str, compiled_pattern: re.Pattern) -> list[tuple[int
def resolve_after(content: str, compiled_pattern: re.Pattern) -> list[tuple[int, int]]:
"""Resolves line coordinates the way this PR proposes (cached line starts + binary search)."""
coordinates = TextCoordinates(content)
coordinates = TextCoordinateProvider(content)
results = []
for match in compiled_pattern.finditer(content):
start_pos, end_pos = match.start(), match.end()
s = coordinates.line_col_at_index(start_pos).line
end_loc = coordinates.line_col_at_index(end_pos)
s = coordinates.compute_coordinates(start_pos).line
end_loc = coordinates.compute_coordinates(end_pos)
e = end_loc.line
if e > s and end_loc.col == 0:
e -= 1