def handle_word(self, token_text):
        if self.start_of_statement():
            # The conditional starts the statement if appropriate.
            pass
        elif self.input_wanted_newline and \
                not self.is_expression(self.flags.mode) and \
                (self.last_type != 'TK_OPERATOR' or (self.flags.last_text == '--' or self.flags.last_text == '++')) and \
                self.last_type != 'TK_EQUALS' and \
                (self.opts.preserve_newlines or self.flags.last_text != 'var'):
            self.append_newline()

        if self.flags.do_block and not self.flags.do_while:
            if token_text == 'while':
                # do {} ## while ()
                self.output_space_before_token = True
                self.append_token(token_text)
                self.output_space_before_token = True
                self.flags.do_while = True
                return
            else:
                # do {} should always have while as the next word.
                # if we don't see the expected while, recover
                self.append_newline()
                self.flags.do_block = False

        # if may be followed by else, or not
        # Bare/inline ifs are tricky
        # Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
        if self.flags.if_block:
            if token_text != 'else':
                while self.flags.mode == MODE.Statement:
                    self.restore_mode()

                self.flags.if_block = False;

        if token_text == 'case' or (token_text == 'default' and self.flags.in_case_statement):
            self.append_newline()
            if self.flags.case_body or self.opts.jslint_happy:
                self.flags.case_body = False
                self.deindent()
            self.append_token(token_text)
            self.flags.in_case = True
            self.flags.in_case_statement = True
            return

        if token_text == 'function':
            if self.flags.var_line and self.flags.last_text != '=':
                self.flags.var_line_reindented = not self.opts.keep_function_indentation

            if self.flags.last_text in ['}', ';'] or (self.just_added_newline() and not self.flags.last_text in ['{', ':', '=', ',']):
                # make sure there is a nice clean space of at least one blank line
                # before a new function definition, except in arrays
                if not self.just_added_blankline() and not self.flags.had_comment:
                    self.append_newline()
                    self.append_newline(True)

            if self.last_type == 'TK_WORD':
                if self.flags.last_text in ['get', 'set', 'new', 'return']:
                    self.output_space_before_token = True
                else:
                    self.append_newline()
            elif self.last_type == 'TK_OPERATOR' or self.flags.last_text == '=':
                # foo = function
                self.output_space_before_token = True
            elif self.is_expression(self.flags.mode):
                # (function
                pass
            else:
                self.append_newline()

        if self.last_type in ['TK_COMMA', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']:
            if not self.start_of_object_property():
                self.allow_wrap_or_preserved_newline(token_text)

        if token_text == 'function':
            self.append_token(token_text)
            self.flags.last_word = token_text
            return

        prefix = 'NONE'

        if self.last_type == 'TK_END_BLOCK':
            if token_text not in ['else', 'catch', 'finally']:
                prefix = 'NEWLINE'
            else:
                if self.opts.brace_style in ['expand', 'end-expand']:
                    prefix = 'NEWLINE'
                else:
                    prefix = 'SPACE'
                    self.output_space_before_token = True
        elif self.last_type == 'TK_SEMICOLON' and self.flags.mode == MODE.BlockStatement:
            # TODO: Should this be for STATEMENT as well?
            prefix = 'NEWLINE'
        elif self.last_type == 'TK_SEMICOLON' and self.is_expression(self.flags.mode):
            prefix = 'SPACE'
        elif self.last_type == 'TK_STRING':
            prefix = 'NEWLINE'
        elif self.last_type == 'TK_WORD':
            prefix = 'SPACE'
        elif self.last_type == 'TK_START_BLOCK':
            prefix = 'NEWLINE'
        elif self.last_type == 'TK_END_EXPR':
            self.output_space_before_token = True
            prefix = 'NEWLINE'

        if token_text in self.line_starters:
            if self.flags.last_text == 'else':
                prefix = 'SPACE'
            else:
                prefix = 'NEWLINE'

        if token_text in ['else', 'catch', 'finally']:
            if self.last_type != 'TK_END_BLOCK' \
               or self.opts.brace_style == 'expand' \
               or self.opts.brace_style == 'end-expand':
                self.append_newline()
            else:
                self.trim_output(True)
                line = self.output_lines[-1]
                # If we trimmed and there's something other than a close block before us
                # put a newline back in.  Handles '} // comment' scenario.
                if line.text[-1] != '}':
                    self.append_newline()

                self.output_space_before_token = True

        elif prefix == 'NEWLINE':
            if self.is_special_word(self.flags.last_text):
                # no newline between return nnn
                self.output_space_before_token = True
            elif self.last_type != 'TK_END_EXPR':
                if (self.last_type != 'TK_START_EXPR' or token_text != 'var') and self.flags.last_text != ':':
                    # no need to force newline on VAR -
                    # for (var x = 0...
                    if token_text == 'if' and self.flags.last_word == 'else' and self.flags.last_text != '{':
                        self.output_space_before_token = True
                    else:
                        self.flags.var_line = False
                        self.flags.var_line_reindented = False
                        self.append_newline()
            elif token_text in self.line_starters and self.flags.last_text != ')':
                self.flags.var_line = False
                self.flags.var_line_reindented = False
                self.append_newline()
        elif self.is_array(self.flags.mode) and self.flags.last_text == ',' and self.last_last_text == '}':
            self.append_newline() # }, in lists get a newline
        elif prefix == 'SPACE':
            self.output_space_before_token = True


        self.append_token(token_text)
        self.flags.last_word = token_text

        if token_text == 'var':
            self.flags.var_line = True
            self.flags.var_line_reindented = False
            self.flags.var_line_tainted = False


        if token_text == 'do':
            self.flags.do_block = True

        if token_text == 'if':
            self.flags.if_block = True
dataset/ETHPy150Open Masood-M/yalih/jsbeautifier/build/lib.linux-i686-2.7/jsbeautifier/__init__.py/Beautifier.handle_word/original