(source, lines)
return statement_ranges
Return a list of all global statement blocks.

    The list comprises of 3-item tuples that contain the starting line number,
    ending line number and whether the statement is a single line.
Return a list of all global statement blocks.
Return a list of all global statement blocks .
def _get_global_statement_blocks(source, lines):
    """Return a list of all global statement blocks.

    The list comprises of 3-item tuples that contain the starting line number,
    ending line number and whether the statement is a single line.

    """
    tree = ast.parse(source)
    visitor = Visitor(lines)
    visitor.visit(tree)

    statement_ranges = []
    for index, line_number in enumerate(visitor.line_numbers_with_statements):
        remaining_line_numbers = visitor.line_numbers_with_statements[index+1:]
        end_line_number = len(lines) if len(remaining_line_numbers) == 0 else min(remaining_line_numbers) - 1
        current_statement_is_oneline = line_number == end_line_number

        if len(statement_ranges) == 0:
            statement_ranges.append((line_number, end_line_number, current_statement_is_oneline))
            continue

        previous_statement = statement_ranges[-1]
        previous_statement_is_oneline = previous_statement[2]
        if previous_statement_is_oneline and current_statement_is_oneline:
            statement_ranges[-1] = previous_statement[0], end_line_number, True
        else:
            statement_ranges.append((line_number, end_line_number, current_statement_is_oneline))

    return statement_ranges
def _get_global_statement_blocks ( source , lines ) : tree = ast . parse ( source ) visitor = Visitor ( lines ) visitor . visit ( tree ) statement_ranges = [ ] for index , line_number in enumerate ( visitor . line_numbers_with_statements ) : remaining_line_numbers = visitor . line_numbers_with_statements [ index + 1 : ] end_line_number = len ( lines ) if len ( remaining_line_numbers ) == 0 else min ( remaining_line_numbers ) - 1 current_statement_is_oneline = line_number == end_line_number if len ( statement_ranges ) == 0 : statement_ranges . append ( ( line_number , end_line_number , current_statement_is_oneline ) ) continue previous_statement = statement_ranges [ - 1 ] previous_statement_is_oneline = previous_statement [ 2 ] if previous_statement_is_oneline and current_statement_is_oneline : statement_ranges [ - 1 ] = previous_statement [ 0 ] , end_line_number , True else : statement_ranges . append ( ( line_number , end_line_number , current_statement_is_oneline ) ) return statement_ranges