diff options
author | Henning Holm <git@henningholm.de> | 2020-07-26 17:23:36 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2020-07-30 05:13:09 +0200 |
commit | 574ac8b17b41462bc110de57934ce17ba9837581 (patch) | |
tree | 7f756c91e0ec96d9bda5e3f5c071ddf25f01e0d1 | |
parent | 1b789a5fb8b11e7c378731589d9cb54a8f53c27f (diff) | |
download | ghdl-574ac8b17b41462bc110de57934ce17ba9837581.tar.gz ghdl-574ac8b17b41462bc110de57934ce17ba9837581.tar.bz2 ghdl-574ac8b17b41462bc110de57934ce17ba9837581.zip |
ghdl-ls: Fix exception crashing language server
Previously, the language server crashed on unhandled
symbols with an exception. As ignoring unhandled symbols
should be fine, logging this as an error to the logger
results in a much better user experience.
This fixes #1410
-rw-r--r-- | python/vhdl_langserver/symbols.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/python/vhdl_langserver/symbols.py b/python/vhdl_langserver/symbols.py index b39827bed..5d3c35dd9 100644 --- a/python/vhdl_langserver/symbols.py +++ b/python/vhdl_langserver/symbols.py @@ -1,3 +1,4 @@ +import logging import libghdl.thin.name_table as name_table import libghdl.thin.files_map as files_map import libghdl.thin.vhdl.pyutils as pyutils @@ -7,6 +8,8 @@ import libghdl.thin.vhdl.elocations as elocations from . import lsp +log = logging.getLogger(__name__) + SYMBOLS_MAP = { nodes.Iir_Kind.Package_Declaration: {'kind': lsp.SymbolKind.Package, 'detail': '(declaration)'}, nodes.Iir_Kind.Package_Body: {'kind': lsp.SymbolKind.Package, 'detail': '(body)'}, @@ -85,7 +88,8 @@ def get_symbols(fe, n): return get_symbols(fe, nodes.Get_Library_Unit(n)) m = SYMBOLS_MAP.get(k, None) if m is None: - raise AssertionError("get_symbol: unhandled {}".format(pyutils.kind_image(k))) + log.error("get_symbol: unhandled {}".format(pyutils.kind_image(k))) + return None kind = m['kind'] if kind is None: return None |