提交 d318761e 编写于 作者: J jjg

6926555: 6921979 breaks TreePosTest

Reviewed-by: darcy
上级 e6ca4d91
...@@ -98,7 +98,7 @@ import static com.sun.tools.javac.util.Position.NOPOS; ...@@ -98,7 +98,7 @@ import static com.sun.tools.javac.util.Position.NOPOS;
* @test * @test
* @bug 6919889 * @bug 6919889
* @summary assorted position errors in compiler syntax trees * @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 { public class TreePosTest {
/** /**
...@@ -150,6 +150,8 @@ public class TreePosTest { ...@@ -150,6 +150,8 @@ public class TreePosTest {
tags.add(args[++i]); tags.add(args[++i]);
else if (arg.equals("-ef") && i + 1 < args.length) else if (arg.equals("-ef") && i + 1 < args.length)
excludeFiles.add(new File(baseDir, args[++i])); 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")) { else if (arg.equals("-r")) {
if (excludeFiles.size() > 0) if (excludeFiles.size() > 0)
throw new Error("-r must be used before -ef"); throw new Error("-r must be used before -ef");
...@@ -199,6 +201,7 @@ public class TreePosTest { ...@@ -199,6 +201,7 @@ public class TreePosTest {
out.println("-t tag Limit checks to tree nodes with this tag"); out.println("-t tag Limit checks to tree nodes with this tag");
out.println(" Can be repeated if desired"); out.println(" Can be repeated if desired");
out.println("-ef file Exclude file or directory"); out.println("-ef file Exclude file or directory");
out.println("-et tag Exclude tree nodes with given tag name");
out.println(""); out.println("");
out.println("files may be directories or files"); out.println("files may be directories or files");
out.println("directories will be scanned recursively"); out.println("directories will be scanned recursively");
...@@ -304,6 +307,8 @@ public class TreePosTest { ...@@ -304,6 +307,8 @@ public class TreePosTest {
Set<String> tags = new HashSet<String>(); Set<String> tags = new HashSet<String>();
/** Set of files and directories to be excluded from analysis. */ /** Set of files and directories to be excluded from analysis. */
Set<File> excludeFiles = new HashSet<File>(); 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. */ /** Table of printable names for tree tag values. */
TagNames tagNames = new TagNames(); TagNames tagNames = new TagNames();
...@@ -324,7 +329,7 @@ public class TreePosTest { ...@@ -324,7 +329,7 @@ public class TreePosTest {
return; return;
Info self = new Info(tree, endPosTable); Info self = new Info(tree, endPosTable);
if (check(self)) { if (check(encl, self)) {
// Modifiers nodes are present throughout the tree even where // Modifiers nodes are present throughout the tree even where
// there is no corresponding source text. // there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty // Redundant semicolons in a class definition can cause empty
...@@ -392,8 +397,13 @@ public class TreePosTest { ...@@ -392,8 +397,13 @@ public class TreePosTest {
super.visitVarDef(tree); super.visitVarDef(tree);
} }
boolean check(Info x) { boolean check(Info encl, Info self) {
return tags.size() == 0 || tags.contains(tagNames.get(x.tag)); 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) { void check(String label, Info encl, Info self, boolean ok) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册