| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Checks C++ and Objective-C files for illegal includes.""" | 5 """Checks C++ and Objective-C files for illegal includes.""" |
| 6 | 6 |
| 7 import codecs | 7 import codecs |
| 8 import os |
| 8 import re | 9 import re |
| 9 | 10 |
| 10 from rules import Rule | 11 from rules import Rule |
| 11 | 12 |
| 12 | 13 |
| 13 class CppChecker(object): | 14 class CppChecker(object): |
| 14 | 15 |
| 15 EXTENSIONS = [ | 16 EXTENSIONS = [ |
| 16 '.h', | 17 '.h', |
| 17 '.cc', | 18 '.cc', |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 is_include, line_status, rule_type = self.CheckLine(rules, line) | 108 is_include, line_status, rule_type = self.CheckLine(rules, line) |
| 108 if is_include: | 109 if is_include: |
| 109 last_include = line_num | 110 last_include = line_num |
| 110 if line_status is not None: | 111 if line_status is not None: |
| 111 if len(line_status) > 0: # Add newline to separate messages. | 112 if len(line_status) > 0: # Add newline to separate messages. |
| 112 line_status += '\n' | 113 line_status += '\n' |
| 113 ret_val += line_status | 114 ret_val += line_status |
| 114 | 115 |
| 115 return ret_val | 116 return ret_val |
| 117 |
| 118 @staticmethod |
| 119 def IsCppFile(file_path): |
| 120 """Returns True iff the given path ends in one of the extensions |
| 121 handled by this checker. |
| 122 """ |
| 123 return os.path.splitext(file_path)[1] in CppChecker.EXTENSIONS |
| OLD | NEW |