| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2007 The Closure Linter Authors. All Rights Reserved. | 3 # Copyright 2007 The Closure Linter Authors. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| 11 # Unless required by applicable law or agreed to in writing, software | 11 # Unless required by applicable law or agreed to in writing, software |
| 12 # distributed under the License is distributed on an "AS-IS" BASIS, | 12 # distributed under the License is distributed on an "AS-IS" BASIS, |
| 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 # See the License for the specific language governing permissions and | 14 # See the License for the specific language governing permissions and |
| 15 # limitations under the License. | 15 # limitations under the License. |
| 16 | 16 |
| 17 """Error object commonly used in linters.""" | 17 """Error object commonly used in linters.""" |
| 18 | 18 |
| 19 __author__ = ('robbyw@google.com (Robert Walker)', | 19 __author__ = ('robbyw@google.com (Robert Walker)', |
| 20 'ajp@google.com (Andy Perelson)') | 20 'ajp@google.com (Andy Perelson)') |
| 21 | 21 |
| 22 | 22 |
| 23 class Error(object): | 23 class Error(object): |
| 24 """Object representing a style error.""" | 24 """Object representing a style error.""" |
| 25 | 25 |
| 26 def __init__(self, code, message, token, position, fix_data): | 26 def __init__(self, code, message, token=None, position=None, fix_data=None): |
| 27 """Initialize the error object. | 27 """Initialize the error object. |
| 28 | 28 |
| 29 Args: | 29 Args: |
| 30 code: The numeric error code. | 30 code: The numeric error code. |
| 31 message: The error message string. | 31 message: The error message string. |
| 32 token: The tokens.Token where the error occurred. | 32 token: The tokens.Token where the error occurred. |
| 33 position: The position of the error within the token. | 33 position: The position of the error within the token. |
| 34 fix_data: Data to be used in autofixing. Codes with fix_data are: | 34 fix_data: Data to be used in autofixing. Codes with fix_data are: |
| 35 GOOG_REQUIRES_NOT_ALPHABETIZED - List of string value tokens that are | 35 GOOG_REQUIRES_NOT_ALPHABETIZED - List of string value tokens that are |
| 36 class names in goog.requires calls. | 36 class names in goog.requires calls. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 | 56 |
| 57 Returns: | 57 Returns: |
| 58 A Negative/0/Positive number when a is before/the same as/after b. | 58 A Negative/0/Positive number when a is before/the same as/after b. |
| 59 """ | 59 """ |
| 60 line_diff = a.token.line_number - b.token.line_number | 60 line_diff = a.token.line_number - b.token.line_number |
| 61 if line_diff: | 61 if line_diff: |
| 62 return line_diff | 62 return line_diff |
| 63 | 63 |
| 64 return a.start_index - b.start_index | 64 return a.start_index - b.start_index |
| 65 Compare = staticmethod(Compare) | 65 Compare = staticmethod(Compare) |
| OLD | NEW |