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

Class _IncludeState

steps/cpplint.py:1084–1257  ·  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

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

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected