diff options
Diffstat (limited to 'pyGHDL/lsp/workspace.py')
-rw-r--r-- | pyGHDL/lsp/workspace.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py index ec10d4821..c3a575e5d 100644 --- a/pyGHDL/lsp/workspace.py +++ b/pyGHDL/lsp/workspace.py @@ -54,6 +54,7 @@ class Workspace(object): # Do not consider analysis order issues. flags.Flag_Elaborate_With_Outdated.value = True libghdl.errorout.Enable_Warning(errorout.Msgid.Warnid_Unused, True) + libghdl.errorout.Enable_Warning(errorout.Msgid.Warnid_No_Assoc, True) self.read_project() self.set_options_from_project() if libghdl.analyze_init_status() != 0: @@ -95,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) @@ -151,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: @@ -348,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}) @@ -472,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) |