MCPcopy Index your code
hub / github.com/cpplint/cpplint / CleansedLines

Class CleansedLines

cpplint.py:2098–2192  ·  view source on GitHub ↗

Holds 4 copies of all lines with different preprocessing applied to them. 1) elided member contains lines without strings and comments. 2) lines member contains lines without comments. 3) raw_lines member contains all the lines without processing. 4) lines_without_raw_strings member

Source from the content-addressed store, hash-verified

2096
2097
2098class CleansedLines:
2099 """Holds 4 copies of all lines with different preprocessing applied to them.
2100
2101 1) elided member contains lines without strings and comments.
2102 2) lines member contains lines without comments.
2103 3) raw_lines member contains all the lines without processing.
2104 4) lines_without_raw_strings member is same as raw_lines, but with C++11 raw
2105 strings removed.
2106 All these members are of <type 'list'>, and of the same length.
2107 """
2108
2109 def __init__(self, lines):
2110 if "-readability/alt_tokens" in _cpplint_state.filters:
2111 for i, line in enumerate(lines):
2112 lines[i] = ReplaceAlternateTokens(line)
2113 self.elided = []
2114 self.lines = []
2115 self.raw_lines = lines
2116 self.num_lines = len(lines)
2117 self.lines_without_raw_strings = CleanseRawStrings(lines)
2118 for line in self.lines_without_raw_strings:
2119 self.lines.append(CleanseComments(line))
2120 elided = self._CollapseStrings(line)
2121 self.elided.append(CleanseComments(elided))
2122
2123 def NumLines(self):
2124 """Returns the number of lines represented."""
2125 return self.num_lines
2126
2127 @staticmethod
2128 def _CollapseStrings(elided):
2129 """Collapses strings and chars on a line to simple "" or '' blocks.
2130
2131 We nix strings first so we're not fooled by text like '"http://"&#x27;
2132
2133 Args:
2134 elided: The line being processed.
2135
2136 Returns:
2137 The line with collapsed strings.
2138 """
2139 if _RE_PATTERN_INCLUDE.match(elided):
2140 return elided
2141
2142 # Remove escaped characters first to make quote/single quote collapsing
2143 # basic. Things that look like escaped characters shouldn't occur
2144 # outside of strings and chars.
2145 elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub("", elided)
2146
2147 # Replace quoted strings and digit separators. Both single quotes
2148 # and double quotes are processed in the same loop, otherwise
2149 # nested quotes wouldn't work.
2150 collapsed = ""
2151 while True:
2152 # Find the first quote character
2153 match = re.match(r'^([^\'"]*)([\'"])(.*)$&#x27;, elided)
2154 if not match:
2155 collapsed += elided

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected