MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / _IncludeState

Class _IncludeState

src/tests/coding/cpplint.py:1069–1242  ·  view source on GitHub ↗

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 f

Source from the content-addressed store, hash-verified

1067
1068
1069class _IncludeState(object):
1070 """Tracks line numbers for includes, and the order in which includes appear.
1071
1072 include_list contains list of lists of (header, line number) pairs.
1073 It's a lists of lists rather than just one flat list to make it
1074 easier to update across preprocessor boundaries.
1075
1076 Call CheckNextIncludeOrder() once for each header in the file, passing
1077 in the type constants defined above. Calls in an illegal order will
1078 raise an _IncludeError with an appropriate error message.
1079
1080 """
1081 # self._section will move monotonically through this set. If it ever
1082 # needs to move backwards, CheckNextIncludeOrder will raise an error.
1083 _INITIAL_SECTION = 0
1084 _MY_H_SECTION = 1
1085 _C_SECTION = 2
1086 _CPP_SECTION = 3
1087 _OTHER_SYS_SECTION = 4
1088 _OTHER_H_SECTION = 5
1089
1090 _TYPE_NAMES = {
1091 _C_SYS_HEADER: 'C system header',
1092 _CPP_SYS_HEADER: 'C++ system header',
1093 _OTHER_SYS_HEADER: 'other system header',
1094 _LIKELY_MY_HEADER: 'header this file implements',
1095 _POSSIBLE_MY_HEADER: 'header this file may implement',
1096 _OTHER_HEADER: 'other header',
1097 }
1098 _SECTION_NAMES = {
1099 _INITIAL_SECTION: "... nothing. (This can't be an error.)",
1100 _MY_H_SECTION: 'a header this file implements',
1101 _C_SECTION: 'C system header',
1102 _CPP_SECTION: 'C++ system header',
1103 _OTHER_SYS_SECTION: 'other system header',
1104 _OTHER_H_SECTION: 'other header',
1105 }
1106
1107 def __init__(self):
1108 self.include_list = [[]]
1109 self._section = None
1110 self._last_header = None
1111 self.ResetSection('')
1112
1113 def FindHeader(self, header):
1114 """Check if a header has already been included.
1115
1116 Args:
1117 header: header to check.
1118 Returns:
1119 Line number of previous occurrence, or -1 if the header has not
1120 been seen before.
1121 """
1122 for section_list in self.include_list:
1123 for f in section_list:
1124 if f[0] == header:
1125 return f[1]
1126 return -1

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected