|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from abc import abstractmethod |
4 | | -from collections.abc import AsyncGenerator, Sequence |
| 4 | +from collections.abc import AsyncGenerator |
5 | 5 | from contextlib import asynccontextmanager |
6 | 6 | from pathlib import Path |
7 | 7 | from typing import Protocol, runtime_checkable |
@@ -37,12 +37,6 @@ def open_files(self, *file_paths: AnyPath) -> AsyncGenerator[None]: |
37 | 37 | @abstractmethod |
38 | 38 | async def request[R](self, req: Request, schema: type[Response[R]]) -> R: ... |
39 | 39 |
|
40 | | - async def file_request[R]( |
41 | | - self, req: Request, schema: type[Response[R]], file_paths: Sequence[AnyPath] |
42 | | - ): |
43 | | - async with self.open_files(*file_paths): |
44 | | - return await self.request(req, schema) |
45 | | - |
46 | 40 | @abstractmethod |
47 | 41 | async def notify(self, msg: Notification) -> None: ... |
48 | 42 |
|
@@ -77,3 +71,10 @@ def as_uri(self, file_path: AnyPath) -> str: |
77 | 71 | def from_uri(self, uri: str) -> Path: |
78 | 72 | """Convert a URI to an absolute path.""" |
79 | 73 | return from_local_uri(uri) |
| 74 | + |
| 75 | + def read_file(self, file_path: AnyPath) -> str: |
| 76 | + """Read the content of a file in the workspace.""" |
| 77 | + |
| 78 | + uri = self.as_uri(file_path) |
| 79 | + abs_file_path = self.from_uri(uri) |
| 80 | + return abs_file_path.read_text() |
0 commit comments