Exemplo n.º 1
0
 def _get_statement_for_position(self, node, pos):
     for c in node.children:
         # sorted here, because the end_pos property depends on the last child having the last position,
         # there seems to be a problem with jedi, where the children of a node are not always in the right order
         if isinstance(c, tree.Class):
             c.children.sort(key=lambda x: x.end_pos)
         if c.start_pos <= pos <= c.end_pos:
             if c.type not in ('decorated', 'simple_stmt', 'suite') \
                     and not isinstance(c, (tree.Flow, tree.ClassOrFunc)):
                 return c
             else:
                 try:
                     return jedi_utils.get_statement_of_position(c, pos)
                 except AttributeError:
                     traceback.print_exc()
     return None
Exemplo n.º 2
0
 def _get_statement_for_position(self, node, pos):
     for c in node.children:
         # sorted here, because the end_pos property depends on the last child having the last position,
         # there seems to be a problem with jedi, where the children of a node are not always in the right order
         if isinstance(c, tree.Class):
             c.children.sort(key=lambda x: x.end_pos)
         if c.start_pos <= pos <= c.end_pos:
             if c.type not in ("decorated", "simple_stmt",
                               "suite") and not isinstance(
                                   c, (tree.Flow, tree.ClassOrFunc)):
                 return c
             else:
                 try:
                     return jedi_utils.get_statement_of_position(c, pos)
                 except AttributeError as e:
                     logger.exception("Could not get statement of position",
                                      exc_info=e)
     return None