From 70d549a6ba3c5e0ce07d817c596dc396c730a6d2 Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Fri, 30 Jun 2023 18:01:42 +0800 Subject: [PATCH] Update pygls version --- hdl_checker/lsp.py | 24 +++++++++++------------- hdl_checker/server.py | 2 +- hdl_checker/tests/test_lsp.py | 4 ++-- setup.py | 7 ++----- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/hdl_checker/lsp.py b/hdl_checker/lsp.py index fae18ad..b38b122 100644 --- a/hdl_checker/lsp.py +++ b/hdl_checker/lsp.py @@ -23,19 +23,17 @@ from tempfile import mkdtemp from typing import Any, Callable, Iterable, List, Optional, Set, Tuple, Union -from pygls.features import ( - DEFINITION, - HOVER, +from pygls.server import LanguageServer +from lsprotocol.types import ( + TEXT_DOCUMENT_DEFINITION, + TEXT_DOCUMENT_HOVER, INITIALIZE, INITIALIZED, - REFERENCES, + TEXT_DOCUMENT_REFERENCES, TEXT_DOCUMENT_DID_CHANGE, TEXT_DOCUMENT_DID_OPEN, TEXT_DOCUMENT_DID_SAVE, WORKSPACE_DID_CHANGE_CONFIGURATION, -) -from pygls.server import LanguageServer -from pygls.types import ( ClientCapabilities, Diagnostic, DiagnosticSeverity, @@ -167,7 +165,7 @@ def __init__(self, *args, **kwargs) -> None: self.onConfigUpdate(None) self._global_diags: Set[CheckerDiagnostic] = set() self.initialization_options: Optional[Any] = None - self.client_capabilities: Optional[ClientCapabilities] = None + self._client_capabilities: Optional[ClientCapabilities] = None @property def checker(self) -> Server: @@ -353,7 +351,7 @@ def _use_markdown_for_hover(self): try: return ( MarkupKind.Markdown.value - in self.client_capabilities.textDocument.hover.contentFormat + in self._client_capabilities.textDocument.hover.contentFormat ) except AttributeError: return False @@ -536,7 +534,7 @@ def setupLanguageServerFeatures(server: HdlCheckerLanguageServer) -> None: @server.feature(INITIALIZE) def initialize(self: HdlCheckerLanguageServer, params: InitializeParams) -> None: options = params.initializationOptions - self.client_capabilities = params.capabilities + self._client_capabilities = params.capabilities self.initialization_options = options @server.feature(INITIALIZED) @@ -570,17 +568,17 @@ def didChangeConfiguration( ) -> None: self.onConfigUpdate(settings) - @server.feature(HOVER) + @server.feature(TEXT_DOCUMENT_HOVER) def onHover(self: HdlCheckerLanguageServer, params: HoverParams) -> Optional[Hover]: return self.hover(params) - @server.feature(REFERENCES) + @server.feature(TEXT_DOCUMENT_REFERENCES) def onReferences( self: HdlCheckerLanguageServer, params: ReferenceParams ) -> Optional[List[Location]]: return self.references(params) - @server.feature(DEFINITION) + @server.feature(TEXT_DOCUMENT_DEFINITION) def onDefinition( self: HdlCheckerLanguageServer, params: TextDocumentPositionParams ) -> Optional[List[Location]]: diff --git a/hdl_checker/server.py b/hdl_checker/server.py index 7c1ee94..99f1a4b 100755 --- a/hdl_checker/server.py +++ b/hdl_checker/server.py @@ -221,7 +221,7 @@ def _watchPidWrapper(): if args.lsp: stdin, stdout = _binaryStdio() - server = lsp.HdlCheckerLanguageServer() + server = lsp.HdlCheckerLanguageServer("hdl_checker", version) lsp.setupLanguageServerFeatures(server) server.start_io(stdin=stdin, stdout=stdout) else: diff --git a/hdl_checker/tests/test_lsp.py b/hdl_checker/tests/test_lsp.py index 8388e6e..4d83f49 100644 --- a/hdl_checker/tests/test_lsp.py +++ b/hdl_checker/tests/test_lsp.py @@ -507,7 +507,7 @@ def test_ReportBuildSequencePlain(self): ) # pylint: disable=invalid-name def test_ReportBuildSequenceFallback(self): _logger.info("#" * 100) - with patch.object(self.server, "client_capabilities", None): + with patch.object(self.server, "_client_capabilities", None): self.runTestBuildSequenceTable(tablefmt="plain") @patch( @@ -518,7 +518,7 @@ def test_ReportBuildSequenceMarkdown(self): _logger.info("#" * 100) with patch.object( self.server, - "client_capabilities", + "_client_capabilities", ClientCapabilities( text_document=TextDocumentClientCapabilities( synchronization=None, diff --git a/setup.py b/setup.py index 4730e16..d7a37b3 100755 --- a/setup.py +++ b/setup.py @@ -56,14 +56,11 @@ 'backports.functools_lru_cache; python_version<"3.2"', 'bottle>=0.12.9', 'enum34>=1.1.6; python_version<"3.3"', - 'future>=0.14.0', - 'futures; python_version<"3.2"', - 'prettytable>=0.7.2', - 'pygls==0.9.1', + 'pygls>0.9.1', 'requests>=2.20.0', 'six>=1.10.0', 'tabulate>=0.8.5', - 'typing>=3.7.4', + 'typing>=3.7.4; python_version<"3.5"', 'waitress>=0.9.0', ], cmdclass = versioneer.get_cmdclass(), entry_points = {