class documentation

class _IncludeState(object):

View In Hierarchy

Tracks line numbers for includes, and the order in which includes appear.

include_list contains list of lists of (header, line number) pairs. It's a lists of lists rather than just one flat list to make it easier to update across preprocessor boundaries.

Call CheckNextIncludeOrder() once for each header in the file, passing in the type constants defined above. Calls in an illegal order will raise an _IncludeError with an appropriate error message.

Method __init__ Undocumented
Method CanonicalizeAlphabeticalOrder Returns a path canonicalized for alphabetical comparison.
Method CheckNextIncludeOrder Returns a non-empty error message if the next header is out of order.
Method FindHeader Check if a header has already been included.
Method IsInAlphabeticalOrder Check if a header is in alphabetical order with the previous header.
Method ResetSection Reset section checking for preprocessor directive.
Method SetLastHeader Undocumented
Instance Variable include_list Undocumented
Constant _C_SECTION Undocumented
Constant _CPP_SECTION Undocumented
Constant _INITIAL_SECTION Undocumented
Constant _MY_H_SECTION Undocumented
Constant _OTHER_H_SECTION Undocumented
Constant _SECTION_NAMES Undocumented
Constant _TYPE_NAMES Undocumented
Instance Variable _last_header Undocumented
Instance Variable _section Undocumented
def __init__(self):

Undocumented

def CanonicalizeAlphabeticalOrder(self, header_path):

Returns a path canonicalized for alphabetical comparison.

  • replaces "-" with "_" so they both cmp the same.
  • removes '-inl' since we don't require them to be after the main header.
  • lowercase everything, just in case.
Args:
header_path: Path to be canonicalized.
Returns:
Canonicalized path.
def CheckNextIncludeOrder(self, header_type):

Returns a non-empty error message if the next header is out of order.

This function also updates the internal state to be ready to check the next include.

Args:
header_type: One of the _XXX_HEADER constants defined above.
Returns:
The empty string if the header is in the right order, or an error message describing what's wrong.
def FindHeader(self, header):

Check if a header has already been included.

Args:
header: header to check.
Returns:
Line number of previous occurrence, or -1 if the header has not been seen before.
def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path):

Check if a header is in alphabetical order with the previous header.

Args:
clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. header_path: Canonicalized header to be checked.
Returns:
Returns true if the header is in alphabetical order.
def ResetSection(self, directive):

Reset section checking for preprocessor directive.

Args:
directive: preprocessor directive (e.g. "if", "else").
def SetLastHeader(self, header_path):

Undocumented

include_list: list[list] =

Undocumented

_C_SECTION: int =

Undocumented

Value
2
_CPP_SECTION: int =

Undocumented

Value
3
_INITIAL_SECTION: int =

Undocumented

Value
0
_MY_H_SECTION: int =

Undocumented

Value
1
_OTHER_H_SECTION: int =

Undocumented

Value
4
_SECTION_NAMES =

Undocumented

Value
{_INITIAL_SECTION: '... nothing. (This can\'t be an error.)',
 _MY_H_SECTION: 'a header this file implements',
 _C_SECTION: 'C system header',
 _CPP_SECTION: 'C++ system header',
 _OTHER_H_SECTION: 'other header'}
_TYPE_NAMES =

Undocumented

Value
{_C_SYS_HEADER: 'C system header',
 _CPP_SYS_HEADER: 'C++ system header',
 _LIKELY_MY_HEADER: 'header this file implements',
 _POSSIBLE_MY_HEADER: 'header this file may implement',
 _OTHER_HEADER: 'other header'}
_last_header: str =

Undocumented

_section =

Undocumented