parameters: (filename, clean_lines, class_info, linenum, error)
docstring: Checks for additional blank line issues related to sections.
  
    Currently the only thing checked here is blank line before protected/private.
  
    Args:
      filename: The name of the current file.
      clean_lines: A CleansedLines instance containing the file.
      class_info: A _ClassInfo objects.
      linenum: The number of the line to check.
      error: The function to call with any errors found.
docstring_summary: Checks for additional blank line issues related to sections.
docstring_tokens: Checks for additional blank line issues related to sections .
function: def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error):
    """Checks for additional blank line issues related to sections.
  
    Currently the only thing checked here is blank line before protected/private.
  
    Args:
      filename: The name of the current file.
      clean_lines: A CleansedLines instance containing the file.
      class_info: A _ClassInfo objects.
      linenum: The number of the line to check.
      error: The function to call with any errors found.
    """
    # Skip checks if the class is small, where small means 25 lines or less.
    # 25 lines seems like a good cutoff since that's the usual height of
    # terminals, and any class that can't fit in one screen can't really
    # be considered "small".
    #
    # Also skip checks if we are on the first line.  This accounts for
    # classes that look like
    #   class Foo { public: ... };
    #
    # If we didn't find the end of the class, last_line would be zero,
    # and the check will be skipped by the first condition.
    if (class_info.last_line - class_info.starting_linenum <= 24 or
        linenum <= class_info.starting_linenum):
      return
  
    matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum])
    if matched:
      # Issue warning if the line before public/protected/private was
      # not a blank line, but don't do this if the previous line contains
      # "class" or "struct".  This can happen two ways:
      #  - We are at the beginning of the class.
      #  - We are forward-declaring an inner class that is semantically
      #    private, but needed to be public for implementation reasons.
      # Also ignores cases where the previous line ends with a backslash as can be
      # common when defining classes in C macros.
      prev_line = clean_lines.lines[linenum - 1]
      if (not IsBlankLine(prev_line) and
          not Search(r'\b(class|struct)\b', prev_line) and
          not Search(r'\\$', prev_line)):
        # Try a bit harder to find the beginning of the class.  This is to
        # account for multi-line base-specifier lists, e.g.:
        #   class Derived
        #       : public Base {
        end_class_head = class_info.starting_linenum
        for i in range(class_info.starting_linenum, linenum):
          if Search(r'\{\s*$', clean_lines.lines[i]):
            end_class_head = i
            break
        if end_class_head < linenum - 1:
          error(filename, linenum, 'whitespace/blank_line', 3,
                '"%s:" should be preceded by a blank line' % matched.group(1))
function_tokens: def CheckSectionSpacing ( filename , clean_lines , class_info , linenum , error ) : # Skip checks if the class is small, where small means 25 lines or less. # 25 lines seems like a good cutoff since that's the usual height of # terminals, and any class that can't fit in one screen can't really # be considered "small". # # Also skip checks if we are on the first line.  This accounts for # classes that look like #   class Foo { public: ... }; # # If we didn't find the end of the class, last_line would be zero, # and the check will be skipped by the first condition. if ( class_info . last_line - class_info . starting_linenum <= 24 or linenum <= class_info . starting_linenum ) : return matched = Match ( r'\s*(public|protected|private):' , clean_lines . lines [ linenum ] ) if matched : # Issue warning if the line before public/protected/private was # not a blank line, but don't do this if the previous line contains # "class" or "struct".  This can happen two ways: #  - We are at the beginning of the class. #  - We are forward-declaring an inner class that is semantically #    private, but needed to be public for implementation reasons. # Also ignores cases where the previous line ends with a backslash as can be # common when defining classes in C macros. prev_line = clean_lines . lines [ linenum - 1 ] if ( not IsBlankLine ( prev_line ) and not Search ( r'\b(class|struct)\b' , prev_line ) and not Search ( r'\\$' , prev_line ) ) : # Try a bit harder to find the beginning of the class.  This is to # account for multi-line base-specifier lists, e.g.: #   class Derived #       : public Base { end_class_head = class_info . starting_linenum for i in range ( class_info . starting_linenum , linenum ) : if Search ( r'\{\s*$' , clean_lines . lines [ i ] ) : end_class_head = i break if end_class_head < linenum - 1 : error ( filename , linenum , 'whitespace/blank_line' , 3 , '"%s:" should be preceded by a blank line' % matched . group ( 1 ) )