89 sourcefile = tree.sourcefile; |
89 sourcefile = tree.sourcefile; |
90 found = new HashSet<Tree>(); |
90 found = new HashSet<Tree>(); |
91 scan(tree, null); |
91 scan(tree, null); |
92 expect = new HashSet<Tree>(); |
92 expect = new HashSet<Tree>(); |
93 reflectiveScan(tree); |
93 reflectiveScan(tree); |
|
94 |
94 if (found.equals(expect)) { |
95 if (found.equals(expect)) { |
95 System.err.println(found.size() + " trees compared OK"); |
96 //System.err.println(sourcefile.getName() + ": trees compared OK"); |
96 return found.size(); |
97 return found.size(); |
97 } |
98 } |
98 |
99 |
99 error("Differences found for " + tree.sourcefile.getName()); |
100 error(sourcefile.getName() + ": differences found"); |
100 |
101 |
101 if (found.size() != expect.size()) |
102 if (found.size() != expect.size()) |
102 error("Size mismatch; found: " + found.size() + ", expected: " + expect.size()); |
103 error("Size mismatch; found: " + found.size() + ", expected: " + expect.size()); |
103 |
104 |
104 Set<Tree> missing = new HashSet<Tree>(); |
105 Set<Tree> missing = new HashSet<Tree>(); |
105 missing.addAll(expect); |
106 missing.addAll(expect); |
106 missing.removeAll(found); |
107 missing.removeAll(found); |
107 for (Tree t: missing) |
108 for (Tree t: missing) |
108 error(tree.sourcefile, t, "missing"); |
109 error(sourcefile, t, "missing"); |
109 |
110 |
110 Set<Tree> excess = new HashSet<Tree>(); |
111 Set<Tree> excess = new HashSet<Tree>(); |
111 excess.addAll(found); |
112 excess.addAll(found); |
112 excess.removeAll(expect); |
113 excess.removeAll(expect); |
113 for (Tree t: excess) |
114 for (Tree t: excess) |
114 error(tree.sourcefile, t, "unexpected"); |
115 error(sourcefile, t, "unexpected"); |
115 |
116 |
116 return 0; |
117 return 0; |
117 } |
118 } |
118 |
119 |
119 /** Record all tree nodes found by scanner. */ |
120 /** Record all tree nodes found by scanner. */ |
120 @Override |
121 @Override |
121 public Void scan(Tree tree, Void ignore) { |
122 public Void scan(Tree tree, Void ignore) { |
122 if (tree == null) |
123 if (tree == null) |
123 return null; |
124 return null; |
124 System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64)); |
125 //System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64)); |
125 found.add(tree); |
126 found.add(tree); |
126 return super.scan(tree, ignore); |
127 return super.scan(tree, ignore); |
127 } |
128 } |
128 |
129 |
129 /** record all tree nodes found by reflection. */ |
130 /** record all tree nodes found by reflection. */ |
130 public void reflectiveScan(Object o) { |
131 public void reflectiveScan(Object o) { |
131 if (o == null) |
132 if (o == null) |
132 return; |
133 return; |
133 if (o instanceof JCTree) { |
134 if (o instanceof JCTree) { |
134 JCTree tree = (JCTree) o; |
135 JCTree tree = (JCTree) o; |
135 System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); |
136 //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); |
136 expect.add(tree); |
137 expect.add(tree); |
137 for (Field f: getFields(tree)) { |
138 for (Field f: getFields(tree)) { |
138 if (TypeBoundKind.class.isAssignableFrom(f.getType())) { |
139 if (TypeBoundKind.class.isAssignableFrom(f.getType())) { |
139 // not part of public API |
140 // not part of public API |
140 continue; |
141 continue; |