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)
| 806 | return True |
| 807 | |
| 808 | def CheckNextIncludeOrder(self, header_type): |
| 809 | """Returns a non-empty error message if the next header is out of order. |
| 810 | |
| 811 | This function also updates the internal state to be ready to check |
| 812 | the next include. |
| 813 | |
| 814 | Args: |
| 815 | header_type: One of the _XXX_HEADER constants defined above. |
| 816 | |
| 817 | Returns: |
| 818 | The empty string if the header is in the right order, or an |
| 819 | error message describing what's wrong. |
| 820 | |
| 821 | """ |
| 822 | error_message = ('Found %s after %s' % |
| 823 | (self._TYPE_NAMES[header_type], |
| 824 | self._SECTION_NAMES[self._section])) |
| 825 | |
| 826 | last_section = self._section |
| 827 | |
| 828 | if header_type == _C_SYS_HEADER: |
| 829 | if self._section <= self._C_SECTION: |
| 830 | self._section = self._C_SECTION |
| 831 | else: |
| 832 | self._last_header = '' |
| 833 | return error_message |
| 834 | elif header_type == _CPP_SYS_HEADER: |
| 835 | if self._section <= self._CPP_SECTION: |
| 836 | self._section = self._CPP_SECTION |
| 837 | else: |
| 838 | self._last_header = '' |
| 839 | return error_message |
| 840 | elif header_type == _LIKELY_MY_HEADER: |
| 841 | if self._section <= self._MY_H_SECTION: |
| 842 | self._section = self._MY_H_SECTION |
| 843 | else: |
| 844 | self._section = self._OTHER_H_SECTION |
| 845 | elif header_type == _POSSIBLE_MY_HEADER: |
| 846 | if self._section <= self._MY_H_SECTION: |
| 847 | self._section = self._MY_H_SECTION |
| 848 | else: |
| 849 | # This will always be the fallback because we're not sure |
| 850 | # enough that the header is associated with this file. |
| 851 | self._section = self._OTHER_H_SECTION |
| 852 | else: |
| 853 | assert header_type == _OTHER_HEADER |
| 854 | self._section = self._OTHER_H_SECTION |
| 855 | |
| 856 | if last_section != self._section: |
| 857 | self._last_header = '' |
| 858 | |
| 859 | return '' |
| 860 | |
| 861 | |
| 862 | class _CppLintState(object): |