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 t
(self, header_type)
| 1183 | return True |
| 1184 | |
| 1185 | def CheckNextIncludeOrder(self, header_type): |
| 1186 | """Returns a non-empty error message if the next header is out of order. |
| 1187 | |
| 1188 | This function also updates the internal state to be ready to check |
| 1189 | the next include. |
| 1190 | |
| 1191 | Args: |
| 1192 | header_type: One of the _XXX_HEADER constants defined above. |
| 1193 | |
| 1194 | Returns: |
| 1195 | The empty string if the header is in the right order, or an |
| 1196 | error message describing what's wrong. |
| 1197 | |
| 1198 | """ |
| 1199 | error_message = ('Found %s after %s' % |
| 1200 | (self._TYPE_NAMES[header_type], |
| 1201 | self._SECTION_NAMES[self._section])) |
| 1202 | |
| 1203 | last_section = self._section |
| 1204 | |
| 1205 | if header_type == _C_SYS_HEADER: |
| 1206 | if self._section <= self._C_SECTION: |
| 1207 | self._section = self._C_SECTION |
| 1208 | else: |
| 1209 | self._last_header = '' |
| 1210 | return error_message |
| 1211 | elif header_type == _CPP_SYS_HEADER: |
| 1212 | if self._section <= self._CPP_SECTION: |
| 1213 | self._section = self._CPP_SECTION |
| 1214 | else: |
| 1215 | self._last_header = '' |
| 1216 | return error_message |
| 1217 | elif header_type == _OTHER_SYS_HEADER: |
| 1218 | if self._section <= self._OTHER_SYS_SECTION: |
| 1219 | self._section = self._OTHER_SYS_SECTION |
| 1220 | else: |
| 1221 | self._last_header = '' |
| 1222 | return error_message |
| 1223 | elif header_type == _LIKELY_MY_HEADER: |
| 1224 | if self._section <= self._MY_H_SECTION: |
| 1225 | self._section = self._MY_H_SECTION |
| 1226 | else: |
| 1227 | self._section = self._OTHER_H_SECTION |
| 1228 | elif header_type == _POSSIBLE_MY_HEADER: |
| 1229 | if self._section <= self._MY_H_SECTION: |
| 1230 | self._section = self._MY_H_SECTION |
| 1231 | else: |
| 1232 | # This will always be the fallback because we're not sure |
| 1233 | # enough that the header is associated with this file. |
| 1234 | self._section = self._OTHER_H_SECTION |
| 1235 | else: |
| 1236 | assert header_type == _OTHER_HEADER |
| 1237 | self._section = self._OTHER_H_SECTION |
| 1238 | |
| 1239 | if last_section != self._section: |
| 1240 | self._last_header = '' |
| 1241 | |
| 1242 | return '' |