Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: third_party/closure_compiler/checker.py

Issue 435053002: Remove <if> statements before checking JS code by checker.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@B_define
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/closure_compiler/checker_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/closure_compiler/checker.py
diff --git a/third_party/closure_compiler/checker.py b/third_party/closure_compiler/checker.py
index 7dda25fc1fc2cfcfcc88efc11203e29e65cba4ac..1f5469161e37b4aec9f4b5e81d72f0319ac65a49 100644
--- a/third_party/closure_compiler/checker.py
+++ b/third_party/closure_compiler/checker.py
@@ -31,6 +31,7 @@ class FileCache(object):
class Flattener(object):
+ _IF_TAGS_REG = "</?if[^>]*?>"
_INCLUDE_REG = "<include[^>]+src=['\"]([^>]*)['\"]>"
def __init__(self, file):
@@ -46,8 +47,17 @@ class Flattener(object):
else:
self.index += 1
+ self.lines = map(self._remove_if_operators, self.lines)
Dan Beam 2014/08/01 20:39:54 for line in self.lines: line[2] = re.sub(self._I
Vitaly Pavlenko 2014/08/01 20:52:37 line[2] = re.sub(self._IF_TAGS_REG, "", line[2]) T
Dan Beam 2014/08/01 20:59:53 ^ that's fine
+
self.contents = "\n".join(l[2] for l in self.lines)
+ def _remove_if_operators(self, line):
+ # Replace every occurrence of tags like <if expr="..."> and </if>
+ # with an empty string.
+ file, lnum, contents = line
+ contents = re.sub(self._IF_TAGS_REG, '', contents)
+ return (file, lnum, contents)
+
# Returns a list of tuples in the format: (file, line number, line contents).
def _get_file(self, file):
lines = FileCache.read(file).splitlines()
« no previous file with comments | « no previous file | third_party/closure_compiler/checker_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698