<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _update_extent(self):
 """Updates the extent of the element being altered by this operation to include the code that has changed."""

        #For new instances, their length is being updated by the module
        #updater and will include *all* statements, so we don't want to
        #keep changing the endpoints.
        if self.bar_extent:
            return
            
        original = self.element.end
        if self.mode == "insert":
            #The end value needs to increase by the length of the current
            #statement being executed.
            self.element.end += self.curlength
        elif self.mode == "delete":
            #Reduce end by statement length
            self.element.end -= self.curlength
        elif self.mode == "replace":
            #Check whether we are currently doing the delete portion of the
            #replacement or the insert portion.
            if self.state[0] is None:
                self.element.end -= self.curlength
            else:
                self.element.end += self.curlength

        #Keep track of the total effect of all statements in this operation
        #so that it is easy to update the module once they are all done.
        self.length += self.element.end - original