OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2008 The Closure Linter Authors. All Rights Reserved. | |
4 # | |
5 # Licensed under the Apache License, Version 2.0 (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 | |
8 # | |
9 # http://www.apache.org/licenses/LICENSE-2.0 | |
10 # | |
11 # Unless required by applicable law or agreed to in writing, software | |
12 # distributed under the License is distributed on an "AS-IS" BASIS, | |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 # See the License for the specific language governing permissions and | |
15 # limitations under the License. | |
16 | |
17 """Interface for a linter error handler. | |
18 | |
19 Error handlers aggregate a set of errors from multiple files and can optionally | |
20 perform some action based on the reported errors, for example, logging the error | |
21 or automatically fixing it. | |
22 """ | |
23 | |
24 __author__ = ('robbyw@google.com (Robert Walker)', | |
25 'ajp@google.com (Andy Perelson)') | |
26 | |
27 | |
28 class ErrorHandler(object): | |
29 """Error handler interface.""" | |
30 | |
31 def __init__(self): | |
32 if self.__class__ == ErrorHandler: | |
33 raise NotImplementedError('class ErrorHandler is abstract') | |
34 | |
35 def HandleFile(self, filename, first_token): | |
36 """Notifies this ErrorHandler that subsequent errors are in filename. | |
37 | |
38 Args: | |
39 filename: The file being linted. | |
40 first_token: The first token of the file. | |
41 """ | |
42 | |
43 def HandleError(self, error): | |
44 """Append the error to the list. | |
45 | |
46 Args: | |
47 error: The error object | |
48 """ | |
49 | |
50 def FinishFile(self): | |
51 """Finishes handling the current file. | |
52 | |
53 Should be called after all errors in a file have been handled. | |
54 """ | |
55 | |
56 def GetErrors(self): | |
57 """Returns the accumulated errors. | |
58 | |
59 Returns: | |
60 A sequence of errors. | |
61 """ | |
OLD | NEW |