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