def _extract_def(d, path): d_line, d_column = d.start_pos # use full name for import type if d.type == 'function': try: params = [p.name for p in d.params] name = d.name + '(' + ', '.join(params) + ')' except AttributeError: name = d.name else: name = d.name definition = Definition(name, d_line - 1, d_column, icon_from_typename(d.name, d.type), file_path=path) # check for methods in class or nested methods/classes if d.type == "class" or d.type == 'function': try: sub_definitions = d.defined_names() for sub_d in sub_definitions: if (d.type == 'function' and sub_d.type == 'function') or \ d.type == 'class': definition.add_child(_extract_def(sub_d, path)) except (AttributeError, IndexError): pass return definition
def to_definition(self): """ Converts the name instance to a pyqode.core.share.Definition """ icon = { Name.Type.Root: icons.ICON_MIMETYPE, Name.Type.Division: icons.ICON_DIVISION, Name.Type.Section: icons.ICON_SECTION, Name.Type.Variable: icons.ICON_VAR, Name.Type.Paragraph: icons.ICON_FUNC }[self.node_type] d = Definition(self.name, self.line, self.column, icon, self.description) for ch in self.children: d.add_child(ch.to_definition()) return d