Index: chrome/browser/web_dev_style/js_checker.py |
diff --git a/chrome/browser/web_dev_style/js_checker.py b/chrome/browser/web_dev_style/js_checker.py |
index 0e224aa84651ff31f2d43d225ccfcf192b6d61ac..b928aa5d2f0533892871408fb1210e9919bae047 100644 |
--- a/chrome/browser/web_dev_style/js_checker.py |
+++ b/chrome/browser/web_dev_style/js_checker.py |
@@ -7,6 +7,9 @@ |
See chrome/browser/PRESUBMIT.py |
""" |
+import regex_check |
+ |
+ |
class JSChecker(object): |
def __init__(self, input_api, output_api, file_filter=None): |
self.input_api = input_api |
@@ -14,27 +17,8 @@ class JSChecker(object): |
self.file_filter = file_filter |
def RegexCheck(self, line_number, line, regex, message): |
- """Searches for |regex| in |line| to check for a particular style |
- violation, returning a message like the one below if the regex matches. |
- The |regex| must have exactly one capturing group so that the relevant |
- part of |line| can be highlighted. If more groups are needed, use |
- "(?:...)" to make a non-capturing group. Sample message: |
- |
- line 6: Use var instead of const. |
- const foo = bar(); |
- ^^^^^ |
- """ |
- match = self.input_api.re.search(regex, line) |
- if match: |
- assert len(match.groups()) == 1 |
- start = match.start(1) |
- length = match.end(1) - start |
- return ' line %d: %s\n%s\n%s' % ( |
- line_number, |
- message, |
- line, |
- self.error_highlight(start, length)) |
- return '' |
+ return regex_check.RegexCheck( |
+ self.input_api.re, line_number, line, regex, message) |
def ChromeSendCheck(self, i, line): |
"""Checks for a particular misuse of 'chrome.send'.""" |