Skip to content

Commit 269c2bc

Browse files
committed
discovering now uses the robot workspace functionality to load documents
1 parent db771df commit 269c2bc

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

robotcode/language_server/robotframework/parts/discovering.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@
1010
from ....utils.async_tools import run_in_thread
1111
from ....utils.logging import LoggingDescriptor
1212
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
2114
from .protocol_part import RobotLanguageServerProtocolPart
2215

2316
if TYPE_CHECKING:
@@ -59,18 +52,6 @@ class DiscoveringProtocolPart(RobotLanguageServerProtocolPart):
5952
def __init__(self, parent: RobotLanguageServerProtocol) -> None:
6053
super().__init__(parent)
6154

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-
7455
def get_tests_from_workspace_threading(self, paths: Optional[List[str]]) -> List[TestItem]:
7556
from robot.output.logger import LOGGER
7657
from robot.running import TestCase, TestSuite
@@ -205,5 +186,9 @@ async def get_tests_from_document(
205186
self.get_tests_from_document_threading,
206187
text_document,
207188
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+
),
209194
)

0 commit comments

Comments
 (0)