'Adds a line break and necessary indentation.
Appends the next token to the state and updates information necessary for
indentation.
Arguments:
dry_run: (bool) Don\'t commit whitespace changes to the FormatToken if
True.
must_split: (bool) A newline was required before this token.
Returns:
The split penalty for splitting after the current state.'

def _AddTokenOnNewline(self, dry_run, must_split):

    current = self.next_token
    previous = current.previous_token
    self.column = self._GetNewlineColumn()
    if (not dry_run):
        current.AddWhitespacePrefix(newlines_before=1, spaces=self.column)
    if (not current.is_comment):
        self.stack[(-1)].last_space = self.column
    self.start_of_line_level = self.paren_level
    self.lowest_level_on_line = self.paren_level
    if (previous.OpensScope() or (previous.is_comment and (previous.previous_token is not None) and previous.previous_token.OpensScope())):
        self.stack[(-1)].closing_scope_indent = max(0, (self.stack[(-1)].indent - style.Get('CONTINUATION_INDENT_WIDTH')))
        split_before_closing_bracket = True
        if style.Get('COALESCE_BRACKETS'):
            split_before_closing_bracket = False
        self.stack[(-1)].split_before_closing_bracket = split_before_closing_bracket
    penalty = current.split_penalty
    if must_split:
        return penalty
    if (previous.is_pseudo_paren and (previous.value == '(')):
        penalty += 50
    if (current.value not in {'if', 'for'}):
        last = self.stack[(-1)]
        last.num_line_splits += 1
        penalty += (style.Get('SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT') * last.num_line_splits)
    if (current.OpensScope() and previous.OpensScope()):
        pprev = previous.previous_token
        if ((not pprev) or (not pprev.is_name)):
            penalty += 10
    return (penalty + 10)
