Skip to content

Commit

Permalink
Update pygls
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux#1431
  • Loading branch information
treiher committed Nov 14, 2023
1 parent f03f276 commit 8dccac9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions rflx/ls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_lsp_severity(severity: error.Severity) -> Optional[DiagnosticSeverity]:


def initialize_lexer(language_server: RecordFluxLanguageServer, uri: str) -> LSLexer:
document = language_server.workspace.get_document(uri)
document = language_server.workspace.get_text_document(uri)
lexer = LSLexer(language_server.models[Path(document.path).parent].ls_model)
lexer.tokenize(document.source, document.path)
return lexer
Expand Down Expand Up @@ -142,7 +142,7 @@ def update(self, document_uri: str) -> None:
self._error = error.RecordFluxError()

for path in workspace_files:
document = self.workspace.get_document(path.as_uri())
document = self.workspace.get_text_document(path.as_uri())
self._document_state[document.uri] = hash(document.source)
try:
parser.parse_string(document.source, path)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run(self) -> None:
"importlib_resources >=6, <7", # TODO(eng/recordflux/RecordFlux#1359): Remove
"pydantic >=1, <2",
"pydotplus >=2, <3",
"pygls >=1.0, <1.1",
"pygls >=1.1, <1.2",
"ruamel.yaml >=0.17, <0.18",
"z3-solver >=4, <5",
],
Expand Down
41 changes: 22 additions & 19 deletions tests/unit/ls/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
SemanticTokensParams,
TextDocumentIdentifier,
TextDocumentItem,
TextDocumentSyncKind,
VersionedTextDocumentIdentifier,
WorkspaceFolder,
)
Expand Down Expand Up @@ -62,11 +63,11 @@
@pytest.fixture()
def language_server() -> server.RecordFluxLanguageServer:
language_server = server.RecordFluxLanguageServer()
language_server.lsp.workspace = Workspace(
language_server.lsp._workspace = Workspace( # noqa: SLF001
DATA_DIR.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[WorkspaceFolder(DATA_DIR.absolute().as_uri(), "data")],
) # type: ignore[no-untyped-call]
)
return language_server


Expand Down Expand Up @@ -147,11 +148,11 @@ def test_update_directory(tmp_path: Path) -> None:
(tmp_path / "directory.rflx").mkdir()

ls = server.RecordFluxLanguageServer()
ls.lsp.workspace = Workspace(
ls.lsp._workspace = Workspace( # noqa: SLF001
tmp_path.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[WorkspaceFolder(tmp_path.absolute().as_uri(), "tmp_path")],
) # type: ignore[no-untyped-call]
)
document_uri = (tmp_path / "message.rflx").absolute().as_uri()
ls.update(document_uri)

Expand All @@ -162,12 +163,14 @@ def test_update_no_folders(tmp_path: Path) -> None:
document_uri = document.absolute().as_uri()

ls = server.RecordFluxLanguageServer()
ls.lsp.workspace = Workspace(
ls.lsp._workspace = Workspace( # noqa: SLF001
tmp_path.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[],
) # type: ignore[no-untyped-call]
ls.lsp.workspace.put_document(TextDocumentItem(document_uri, "", 0, ""))
)
ls.lsp._workspace.put_document( # type: ignore[no-untyped-call] # noqa: SLF001
TextDocumentItem(document_uri, "", 0, ""),
)
ls.update(document_uri)


Expand All @@ -180,11 +183,11 @@ def test_update_error_in_parser(tmp_path: Path, monkeypatch: pytest.MonkeyPatch)
document_uri = document.absolute().as_uri()

ls = server.RecordFluxLanguageServer()
ls.lsp.workspace = Workspace(
ls.lsp._workspace = Workspace( # noqa: SLF001
tmp_path.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[WorkspaceFolder(tmp_path.absolute().as_uri(), "tmp_path")],
) # type: ignore[no-untyped-call]
)
ls.update(document_uri)

assert published_diagnostics == [
Expand Down Expand Up @@ -217,11 +220,11 @@ def test_update_error_in_unchecked_model(
document_uri = document.absolute().as_uri()

ls = server.RecordFluxLanguageServer()
ls.lsp.workspace = Workspace(
ls.lsp._workspace = Workspace( # noqa: SLF001
tmp_path.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[WorkspaceFolder(tmp_path.absolute().as_uri(), "tmp_path")],
) # type: ignore[no-untyped-call]
)
ls.update(document_uri)

assert published_diagnostics == [
Expand Down Expand Up @@ -249,11 +252,11 @@ def test_verify(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
document_uri = document.absolute().as_uri()

ls = server.RecordFluxLanguageServer()
ls.lsp.workspace = Workspace(
ls.lsp._workspace = Workspace( # noqa: SLF001
tmp_path.absolute().as_uri(),
None,
TextDocumentSyncKind.None_,
workspace_folders=[WorkspaceFolder(tmp_path.absolute().as_uri(), "tmp_path")],
) # type: ignore[no-untyped-call]
)
ls.update(document_uri)
ls.verify(document_uri)

Expand Down

0 comments on commit 8dccac9

Please sign in to comment.