'Build a logical line from tokens.'

def build_tokens_line(self):

    self.mapping = []
    logical = []
    length = 0
    previous = None
    for token in self.tokens:
        (token_type, text) = token[0:2]
        if (token_type in (tokenize.COMMENT, tokenize.NL, tokenize.INDENT, tokenize.DEDENT, tokenize.NEWLINE)):
            continue
        if (token_type == tokenize.STRING):
            text = mute_string(text)
        if previous:
            (end_line, end) = previous[3]
            (start_line, start) = token[2]
            if (end_line != start_line):
                if (self.lines[(end_line - 1)][(end - 1)] not in '{[('):
                    logical.append('    ')
                    length += 1
            elif (end != start):
                fill = self.lines[(end_line - 1)][end:start]
                logical.append(fill)
                length += len(fill)
        self.mapping.append((length, token))
        logical.append(text)
        length += len(text)
        previous = token
    self.logical_line = ''.join(logical)
    assert (self.logical_line.lstrip() == self.logical_line)
    assert (self.logical_line.rstrip() == self.logical_line)
