diff options
author | umarcor <unai.martinezcorral@ehu.eus> | 2021-08-23 21:20:25 +0200 |
---|---|---|
committer | umarcor <unai.martinezcorral@ehu.eus> | 2021-08-23 21:20:25 +0200 |
commit | a3255c69df60fee697e1ee546052a8abe86fb4ff (patch) | |
tree | 524c352b917e25f61f7c7b1aeec19bf831c41f7f /pyGHDL/lsp | |
parent | 8cf15b9abb3a197857627f55ef28111f9492d9d5 (diff) | |
download | ghdl-a3255c69df60fee697e1ee546052a8abe86fb4ff.tar.gz ghdl-a3255c69df60fee697e1ee546052a8abe86fb4ff.tar.bz2 ghdl-a3255c69df60fee697e1ee546052a8abe86fb4ff.zip |
black: rerun, to pick pyproject settings
Diffstat (limited to 'pyGHDL/lsp')
-rw-r--r-- | pyGHDL/lsp/document.py | 13 | ||||
-rw-r--r-- | pyGHDL/lsp/lsp.py | 11 | ||||
-rw-r--r-- | pyGHDL/lsp/symbols.py | 4 | ||||
-rw-r--r-- | pyGHDL/lsp/vhdl_ls.py | 14 | ||||
-rw-r--r-- | pyGHDL/lsp/workspace.py | 44 |
5 files changed, 21 insertions, 65 deletions
diff --git a/pyGHDL/lsp/document.py b/pyGHDL/lsp/document.py index 00cb65955..dd7f694a1 100644 --- a/pyGHDL/lsp/document.py +++ b/pyGHDL/lsp/document.py @@ -124,9 +124,7 @@ class Document(object): text_bytes = text.encode(Document.encoding, "replace") - files_map_editor.Check_Buffer_Content( - self._fe, ctypes.c_char_p(text_bytes), len(text_bytes) - ) + files_map_editor.Check_Buffer_Content(self._fe, ctypes.c_char_p(text_bytes), len(text_bytes)) @staticmethod def add_to_library(tree): @@ -141,10 +139,7 @@ class Document(object): next_unit = nodes.Get_Chain(unit) nodes.Set_Chain(unit, nodes.Null_Iir) lib_unit = nodes.Get_Library_Unit(unit) - if ( - lib_unit != nodes.Null_Iir - and nodes.Get_Identifier(unit) != name_table.Null_Identifier - ): + if lib_unit != nodes.Null_Iir and nodes.Get_Identifier(unit) != name_table.Null_Identifier: # Put the unit (only if it has a library unit) in the library. libraries.Add_Design_Unit_Into_Library(unit, False) tree = nodes.Get_Design_File(unit) @@ -194,9 +189,7 @@ class Document(object): log.debug("document_symbols") if self._tree == nodes.Null_Iir: return [] - syms = symbols.get_symbols_chain( - self._fe, nodes.Get_First_Design_Unit(self._tree) - ) + syms = symbols.get_symbols_chain(self._fe, nodes.Get_First_Design_Unit(self._tree)) return self.flatten_symbols(syms, None) def position_to_location(self, position): diff --git a/pyGHDL/lsp/lsp.py b/pyGHDL/lsp/lsp.py index 49c5502e3..04d2c24ce 100644 --- a/pyGHDL/lsp/lsp.py +++ b/pyGHDL/lsp/lsp.py @@ -122,15 +122,12 @@ class LanguageProtocolServer(object): try: response = fmethod(**params) except Exception: - log.exception( - "Caught exception while handling %s with params %s:", method, params - ) + log.exception("Caught exception while handling %s with params %s:", method, params) self.show_message( MessageType.Error, - ( - "Caught exception while handling {}, " - + "see VHDL language server output for details." - ).format(method), + ("Caught exception while handling {}, " + "see VHDL language server output for details.").format( + method + ), ) response = None if tid is None: diff --git a/pyGHDL/lsp/symbols.py b/pyGHDL/lsp/symbols.py index 1d863a12f..a77d740c0 100644 --- a/pyGHDL/lsp/symbols.py +++ b/pyGHDL/lsp/symbols.py @@ -160,9 +160,7 @@ def get_symbols(fe, n): children.extend( get_symbols_chain( fe, - nodes.Get_Concurrent_Statement_Chain( - nodes.Get_Generate_Statement_Body(n) - ), + nodes.Get_Concurrent_Statement_Chain(nodes.Get_Generate_Statement_Body(n)), ) ) diff --git a/pyGHDL/lsp/vhdl_ls.py b/pyGHDL/lsp/vhdl_ls.py index 0c022c380..8207c9e28 100644 --- a/pyGHDL/lsp/vhdl_ls.py +++ b/pyGHDL/lsp/vhdl_ls.py @@ -62,15 +62,7 @@ class VhdlLanguageServer(object): } return server_capabilities - def initialize( - self, - processId, - rootPath, - capabilities, - rootUri=None, - initializationOptions=None, - **_ - ): + def initialize(self, processId, rootPath, capabilities, rootUri=None, initializationOptions=None, **_): log.debug( "Language server initialize: pid=%s uri=%s path=%s options=%s", processId, @@ -91,9 +83,7 @@ class VhdlLanguageServer(object): def textDocument_didOpen(self, textDocument=None): doc_uri = textDocument["uri"] - self.workspace.put_document( - doc_uri, textDocument["text"], version=textDocument.get("version") - ) + self.workspace.put_document(doc_uri, textDocument["text"], version=textDocument.get("version")) self.lint(doc_uri) def textDocument_didChange(self, textDocument=None, contentChanges=None, **_kwargs): diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py index 55d4cbe85..ec10d4821 100644 --- a/pyGHDL/lsp/workspace.py +++ b/pyGHDL/lsp/workspace.py @@ -96,9 +96,7 @@ class Workspace(object): path = lsp.path_from_uri(doc_uri) if source is None: source = open(path).read() - sfe = document.Document.load( - source, os.path.dirname(path), os.path.basename(path) - ) + sfe = document.Document.load(source, os.path.dirname(path), os.path.basename(path)) return self._create_document(doc_uri, sfe) def get_or_create_document(self, doc_uri): @@ -157,9 +155,7 @@ class Workspace(object): sfe = document.Document.load(fd.read(), self._root_path, name) fd.close() except OSError as err: - self._server.show_message( - lsp.MessageType.Error, "cannot load {}: {}".format(name, err.strerror) - ) + self._server.show_message(lsp.MessageType.Error, "cannot load {}: {}".format(name, err.strerror)) return doc = self.create_document_from_sfe(sfe, absname) doc.parse_document() @@ -184,9 +180,7 @@ class Workspace(object): log.info("error in project file") self._server.show_message( lsp.MessageType.Error, - "json error in project file {}:{}:{}".format( - prj_file, e.lineno, e.colno - ), + "json error in project file {}:{}:{}".format(prj_file, e.lineno, e.colno), ) f.close() @@ -207,13 +201,9 @@ class Workspace(object): log.info("Using options: %s", ghdl_opts) for opt in ghdl_opts: if not libghdl.set_option(opt): - self._server.show_message( - lsp.MessageType.Error, "error with option: {}".format(opt) - ) + self._server.show_message(lsp.MessageType.Error, "error with option: {}".format(opt)) except ProjectError as e: - self._server.show_message( - lsp.MessageType.Error, "error in project file: {}".format(e.msg) - ) + self._server.show_message(lsp.MessageType.Error, "error in project file: {}".format(e.msg)) def read_files_from_project(self): try: @@ -230,14 +220,10 @@ class Workspace(object): if lang == "vhdl": self.add_vhdl_file(name) except ProjectError as e: - self._server.show_message( - lsp.MessageType.Error, "error in project file: {}".format(e.msg) - ) + self._server.show_message(lsp.MessageType.Error, "error in project file: {}".format(e.msg)) def get_configuration(self): - self._server.configuration( - [{"scopeUri": "", "section": "vhdl.maxNumberOfProblems"}] - ) + self._server.configuration([{"scopeUri": "", "section": "vhdl.maxNumberOfProblems"}]) def gather_diagnostics(self, doc): # Gather messages (per file) @@ -302,9 +288,7 @@ class Workspace(object): # Avoid infinite recursion antideps[unit] = None for un in udeps: - log.debug( - "obsolete %d %s", un, pyutils.name_image(nodes.Get_Identifier(un)) - ) + log.debug("obsolete %d %s", un, pyutils.name_image(nodes.Get_Identifier(un))) # Recurse self.obsolete_dependent_units(un, antideps) if nodes.Get_Date_State(un) == nodes.DateStateType.Disk: @@ -376,9 +360,7 @@ class Workspace(object): ) def show_message(self, message, msg_type=lsp.MessageType.Info): - self._server.notify( - "window/showMessage", params={"type": msg_type, "message": message} - ) + self._server.notify("window/showMessage", params={"type": msg_type, "message": message}) def declaration_to_location(self, decl): """Convert declaration :param decl: to an LSP Location.""" @@ -395,9 +377,7 @@ class Workspace(object): nid = nodes.Get_Identifier(decl) res["range"] = { "start": symbols.location_to_position(fe, decl_loc), - "end": symbols.location_to_position( - fe, decl_loc + name_table.Get_Name_Length(nid) - ), + "end": symbols.location_to_position(fe, decl_loc + name_table.Get_Name_Length(nid)), } return res @@ -453,9 +433,7 @@ class Workspace(object): def create_interfaces(inters): res = [] while inters != nodes.Null_Iir: - res.append( - {"name": name_table.Get_Name_Ptr(nodes.Get_Identifier(inters))} - ) + res.append({"name": name_table.Get_Name_Ptr(nodes.Get_Identifier(inters))}) inters = nodes.Get_Chain(inters) return res |