MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / InTemplateArgumentList

Method InTemplateArgumentList

steps/cpplint.py:2978–3028  ·  view source on GitHub ↗

Check if current position is inside template argument list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: position just after the suspected template argument. Returns: True if (linenum, pos) is inside

(self, clean_lines, linenum, pos)

Source from the content-addressed store, hash-verified

2976 return self.stack and self.stack[-1].inline_asm != _NO_ASM
2977
2978 def InTemplateArgumentList(self, clean_lines, linenum, pos):
2979 """Check if current position is inside template argument list.
2980
2981 Args:
2982 clean_lines: A CleansedLines instance containing the file.
2983 linenum: The number of the line to check.
2984 pos: position just after the suspected template argument.
2985 Returns:
2986 True if (linenum, pos) is inside template arguments.
2987 """
2988 while linenum < clean_lines.NumLines():
2989 # Find the earliest character that might indicate a template argument
2990 line = clean_lines.elided[linenum]
2991 match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:])
2992 if not match:
2993 linenum += 1
2994 pos = 0
2995 continue
2996 token = match.group(1)
2997 pos += len(match.group(0))
2998
2999 # These things do not look like template argument list:
3000 # class Suspect {
3001 # class Suspect x; }
3002 if token in ('{', '}', ';'): return False
3003
3004 # These things look like template argument list:
3005 # template <class Suspect>
3006 # template <class Suspect = default_value>
3007 # template <class Suspect[]>
3008 # template <class Suspect...>
3009 if token in ('>', '=', '[', ']', '.'): return True
3010
3011 # Check if token is an unmatched '<'.
3012 # If not, move on to the next character.
3013 if token != '<':
3014 pos += 1
3015 if pos >= len(line):
3016 linenum += 1
3017 pos = 0
3018 continue
3019
3020 # We can't be sure if we just find a single '<', and need to
3021 # find the matching '>'.
3022 (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1)
3023 if end_pos < 0:
3024 # Not sure if template argument list or syntax error in file
3025 return False
3026 linenum = end_line
3027 pos = end_pos
3028 return False
3029
3030 def UpdatePreprocessor(self, line):
3031 """Update preprocessor stack.

Callers 1

UpdateMethod · 0.95

Calls 3

MatchFunction · 0.85
CloseExpressionFunction · 0.85
NumLinesMethod · 0.80

Tested by

no test coverage detected