|
10 | 10 | from ....utils.async_tools import run_in_thread
|
11 | 11 | from ....utils.logging import LoggingDescriptor
|
12 | 12 | from ....utils.uri import Uri
|
13 |
| -from ...common.lsp_types import ( |
14 |
| - DocumentUri, |
15 |
| - Model, |
16 |
| - Position, |
17 |
| - Range, |
18 |
| - TextDocumentIdentifier, |
19 |
| -) |
20 |
| -from ...common.text_document import TextDocument |
| 13 | +from ...common.lsp_types import Model, Position, Range, TextDocumentIdentifier |
21 | 14 | from .protocol_part import RobotLanguageServerProtocolPart
|
22 | 15 |
|
23 | 16 | if TYPE_CHECKING:
|
@@ -59,18 +52,6 @@ class DiscoveringProtocolPart(RobotLanguageServerProtocolPart):
|
59 | 52 | def __init__(self, parent: RobotLanguageServerProtocol) -> None:
|
60 | 53 | super().__init__(parent)
|
61 | 54 |
|
62 |
| - def get_document(self, uri: DocumentUri) -> TextDocument: |
63 |
| - from robot.utils import FileReader |
64 |
| - |
65 |
| - result = self.parent.documents.get(uri, None) |
66 |
| - if result is not None: |
67 |
| - return result |
68 |
| - |
69 |
| - with FileReader(Uri(uri).to_path()) as reader: |
70 |
| - text = str(reader.read()) |
71 |
| - |
72 |
| - return TextDocument(document_uri=uri, language_id="robotframework", version=None, text=text) |
73 |
| - |
74 | 55 | def get_tests_from_workspace_threading(self, paths: Optional[List[str]]) -> List[TestItem]:
|
75 | 56 | from robot.output.logger import LOGGER
|
76 | 57 | from robot.running import TestCase, TestSuite
|
@@ -205,5 +186,9 @@ async def get_tests_from_document(
|
205 | 186 | self.get_tests_from_document_threading,
|
206 | 187 | text_document,
|
207 | 188 | id,
|
208 |
| - await self.parent.documents_cache.get_model(self.get_document(text_document.uri)), |
| 189 | + await self.parent.documents_cache.get_model( |
| 190 | + self.parent.robot_workspace.get_or_open_document( |
| 191 | + Uri(text_document.uri).to_path(), language_id="robotframework" |
| 192 | + ) |
| 193 | + ), |
209 | 194 | )
|
0 commit comments