Mercurial > hg > truffle
changeset 8607:c7672a325faf
search for classes containing annotations returns source file as well as class name
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Apr 2013 10:08:42 +0200 |
parents | f00f02691677 |
children | 6d884611d4c1 516e35a8eed8 |
files | mx/commands.py mxtool/mx.py |
diffstat | 2 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mx/commands.py Wed Apr 03 00:20:46 2013 +0200 +++ b/mx/commands.py Wed Apr 03 10:08:42 2013 +0200 @@ -690,8 +690,8 @@ # Exclude all compiler tests and snippets excludes = ['com.oracle.graal.compiler.tests.*', 'com.oracle.graal.jtt.*'] for p in mx.projects(): - excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True) - excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True) + excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys() + excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys() includes = ['com.oracle.graal.*', 'com.oracle.max.*'] agentOptions = { @@ -732,7 +732,7 @@ classes = [] for p in mx.projects(): - classes += _find_classes_with_annotations(p, None, annotations) + classes += _find_classes_with_annotations(p, None, annotations).keys() if len(pos) != 0: classes = [c for c in classes if containsAny(c, pos)]
--- a/mxtool/mx.py Wed Apr 03 00:20:46 2013 +0200 +++ b/mxtool/mx.py Wed Apr 03 10:08:42 2013 +0200 @@ -311,10 +311,10 @@ def find_classes_with_matching_source_line(self, pkgRoot, function, includeInnerClasses=False): """ Scan the sources of this project for Java source files containing a line for which - 'function' returns true. The fully qualified class name of each existing class - corresponding to a matched source file is returned in a list. + 'function' returns true. A map from class name to source file path for each existing class + corresponding to a matched source file is returned. """ - classes = [] + result = dict() pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") for srcDir in self.source_dirs(): outputDir = self.output_dir() @@ -322,7 +322,8 @@ for name in files: if name.endswith('.java') and name != 'package-info.java': matchFound = False - with open(join(root, name)) as f: + source = join(root, name) + with open(source) as f: pkg = None for line in f: if line.startswith("package "): @@ -342,10 +343,12 @@ for e in os.listdir(pkgOutputDir): if includeInnerClasses: if e.endswith('.class') and (e.startswith(basename) or e.startswith(basename + '$')): - classes.append(pkg + '.' + e[:-len('.class')]) + className = pkg + '.' + e[:-len('.class')] + result[className] = source elif e == basename + '.class': - classes.append(pkg + '.' + basename) - return classes + className = pkg + '.' + basename + result[className] = source + return result def _init_packages_and_imports(self): if not hasattr(self, '_defined_java_packages'):