Lines Matching refs:self
1086 # self._section will move monotonically through this set. If it ever
1112 def __init__(self):
1113 self.include_list = [[]]
1114 self._section = None
1115 self._last_header = None
1116 self.ResetSection('')
1118 def FindHeader(self, header):
1127 for section_list in self.include_list:
1133 def ResetSection(self, directive):
1140 self._section = self._INITIAL_SECTION
1142 self._last_header = ''
1147 self.include_list.append([])
1149 self.include_list[-1] = []
1151 def SetLastHeader(self, header_path):
1152 self._last_header = header_path
1154 def CanonicalizeAlphabeticalOrder(self, header_path):
1169 def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path):
1185 if (self._last_header > header_path and
1190 def CheckNextIncludeOrder(self, header_type):
1205 (self._TYPE_NAMES[header_type],
1206 self._SECTION_NAMES[self._section]))
1208 last_section = self._section
1211 if self._section <= self._C_SECTION:
1212 self._section = self._C_SECTION
1214 self._last_header = ''
1217 if self._section <= self._CPP_SECTION:
1218 self._section = self._CPP_SECTION
1220 self._last_header = ''
1223 if self._section <= self._OTHER_SYS_SECTION:
1224 self._section = self._OTHER_SYS_SECTION
1226 self._last_header = ''
1229 if self._section <= self._MY_H_SECTION:
1230 self._section = self._MY_H_SECTION
1232 self._section = self._OTHER_H_SECTION
1234 if self._section <= self._MY_H_SECTION:
1235 self._section = self._MY_H_SECTION
1239 self._section = self._OTHER_H_SECTION
1242 self._section = self._OTHER_H_SECTION
1244 if last_section != self._section:
1245 self._last_header = ''
1253 def __init__(self):
1254 self.verbose_level = 1 # global setting.
1255 self.error_count = 0 # global count of reported errors
1257 self.filters = _DEFAULT_FILTERS[:]
1259 self._filters_backup = self.filters[:]
1260 self.counting = 'total' # In what way are we counting errors?
1261 self.errors_by_category = {} # string to int dict storing error counts
1262 self.quiet = False # Suppress non-error messagess?
1271 self.output_format = 'emacs'
1275 self._junit_errors = []
1276 self._junit_failures = []
1278 def SetOutputFormat(self, output_format):
1280 self.output_format = output_format
1282 def SetQuiet(self, quiet):
1284 last_quiet = self.quiet
1285 self.quiet = quiet
1288 def SetVerboseLevel(self, level):
1290 last_verbose_level = self.verbose_level
1291 self.verbose_level = level
1294 def SetCountingStyle(self, counting_style):
1296 self.counting = counting_style
1298 def SetFilters(self, filters):
1313 self.filters = _DEFAULT_FILTERS[:]
1314 self.AddFilters(filters)
1316 def AddFilters(self, filters):
1321 self.filters.append(clean_filt)
1322 for filt in self.filters:
1327 def BackupFilters(self):
1329 self._filters_backup = self.filters[:]
1331 def RestoreFilters(self):
1333 self.filters = self._filters_backup[:]
1335 def ResetErrorCounts(self):
1337 self.error_count = 0
1338 self.errors_by_category = {}
1340 def IncrementErrorCount(self, category):
1342 self.error_count += 1
1343 if self.counting in ('toplevel', 'detailed'):
1344 if self.counting != 'detailed':
1346 if category not in self.errors_by_category:
1347 self.errors_by_category[category] = 0
1348 self.errors_by_category[category] += 1
1350 def PrintErrorCounts(self):
1352 for category, count in sorted(iteritems(self.errors_by_category)):
1353 self.PrintInfo('Category \'%s\' errors found: %d\n' %
1355 if self.error_count > 0:
1356 self.PrintInfo('Total errors found: %d\n' % self.error_count)
1358 def PrintInfo(self, message):
1361 if not _quiet and self.output_format not in _MACHINE_OUTPUTS:
1364 def PrintError(self, message):
1365 if self.output_format == 'junit':
1366 self._junit_errors.append(message)
1370 def AddJUnitFailure(self, filename, linenum, message, category, confidence):
1371 self._junit_failures.append((filename, linenum, message, category,
1374 def FormatJUnitXML(self):
1375 num_errors = len(self._junit_errors)
1376 num_failures = len(self._junit_failures)
1393 error.text = '\n'.join(self._junit_errors)
1398 for failure in self._junit_failures:
1497 def __init__(self):
1498 self.in_a_function = False
1499 self.lines_in_function = 0
1500 self.current_function = ''
1502 def Begin(self, function_name):
1508 self.in_a_function = True
1509 self.lines_in_function = 0
1510 self.current_function = function_name
1512 def Count(self):
1514 if self.in_a_function:
1515 self.lines_in_function += 1
1517 def Check(self, error, filename, linenum):
1525 if not self.in_a_function:
1528 if Match(r'T(EST|est)', self.current_function):
1529 base_trigger = self._TEST_TRIGGER
1531 base_trigger = self._NORMAL_TRIGGER
1534 if self.lines_in_function > trigger:
1535 error_level = int(math.log(self.lines_in_function / base_trigger, 2))
1543 self.current_function, self.lines_in_function, trigger))
1545 def End(self):
1547 self.in_a_function = False
1562 def __init__(self, filename):
1563 self._filename = filename
1565 def FullName(self):
1567 return os.path.abspath(self._filename).replace('\\', '/')
1569 def RepositoryName(self):
1579 fullname = self.FullName()
1629 def Split(self):
1639 googlename = self.RepositoryName()
1643 def BaseName(self):
1645 return self.Split()[1]
1647 def Extension(self):
1649 return self.Split()[2]
1651 def NoExtension(self):
1653 return '/'.join(self.Split()[0:2])
1655 def IsSource(self):
1657 return _IsSourceExtension(self.Extension()[1:])
1917 def __init__(self, lines):
1918 self.elided = []
1919 self.lines = []
1920 self.raw_lines = lines
1921 self.num_lines = len(lines)
1922 self.lines_without_raw_strings = CleanseRawStrings(lines)
1924 for linenum in range(len(self.lines_without_raw_strings)):
1925 self.lines.append(CleanseComments(
1926 self.lines_without_raw_strings[linenum]))
1927 elided = self._CollapseStrings(self.lines_without_raw_strings[linenum])
1928 self.elided.append(CleanseComments(elided))
1930 def NumLines(self):
1932 return self.num_lines
2705 def __init__(self, linenum, seen_open_brace):
2706 self.starting_linenum = linenum
2707 self.seen_open_brace = seen_open_brace
2708 self.open_parentheses = 0
2709 self.inline_asm = _NO_ASM
2710 self.check_namespace_indentation = False
2712 def CheckBegin(self, filename, clean_lines, linenum, error):
2727 def CheckEnd(self, filename, clean_lines, linenum, error):
2740 def IsBlockInfo(self):
2749 return self.__class__ == _BlockInfo
2755 def __init__(self, linenum):
2756 _BlockInfo.__init__(self, linenum, True)
2762 def __init__(self, name, class_or_struct, clean_lines, linenum):
2763 _BlockInfo.__init__(self, linenum, False)
2764 self.name = name
2765 self.is_derived = False
2766 self.check_namespace_indentation = True
2768 self.access = 'public'
2769 self.is_struct = True
2771 self.access = 'private'
2772 self.is_struct = False
2776 self.class_indent = GetIndentLevel(clean_lines.raw_lines[linenum])
2783 self.last_line = 0
2789 self.last_line = i
2792 def CheckBegin(self, filename, clean_lines, linenum, error):
2795 self.is_derived = True
2797 def CheckEnd(self, filename, clean_lines, linenum, error):
2801 for i in xrange(linenum - 1, self.starting_linenum, -1):
2804 self.name + r'\)',
2819 if indent and len(indent.group(1)) != self.class_indent:
2820 if self.is_struct:
2821 parent = 'struct ' + self.name
2823 parent = 'class ' + self.name
2831 def __init__(self, name, linenum):
2832 _BlockInfo.__init__(self, linenum, False)
2833 self.name = name or ''
2834 self.check_namespace_indentation = True
2836 def CheckEnd(self, filename, clean_lines, linenum, error):
2851 if (linenum - self.starting_linenum < 10
2867 if self.name:
2870 re.escape(self.name) + r'[\*/\.\\\s]*$'),
2874 self.name)
2892 def __init__(self, stack_before_if):
2894 self.stack_before_if = stack_before_if
2897 self.stack_before_else = []
2900 self.seen_else = False
2906 def __init__(self):
2913 self.stack = []
2924 self.previous_stack_top = []
2927 self.pp_stack = []
2929 def SeenOpenBrace(self):
2936 return (not self.stack) or self.stack[-1].seen_open_brace
2938 def InNamespaceBody(self):
2944 return self.stack and isinstance(self.stack[-1], _NamespaceInfo)
2946 def InExternC(self):
2952 return self.stack and isinstance(self.stack[-1], _ExternCInfo)
2954 def InClassDeclaration(self):
2960 return self.stack and isinstance(self.stack[-1], _ClassInfo)
2962 def InAsmBlock(self):
2968 return self.stack and self.stack[-1].inline_asm != _NO_ASM
2970 def InTemplateArgumentList(self, clean_lines, linenum, pos):
3022 def UpdatePreprocessor(self, line):
3046 self.pp_stack.append(_PreprocessorInfo(copy.deepcopy(self.stack)))
3049 if self.pp_stack:
3050 if not self.pp_stack[-1].seen_else:
3054 self.pp_stack[-1].seen_else = True
3055 self.pp_stack[-1].stack_before_else = copy.deepcopy(self.stack)
3058 self.stack = copy.deepcopy(self.pp_stack[-1].stack_before_if)
3064 if self.pp_stack:
3068 if self.pp_stack[-1].seen_else:
3071 self.stack = self.pp_stack[-1].stack_before_else
3073 self.pp_stack.pop()
3079 def Update(self, filename, clean_lines, linenum, error):
3095 if self.stack:
3096 self.previous_stack_top = self.stack[-1]
3098 self.previous_stack_top = None
3101 self.UpdatePreprocessor(line)
3105 if self.stack:
3106 inner_block = self.stack[-1]
3139 self.stack.append(new_namespace)
3156 (not self.stack or self.stack[-1].open_parentheses == 0)):
3167 if not self.InTemplateArgumentList(clean_lines, linenum, end_declaration):
3168 self.stack.append(_ClassInfo(
3175 if not self.SeenOpenBrace():
3176 self.stack[-1].CheckBegin(filename, clean_lines, linenum, error)
3179 if self.stack and isinstance(self.stack[-1], _ClassInfo):
3180 classinfo = self.stack[-1]
3216 if not self.SeenOpenBrace():
3217 self.stack[-1].seen_open_brace = True
3219 self.stack.append(_ExternCInfo(linenum))
3221 self.stack.append(_BlockInfo(linenum, True))
3223 self.stack[-1].inline_asm = _BLOCK_ASM
3234 if not self.SeenOpenBrace():
3235 self.stack.pop()
3238 if self.stack:
3239 self.stack[-1].CheckEnd(filename, clean_lines, linenum, error)
3240 self.stack.pop()
3243 def InnermostClass(self):
3249 for i in range(len(self.stack), 0, -1):
3250 classinfo = self.stack[i - 1]
3255 def CheckCompletedBlocks(self, filename, error):
3266 for obj in self.stack: