parameters: (
      ast, class_decls_by_fq_native, omit_self)
docstring: See module docstring.
docstring_summary: See module docstring.
docstring_tokens: See module docstring .
function: def MoveExtendFunctionsBackIntoClassesInPlace(
      ast, class_decls_by_fq_native, omit_self):
    """See module docstring."""
    extend_methods_orig_decl_indices = []
    for orig_decl_index, decl in enumerate(ast.decls):
      if decl.decltype != ast_pb2.Decl.Type.FUNC:
        continue
      if not decl.func.is_extend_method:
        continue
      if not decl.func.classmethod and not decl.func.constructor:
        assert decl.func.params, 'extended method does not have any parameters'
        assert decl.func.params[0].name.native == 'self', (
            'the first parameter of extended method `%s` is not `self`' %
            decl.func.name.native)
      if decl.func.constructor:
        extend_infix = EXTEND_INFIX_CONSTRUCTOR
      else:
        extend_infix = EXTEND_INFIX
      fq_native_from_func, method_name_from_func = decl.func.name.native.split(
          extend_infix, 1)
      target_class_decl = class_decls_by_fq_native[fq_native_from_func]
      method_decl = ast_pb2.Decl()
      method_decl.CopyFrom(decl)
      method_decl.func.name.native = method_name_from_func
      if omit_self and not decl.func.classmethod and not decl.func.constructor:
        # Explicit self is needed for the PyCLIF code generator,
        # but confuses pytype.
        del method_decl.func.params[0]
      target_class_decl.members.append(method_decl)
      extend_methods_orig_decl_indices.append(orig_decl_index)
    for orig_decl_index in reversed(extend_methods_orig_decl_indices):
      del ast.decls[orig_decl_index]
function_tokens: def MoveExtendFunctionsBackIntoClassesInPlace ( ast , class_decls_by_fq_native , omit_self ) : extend_methods_orig_decl_indices = [ ] for orig_decl_index , decl in enumerate ( ast . decls ) : if decl . decltype != ast_pb2 . Decl . Type . FUNC : continue if not decl . func . is_extend_method : continue if not decl . func . classmethod and not decl . func . constructor : assert decl . func . params , 'extended method does not have any parameters' assert decl . func . params [ 0 ] . name . native == 'self' , ( 'the first parameter of extended method `%s` is not `self`' % decl . func . name . native ) if decl . func . constructor : extend_infix = EXTEND_INFIX_CONSTRUCTOR else : extend_infix = EXTEND_INFIX fq_native_from_func , method_name_from_func = decl . func . name . native . split ( extend_infix , 1 ) target_class_decl = class_decls_by_fq_native [ fq_native_from_func ] method_decl = ast_pb2 . Decl ( ) method_decl . CopyFrom ( decl ) method_decl . func . name . native = method_name_from_func if omit_self and not decl . func . classmethod and not decl . func . constructor : # Explicit self is needed for the PyCLIF code generator, # but confuses pytype. del method_decl . func . params [ 0 ] target_class_decl . members . append ( method_decl ) extend_methods_orig_decl_indices . append ( orig_decl_index ) for orig_decl_index in reversed ( extend_methods_orig_decl_indices ) : del ast . decls [ orig_decl_index ]