aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL')
-rw-r--r--pyGHDL/libghdl/errorout_memory.py2
-rw-r--r--pyGHDL/lsp/document.py3
-rw-r--r--pyGHDL/lsp/vhdl_ls.py4
-rw-r--r--pyGHDL/lsp/workspace.py27
4 files changed, 25 insertions, 11 deletions
diff --git a/pyGHDL/libghdl/errorout_memory.py b/pyGHDL/libghdl/errorout_memory.py
index bf60c53bb..9f75d0331 100644
--- a/pyGHDL/libghdl/errorout_memory.py
+++ b/pyGHDL/libghdl/errorout_memory.py
@@ -122,7 +122,7 @@ def Get_Error_Message(Idx: ErrorIndex) -> str:
:param Idx: Index from 1 to ``Nbr_Messages`` See :func:`Get_Nbr_Messages`.
:return: Error message.
"""
- return _Get_Error_Message(Idx).decode("utf-8")
+ return _Get_Error_Message(Idx).decode("iso-8859-1")
@export
diff --git a/pyGHDL/lsp/document.py b/pyGHDL/lsp/document.py
index dd7f694a1..2656606c6 100644
--- a/pyGHDL/lsp/document.py
+++ b/pyGHDL/lsp/document.py
@@ -35,9 +35,8 @@ class Document(object):
self._tree = nodes.Null_Iir
@staticmethod
- def load(source, dirname, filename):
+ def load(src_bytes, dirname, filename):
# Write text to file buffer.
- src_bytes = source.encode(Document.encoding, "replace")
src_len = len(src_bytes)
buf_len = src_len + Document.initial_gap_size
fileid = name_table.Get_Identifier(filename)
diff --git a/pyGHDL/lsp/vhdl_ls.py b/pyGHDL/lsp/vhdl_ls.py
index 8207c9e28..dea9542b9 100644
--- a/pyGHDL/lsp/vhdl_ls.py
+++ b/pyGHDL/lsp/vhdl_ls.py
@@ -16,6 +16,7 @@ class VhdlLanguageServer(object):
"initialized": self.initialized,
"shutdown": self.shutdown,
"$/setTraceNotification": self.setTraceNotification,
+ "$/setTrace": self.setTrace,
"textDocument/didOpen": self.textDocument_didOpen,
"textDocument/didChange": self.textDocument_didChange,
"textDocument/didClose": self.textDocument_didClose,
@@ -39,6 +40,9 @@ class VhdlLanguageServer(object):
def setTraceNotification(self, value):
pass
+ def setTrace(self, value):
+ pass
+
def capabilities(self):
server_capabilities = {
"textDocumentSync": {
diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py
index 54fa17ce6..c3a575e5d 100644
--- a/pyGHDL/lsp/workspace.py
+++ b/pyGHDL/lsp/workspace.py
@@ -96,7 +96,9 @@ class Workspace(object):
# We assume the path is correct.
path = lsp.path_from_uri(doc_uri)
if source is None:
- source = open(path).read()
+ source = open(path, "rb").read()
+ else:
+ source = source.encode(document.Document.encoding, "replace")
sfe = document.Document.load(source, os.path.dirname(path), os.path.basename(path))
return self._create_document(doc_uri, sfe)
@@ -152,7 +154,7 @@ class Workspace(object):
absname = os.path.join(self._root_path, name)
# Create a document for this file.
try:
- fd = open(absname)
+ fd = open(absname, "rb")
sfe = document.Document.load(fd.read(), self._root_path, name)
fd.close()
except OSError as err:
@@ -349,7 +351,8 @@ class Workspace(object):
self._docs[doc_uri].check_document(source)
def rm_document(self, doc_uri):
- pass
+ # Clear diagnostics as it's not done automatically.
+ self.publish_diagnostics(doc_uri, [])
def apply_edit(self, edit):
return self._server.request("workspace/applyEdit", {"edit": edit})
@@ -473,12 +476,20 @@ class Workspace(object):
while lists.Is_Valid(byref(deps_it)):
el = lists.Get_Element(byref(deps_it))
if nodes.Get_Kind(el) == nodes.Iir_Kind.Design_Unit:
- if res.get(el, None):
- res[el].append(units)
- else:
- res[el] = [units]
+ ent = el
+ elif nodes.Get_Kind(el) == nodes.Iir_Kind.Entity_Aspect_Entity:
+ # Extract design unit from entity aspect
+ # Do not care about the architecture.
+ ent = nodes.Get_Entity_Name(el)
+ ent = nodes.Get_Named_Entity(ent)
+ ent = nodes.Get_Design_Unit(ent)
+ else:
+ assert False, pyutils.kind_image(nodes.Get_Kind(el))
+ assert nodes.Get_Kind(ent) == nodes.Iir_Kind.Design_Unit
+ if res.get(ent, None):
+ res[ent].append(units)
else:
- assert False
+ res[ent] = [units]
lists.Next(byref(deps_it))
units = nodes.Get_Chain(units)
files = nodes.Get_Chain(files)