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

Side by Side Diff: tools/checkdeps/java_checker.py

Issue 10823271: Add ability to write include rules specific to subsets of files in a directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/checkdeps/cpp_checker.py ('k') | tools/checkdeps/results.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Java files for illegal imports.""" 5 """Checks Java files for illegal imports."""
6 6
7 import codecs 7 import codecs
8 import os 8 import os
9 import re 9 import re
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 for line in f: 89 for line in f:
90 for clazz in re.findall('^import\s+(?:static\s+)?([\w\.]+)\s*;', line): 90 for clazz in re.findall('^import\s+(?:static\s+)?([\w\.]+)\s*;', line):
91 if clazz not in self._classmap: 91 if clazz not in self._classmap:
92 # Importing a class from outside the Chromium tree. That's fine -- 92 # Importing a class from outside the Chromium tree. That's fine --
93 # it's probably a Java or Android system class. 93 # it's probably a Java or Android system class.
94 continue 94 continue
95 include_path = os.path.relpath( 95 include_path = os.path.relpath(
96 self._classmap[clazz], self._base_directory) 96 self._classmap[clazz], self._base_directory)
97 # Convert Windows paths to Unix style, as used in DEPS files. 97 # Convert Windows paths to Unix style, as used in DEPS files.
98 include_path = include_path.replace(os.path.sep, '/') 98 include_path = include_path.replace(os.path.sep, '/')
99 rule = rules.RuleApplyingTo(include_path) 99 rule = rules.RuleApplyingTo(include_path, filepath)
100 if rule.allow == Rule.DISALLOW: 100 if rule.allow == Rule.DISALLOW:
101 dependee_status.AddViolation( 101 dependee_status.AddViolation(
102 results.DependencyViolation(include_path, rule, rules)) 102 results.DependencyViolation(include_path, rule, rules))
103 if '{' in line: 103 if '{' in line:
104 # This is code, so we're finished reading imports for this file. 104 # This is code, so we're finished reading imports for this file.
105 break 105 break
106 106
107 return dependee_status 107 return dependee_status
OLDNEW
« no previous file with comments | « tools/checkdeps/cpp_checker.py ('k') | tools/checkdeps/results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698