def obsolete_dependent_units(self, unit, antideps): """Obsolete units that depends of :param unit:""" udeps = antideps.get(unit, None) if udeps is None: # There are no units. return # Avoid infinite recursion antideps[unit] = None for un in udeps: log.debug("obsolete %d %s", un, pyutils.name_image(nodes.Get_Identifier(un))) # Recurse self.obsolete_dependent_units(un, antideps) if nodes.Set_Date_State(un) == nodes.Date_State.Disk: # Already obsolete! continue # FIXME: just de-analyze ? nodes.Set_Date_State(un, nodes.Date_State.Disk) sem_lib.Free_Dependence_List(un) loc = nodes.Get_Location(un) fil = files_map.Location_To_File(loc) pos = files_map.Location_File_To_Pos(loc, fil) line = files_map.Location_File_To_Line(loc, fil) col = files_map.Location_File_Line_To_Offset(loc, fil, line) nodes.Set_Design_Unit_Source_Pos(un, pos) nodes.Set_Design_Unit_Source_Line(un, line) nodes.Set_Design_Unit_Source_Col(un, col)
def parse(cls, node: Iir) -> "Position": """Return the source code position of a IIR node.""" if node == nodes.Null_Iir: raise ValueError( "Position.parse(): Parameter 'node' must not be 'Null_iir'.") location = nodes.Get_Location(node) file = files_map.Location_To_File(location) fileNameId = files_map.Get_File_Name(file) fileName = name_table.Get_Name_Ptr(fileNameId) line = files_map.Location_File_To_Line(location, file) column = files_map.Location_File_Line_To_Offset(location, file, line) return cls(Path(fileName), line, column)
def declaration_to_location(self, decl): "Convert declaration :param decl: to an LSP Location" decl_loc = nodes.Get_Location(decl) if decl_loc == std_package.Std_Location.value: # There is no real file for the std.standard package. return None if decl_loc == libraries.Library_Location.value: # Libraries declaration are virtual. return None fe = files_map.Location_To_File(decl_loc) doc = self.sfe_to_document(fe) res = {"uri": doc.uri} 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)), } return res