Mon, 15 Feb 2010 16:09:50 -0800
6926555: 6921979 breaks TreePosTest
Reviewed-by: darcy
test/tools/javac/treepostests/TreePosTest.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/tools/javac/treepostests/TreePosTest.java Thu Feb 04 10:14:28 2010 -0800 1.2 +++ b/test/tools/javac/treepostests/TreePosTest.java Mon Feb 15 16:09:50 2010 -0800 1.3 @@ -98,7 +98,7 @@ 1.4 * @test 1.5 * @bug 6919889 1.6 * @summary assorted position errors in compiler syntax trees 1.7 - * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations . 1.8 + * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE . 1.9 */ 1.10 public class TreePosTest { 1.11 /** 1.12 @@ -150,6 +150,8 @@ 1.13 tags.add(args[++i]); 1.14 else if (arg.equals("-ef") && i + 1 < args.length) 1.15 excludeFiles.add(new File(baseDir, args[++i])); 1.16 + else if (arg.equals("-et") && i + 1 < args.length) 1.17 + excludeTags.add(args[++i]); 1.18 else if (arg.equals("-r")) { 1.19 if (excludeFiles.size() > 0) 1.20 throw new Error("-r must be used before -ef"); 1.21 @@ -199,6 +201,7 @@ 1.22 out.println("-t tag Limit checks to tree nodes with this tag"); 1.23 out.println(" Can be repeated if desired"); 1.24 out.println("-ef file Exclude file or directory"); 1.25 + out.println("-et tag Exclude tree nodes with given tag name"); 1.26 out.println(""); 1.27 out.println("files may be directories or files"); 1.28 out.println("directories will be scanned recursively"); 1.29 @@ -304,6 +307,8 @@ 1.30 Set<String> tags = new HashSet<String>(); 1.31 /** Set of files and directories to be excluded from analysis. */ 1.32 Set<File> excludeFiles = new HashSet<File>(); 1.33 + /** Set of tag names to be excluded from analysis. */ 1.34 + Set<String> excludeTags = new HashSet<String>(); 1.35 /** Table of printable names for tree tag values. */ 1.36 TagNames tagNames = new TagNames(); 1.37 1.38 @@ -324,7 +329,7 @@ 1.39 return; 1.40 1.41 Info self = new Info(tree, endPosTable); 1.42 - if (check(self)) { 1.43 + if (check(encl, self)) { 1.44 // Modifiers nodes are present throughout the tree even where 1.45 // there is no corresponding source text. 1.46 // Redundant semicolons in a class definition can cause empty 1.47 @@ -392,8 +397,13 @@ 1.48 super.visitVarDef(tree); 1.49 } 1.50 1.51 - boolean check(Info x) { 1.52 - return tags.size() == 0 || tags.contains(tagNames.get(x.tag)); 1.53 + boolean check(Info encl, Info self) { 1.54 + if (excludeTags.size() > 0) { 1.55 + if (encl != null && excludeTags.contains(tagNames.get(encl.tag)) 1.56 + || excludeTags.contains(tagNames.get(self.tag))) 1.57 + return false; 1.58 + } 1.59 + return tags.size() == 0 || tags.contains(tagNames.get(self.tag)); 1.60 } 1.61 1.62 void check(String label, Info encl, Info self, boolean ok) {