MCPcopy Index your code
hub / github.com/nodejs/node / ReplaceAlternateTokens

Function ReplaceAlternateTokens

tools/cpplint.py:2122–2140  ·  view source on GitHub ↗

Replace any alternate token by its original counterpart. In order to comply with the google rule stating that unary operators should never be followed by a space, an exception is made for the 'not' and 'compl' alternate tokens. For these, any trailing space is removed during the con

(line)

Source from the content-addressed store, hash-verified

2120
2121
2122def ReplaceAlternateTokens(line):
2123 """Replace any alternate token by its original counterpart.
2124
2125 In order to comply with the google rule stating that unary operators should
2126 never be followed by a space, an exception is made for the 'not' and 'compl'
2127 alternate tokens. For these, any trailing space is removed during the
2128 conversion.
2129
2130 Args:
2131 line: The line being processed.
2132
2133 Returns:
2134 The line with alternate tokens replaced.
2135 """
2136 for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line):
2137 token = _ALT_TOKEN_REPLACEMENT[match.group(2)]
2138 tail = "" if match.group(2) in ["not", "compl"] and match.group(3) == " " else r"\3"
2139 line = re.sub(match.re, rf"\1{token}{tail}", line, count=1)
2140 return line
2141
2142
2143class CleansedLines:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…