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)
| 635 | return True |
| 636 | |
| 637 | def CheckNextIncludeOrder(self, header_type): |
| 638 | """Returns a non-empty error message if the next header is out of order. |
| 639 | |
| 640 | This function also updates the internal state to be ready to check |
| 641 | the next include. |
| 642 | |
| 643 | Args: |
| 644 | header_type: One of the _XXX_HEADER constants defined above. |
| 645 | |
| 646 | Returns: |
| 647 | The empty string if the header is in the right order, or an |
| 648 | error message describing what's wrong. |
| 649 | |
| 650 | """ |
| 651 | error_message = ('Found %s after %s' % |
| 652 | (self._TYPE_NAMES[header_type], |
| 653 | self._SECTION_NAMES[self._section])) |
| 654 | |
| 655 | last_section = self._section |
| 656 | |
| 657 | if header_type == _C_SYS_HEADER: |
| 658 | if self._section <= self._C_SECTION: |
| 659 | self._section = self._C_SECTION |
| 660 | else: |
| 661 | self._last_header = '' |
| 662 | return error_message |
| 663 | elif header_type == _CPP_SYS_HEADER: |
| 664 | if self._section <= self._CPP_SECTION: |
| 665 | self._section = self._CPP_SECTION |
| 666 | else: |
| 667 | self._last_header = '' |
| 668 | return error_message |
| 669 | elif header_type == _LIKELY_MY_HEADER: |
| 670 | if self._section <= self._MY_H_SECTION: |
| 671 | self._section = self._MY_H_SECTION |
| 672 | else: |
| 673 | self._section = self._OTHER_H_SECTION |
| 674 | elif header_type == _POSSIBLE_MY_HEADER: |
| 675 | if self._section <= self._MY_H_SECTION: |
| 676 | self._section = self._MY_H_SECTION |
| 677 | else: |
| 678 | # This will always be the fallback because we're not sure |
| 679 | # enough that the header is associated with this file. |
| 680 | self._section = self._OTHER_H_SECTION |
| 681 | else: |
| 682 | assert header_type == _OTHER_HEADER |
| 683 | self._section = self._OTHER_H_SECTION |
| 684 | |
| 685 | if last_section != self._section: |
| 686 | self._last_header = '' |
| 687 | |
| 688 | return '' |
| 689 | |
| 690 | |
| 691 | class _CppLintState(object): |