changeset 492:7d9e3a15d2b3

6926555: 6921979 breaks TreePosTest Reviewed-by: darcy
author jjg
date Mon, 15 Feb 2010 16:09:50 -0800
parents 4b4e282a3146
children af18e3956985
files test/tools/javac/treepostests/TreePosTest.java
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javac/treepostests/TreePosTest.java	Thu Feb 04 10:14:28 2010 -0800
+++ b/test/tools/javac/treepostests/TreePosTest.java	Mon Feb 15 16:09:50 2010 -0800
@@ -98,7 +98,7 @@
  * @test
  * @bug 6919889
  * @summary assorted position errors in compiler syntax trees
- * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations  .
+ * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
  */
 public class TreePosTest {
     /**
@@ -150,6 +150,8 @@
                 tags.add(args[++i]);
             else if (arg.equals("-ef") && i + 1 < args.length)
                 excludeFiles.add(new File(baseDir, args[++i]));
+            else if (arg.equals("-et") && i + 1 < args.length)
+                excludeTags.add(args[++i]);
             else if (arg.equals("-r")) {
                 if (excludeFiles.size() > 0)
                     throw new Error("-r must be used before -ef");
@@ -199,6 +201,7 @@
         out.println("-t tag    Limit checks to tree nodes with this tag");
         out.println("          Can be repeated if desired");
         out.println("-ef file  Exclude file or directory");
+        out.println("-et tag   Exclude tree nodes with given tag name");
         out.println("");
         out.println("files may be directories or files");
         out.println("directories will be scanned recursively");
@@ -304,6 +307,8 @@
     Set<String> tags = new HashSet<String>();
     /** Set of files and directories to be excluded from analysis. */
     Set<File> excludeFiles = new HashSet<File>();
+    /** Set of tag names to be excluded from analysis. */
+    Set<String> excludeTags = new HashSet<String>();
     /** Table of printable names for tree tag values. */
     TagNames tagNames = new TagNames();
 
@@ -324,7 +329,7 @@
                 return;
 
             Info self = new Info(tree, endPosTable);
-            if (check(self)) {
+            if (check(encl, self)) {
                 // Modifiers nodes are present throughout the tree even where
                 // there is no corresponding source text.
                 // Redundant semicolons in a class definition can cause empty
@@ -392,8 +397,13 @@
                 super.visitVarDef(tree);
         }
 
-        boolean check(Info x) {
-            return tags.size() == 0 || tags.contains(tagNames.get(x.tag));
+        boolean check(Info encl, Info self) {
+            if (excludeTags.size() > 0) {
+                if (encl != null && excludeTags.contains(tagNames.get(encl.tag))
+                        || excludeTags.contains(tagNames.get(self.tag)))
+                    return false;
+            }
+            return tags.size() == 0 || tags.contains(tagNames.get(self.tag));
         }
 
         void check(String label, Info encl, Info self, boolean ok) {