49429
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, Google LLC. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package com.sun.tools.javac.comp;
|
|
27 |
|
|
28 |
import com.sun.tools.javac.code.Symbol;
|
|
29 |
import com.sun.tools.javac.tree.JCTree;
|
|
30 |
import com.sun.tools.javac.tree.JCTree.JCAnnotatedType;
|
|
31 |
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
|
|
32 |
import com.sun.tools.javac.tree.JCTree.JCArrayAccess;
|
|
33 |
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
|
|
34 |
import com.sun.tools.javac.tree.JCTree.JCAssert;
|
|
35 |
import com.sun.tools.javac.tree.JCTree.JCAssign;
|
|
36 |
import com.sun.tools.javac.tree.JCTree.JCAssignOp;
|
|
37 |
import com.sun.tools.javac.tree.JCTree.JCBinary;
|
|
38 |
import com.sun.tools.javac.tree.JCTree.JCBlock;
|
|
39 |
import com.sun.tools.javac.tree.JCTree.JCBreak;
|
|
40 |
import com.sun.tools.javac.tree.JCTree.JCCase;
|
|
41 |
import com.sun.tools.javac.tree.JCTree.JCCatch;
|
|
42 |
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
|
43 |
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
|
44 |
import com.sun.tools.javac.tree.JCTree.JCConditional;
|
|
45 |
import com.sun.tools.javac.tree.JCTree.JCContinue;
|
|
46 |
import com.sun.tools.javac.tree.JCTree.JCDoWhileLoop;
|
|
47 |
import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop;
|
|
48 |
import com.sun.tools.javac.tree.JCTree.JCErroneous;
|
|
49 |
import com.sun.tools.javac.tree.JCTree.JCExports;
|
|
50 |
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
|
|
51 |
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
|
|
52 |
import com.sun.tools.javac.tree.JCTree.JCForLoop;
|
|
53 |
import com.sun.tools.javac.tree.JCTree.JCIdent;
|
|
54 |
import com.sun.tools.javac.tree.JCTree.JCIf;
|
|
55 |
import com.sun.tools.javac.tree.JCTree.JCImport;
|
|
56 |
import com.sun.tools.javac.tree.JCTree.JCInstanceOf;
|
|
57 |
import com.sun.tools.javac.tree.JCTree.JCLabeledStatement;
|
|
58 |
import com.sun.tools.javac.tree.JCTree.JCLambda;
|
|
59 |
import com.sun.tools.javac.tree.JCTree.JCLiteral;
|
|
60 |
import com.sun.tools.javac.tree.JCTree.JCMemberReference;
|
|
61 |
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
|
62 |
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
|
63 |
import com.sun.tools.javac.tree.JCTree.JCModifiers;
|
|
64 |
import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
|
|
65 |
import com.sun.tools.javac.tree.JCTree.JCNewArray;
|
|
66 |
import com.sun.tools.javac.tree.JCTree.JCNewClass;
|
|
67 |
import com.sun.tools.javac.tree.JCTree.JCOpens;
|
|
68 |
import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
|
|
69 |
import com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree;
|
|
70 |
import com.sun.tools.javac.tree.JCTree.JCProvides;
|
|
71 |
import com.sun.tools.javac.tree.JCTree.JCRequires;
|
|
72 |
import com.sun.tools.javac.tree.JCTree.JCReturn;
|
|
73 |
import com.sun.tools.javac.tree.JCTree.JCSwitch;
|
|
74 |
import com.sun.tools.javac.tree.JCTree.JCSynchronized;
|
|
75 |
import com.sun.tools.javac.tree.JCTree.JCThrow;
|
|
76 |
import com.sun.tools.javac.tree.JCTree.JCTry;
|
|
77 |
import com.sun.tools.javac.tree.JCTree.JCTypeApply;
|
|
78 |
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
|
|
79 |
import com.sun.tools.javac.tree.JCTree.JCTypeIntersection;
|
|
80 |
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
|
|
81 |
import com.sun.tools.javac.tree.JCTree.JCTypeUnion;
|
|
82 |
import com.sun.tools.javac.tree.JCTree.JCUnary;
|
|
83 |
import com.sun.tools.javac.tree.JCTree.JCUses;
|
|
84 |
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
|
85 |
import com.sun.tools.javac.tree.JCTree.JCWhileLoop;
|
|
86 |
import com.sun.tools.javac.tree.JCTree.JCWildcard;
|
|
87 |
import com.sun.tools.javac.tree.JCTree.LetExpr;
|
|
88 |
import com.sun.tools.javac.tree.JCTree.TypeBoundKind;
|
|
89 |
import com.sun.tools.javac.tree.TreeInfo;
|
|
90 |
import com.sun.tools.javac.tree.TreeScanner;
|
|
91 |
import com.sun.tools.javac.util.List;
|
|
92 |
|
|
93 |
import javax.lang.model.element.ElementKind;
|
|
94 |
import java.util.Iterator;
|
|
95 |
import java.util.Objects;
|
|
96 |
import java.util.function.BiFunction;
|
|
97 |
import java.util.function.Consumer;
|
|
98 |
|
|
99 |
/** A visitor that compares two lambda bodies for structural equality. */
|
|
100 |
public class TreeDiffer extends TreeScanner {
|
|
101 |
|
|
102 |
private BiFunction<Symbol, Symbol, Boolean> symbolDiffer;
|
|
103 |
|
|
104 |
public TreeDiffer(BiFunction<Symbol, Symbol, Boolean> symbolDiffer) {
|
|
105 |
this.symbolDiffer = Objects.requireNonNull(symbolDiffer);
|
|
106 |
}
|
|
107 |
|
|
108 |
private JCTree parameter;
|
|
109 |
private boolean result;
|
|
110 |
|
|
111 |
public boolean scan(JCTree tree, JCTree parameter) {
|
|
112 |
if (tree == null || parameter == null) {
|
|
113 |
return tree == null && parameter == null;
|
|
114 |
}
|
|
115 |
tree = TreeInfo.skipParens(tree);
|
|
116 |
parameter = TreeInfo.skipParens(parameter);
|
|
117 |
if (tree.type != null
|
|
118 |
&& tree.type.constValue() != null
|
|
119 |
&& parameter.type != null
|
|
120 |
&& parameter.type.constValue() != null) {
|
|
121 |
return Objects.equals(tree.type.constValue(), parameter.type.constValue());
|
|
122 |
}
|
|
123 |
if (tree.getTag() != parameter.getTag()) {
|
|
124 |
return false;
|
|
125 |
}
|
|
126 |
JCTree prevParameter = this.parameter;
|
|
127 |
boolean prevResult = this.result;
|
|
128 |
try {
|
|
129 |
this.parameter = parameter;
|
|
130 |
tree.accept(this);
|
|
131 |
return result;
|
|
132 |
} finally {
|
|
133 |
this.parameter = prevParameter;
|
|
134 |
this.result = prevResult;
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
private boolean scan(Iterable<? extends JCTree> xs, Iterable<? extends JCTree> ys) {
|
|
139 |
if (xs == null || ys == null) {
|
|
140 |
return xs == null && ys == null;
|
|
141 |
}
|
|
142 |
Iterator<? extends JCTree> x = xs.iterator();
|
|
143 |
Iterator<? extends JCTree> y = ys.iterator();
|
|
144 |
while (x.hasNext() && y.hasNext()) {
|
|
145 |
if (!scan(x.next(), y.next())) {
|
|
146 |
return false;
|
|
147 |
}
|
|
148 |
}
|
|
149 |
return !x.hasNext() && !y.hasNext();
|
|
150 |
}
|
|
151 |
|
|
152 |
private boolean scanDimAnnotations(List<List<JCAnnotation>> xs, List<List<JCAnnotation>> ys) {
|
|
153 |
if (xs == null || ys == null) {
|
|
154 |
return xs == null && ys == null;
|
|
155 |
}
|
|
156 |
Iterator<List<JCAnnotation>> x = xs.iterator();
|
|
157 |
Iterator<List<JCAnnotation>> y = ys.iterator();
|
|
158 |
while (x.hasNext() && y.hasNext()) {
|
|
159 |
if (!scan(x.next(), y.next())) {
|
|
160 |
return false;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
return !x.hasNext() && !y.hasNext();
|
|
164 |
}
|
|
165 |
|
|
166 |
@Override
|
|
167 |
public void visitIdent(JCIdent tree) {
|
|
168 |
JCIdent that = (JCIdent) parameter;
|
|
169 |
// Identifiers are a special case: we want to ensure the identifiers correspond to the
|
|
170 |
// same symbols (rather than just having the same name), but also consider lambdas
|
|
171 |
// equal if they differ only in the names of the parameters.
|
|
172 |
Symbol symbol = tree.sym;
|
|
173 |
Symbol otherSymbol = that.sym;
|
|
174 |
if (symbol != null && otherSymbol != null) {
|
|
175 |
Boolean tmp = symbolDiffer.apply(symbol, otherSymbol);
|
|
176 |
if (tmp != null) {
|
|
177 |
result = tmp;
|
|
178 |
return;
|
|
179 |
}
|
|
180 |
}
|
|
181 |
result = tree.sym == that.sym;
|
|
182 |
}
|
|
183 |
|
|
184 |
@Override
|
|
185 |
public void visitSelect(JCFieldAccess tree) {
|
|
186 |
JCFieldAccess that = (JCFieldAccess) parameter;
|
|
187 |
result = scan(tree.selected, that.selected) && tree.sym == that.sym;
|
|
188 |
}
|
|
189 |
|
|
190 |
@Override
|
|
191 |
public void visitAnnotatedType(JCAnnotatedType tree) {
|
|
192 |
JCAnnotatedType that = (JCAnnotatedType) parameter;
|
|
193 |
result =
|
|
194 |
scan(tree.annotations, that.annotations)
|
|
195 |
&& scan(tree.underlyingType, that.underlyingType);
|
|
196 |
}
|
|
197 |
|
|
198 |
@Override
|
|
199 |
public void visitAnnotation(JCAnnotation tree) {
|
|
200 |
JCAnnotation that = (JCAnnotation) parameter;
|
|
201 |
result = scan(tree.annotationType, that.annotationType) && scan(tree.args, that.args);
|
|
202 |
}
|
|
203 |
|
|
204 |
@Override
|
|
205 |
public void visitApply(JCMethodInvocation tree) {
|
|
206 |
JCMethodInvocation that = (JCMethodInvocation) parameter;
|
|
207 |
result =
|
|
208 |
scan(tree.typeargs, that.typeargs)
|
|
209 |
&& scan(tree.meth, that.meth)
|
|
210 |
&& scan(tree.args, that.args)
|
|
211 |
&& tree.polyKind == that.polyKind;
|
|
212 |
}
|
|
213 |
|
|
214 |
@Override
|
|
215 |
public void visitAssert(JCAssert tree) {
|
|
216 |
JCAssert that = (JCAssert) parameter;
|
|
217 |
result = scan(tree.cond, that.cond) && scan(tree.detail, that.detail);
|
|
218 |
}
|
|
219 |
|
|
220 |
@Override
|
|
221 |
public void visitAssign(JCAssign tree) {
|
|
222 |
JCAssign that = (JCAssign) parameter;
|
|
223 |
result = scan(tree.lhs, that.lhs) && scan(tree.rhs, that.rhs);
|
|
224 |
}
|
|
225 |
|
|
226 |
@Override
|
|
227 |
public void visitAssignop(JCAssignOp tree) {
|
|
228 |
JCAssignOp that = (JCAssignOp) parameter;
|
|
229 |
result =
|
|
230 |
scan(tree.lhs, that.lhs)
|
|
231 |
&& scan(tree.rhs, that.rhs)
|
|
232 |
&& tree.operator == that.operator;
|
|
233 |
}
|
|
234 |
|
|
235 |
@Override
|
|
236 |
public void visitBinary(JCBinary tree) {
|
|
237 |
JCBinary that = (JCBinary) parameter;
|
|
238 |
result =
|
|
239 |
scan(tree.lhs, that.lhs)
|
|
240 |
&& scan(tree.rhs, that.rhs)
|
|
241 |
&& tree.operator == that.operator;
|
|
242 |
}
|
|
243 |
|
|
244 |
@Override
|
|
245 |
public void visitBlock(JCBlock tree) {
|
|
246 |
JCBlock that = (JCBlock) parameter;
|
|
247 |
result = tree.flags == that.flags && scan(tree.stats, that.stats);
|
|
248 |
}
|
|
249 |
|
|
250 |
@Override
|
|
251 |
public void visitBreak(JCBreak tree) {
|
|
252 |
JCBreak that = (JCBreak) parameter;
|
|
253 |
result = tree.label == that.label;
|
|
254 |
}
|
|
255 |
|
|
256 |
@Override
|
|
257 |
public void visitCase(JCCase tree) {
|
|
258 |
JCCase that = (JCCase) parameter;
|
|
259 |
result = scan(tree.pat, that.pat) && scan(tree.stats, that.stats);
|
|
260 |
}
|
|
261 |
|
|
262 |
@Override
|
|
263 |
public void visitCatch(JCCatch tree) {
|
|
264 |
JCCatch that = (JCCatch) parameter;
|
|
265 |
result = scan(tree.param, that.param) && scan(tree.body, that.body);
|
|
266 |
}
|
|
267 |
|
|
268 |
@Override
|
|
269 |
public void visitClassDef(JCClassDecl tree) {
|
|
270 |
JCClassDecl that = (JCClassDecl) parameter;
|
|
271 |
result =
|
|
272 |
scan(tree.mods, that.mods)
|
|
273 |
&& tree.name == that.name
|
|
274 |
&& scan(tree.typarams, that.typarams)
|
|
275 |
&& scan(tree.extending, that.extending)
|
|
276 |
&& scan(tree.implementing, that.implementing)
|
|
277 |
&& scan(tree.defs, that.defs);
|
|
278 |
}
|
|
279 |
|
|
280 |
@Override
|
|
281 |
public void visitConditional(JCConditional tree) {
|
|
282 |
JCConditional that = (JCConditional) parameter;
|
|
283 |
result =
|
|
284 |
scan(tree.cond, that.cond)
|
|
285 |
&& scan(tree.truepart, that.truepart)
|
|
286 |
&& scan(tree.falsepart, that.falsepart);
|
|
287 |
}
|
|
288 |
|
|
289 |
@Override
|
|
290 |
public void visitContinue(JCContinue tree) {
|
|
291 |
JCContinue that = (JCContinue) parameter;
|
|
292 |
result = tree.label == that.label;
|
|
293 |
}
|
|
294 |
|
|
295 |
@Override
|
|
296 |
public void visitDoLoop(JCDoWhileLoop tree) {
|
|
297 |
JCDoWhileLoop that = (JCDoWhileLoop) parameter;
|
|
298 |
result = scan(tree.body, that.body) && scan(tree.cond, that.cond);
|
|
299 |
}
|
|
300 |
|
|
301 |
@Override
|
|
302 |
public void visitErroneous(JCErroneous tree) {
|
|
303 |
JCErroneous that = (JCErroneous) parameter;
|
|
304 |
result = scan(tree.errs, that.errs);
|
|
305 |
}
|
|
306 |
|
|
307 |
@Override
|
|
308 |
public void visitExec(JCExpressionStatement tree) {
|
|
309 |
JCExpressionStatement that = (JCExpressionStatement) parameter;
|
|
310 |
result = scan(tree.expr, that.expr);
|
|
311 |
}
|
|
312 |
|
|
313 |
@Override
|
|
314 |
public void visitExports(JCExports tree) {
|
|
315 |
JCExports that = (JCExports) parameter;
|
|
316 |
result = scan(tree.qualid, that.qualid) && scan(tree.moduleNames, that.moduleNames);
|
|
317 |
}
|
|
318 |
|
|
319 |
@Override
|
|
320 |
public void visitForLoop(JCForLoop tree) {
|
|
321 |
JCForLoop that = (JCForLoop) parameter;
|
|
322 |
result =
|
|
323 |
scan(tree.init, that.init)
|
|
324 |
&& scan(tree.cond, that.cond)
|
|
325 |
&& scan(tree.step, that.step)
|
|
326 |
&& scan(tree.body, that.body);
|
|
327 |
}
|
|
328 |
|
|
329 |
@Override
|
|
330 |
public void visitForeachLoop(JCEnhancedForLoop tree) {
|
|
331 |
JCEnhancedForLoop that = (JCEnhancedForLoop) parameter;
|
|
332 |
result =
|
|
333 |
scan(tree.var, that.var)
|
|
334 |
&& scan(tree.expr, that.expr)
|
|
335 |
&& scan(tree.body, that.body);
|
|
336 |
}
|
|
337 |
|
|
338 |
@Override
|
|
339 |
public void visitIf(JCIf tree) {
|
|
340 |
JCIf that = (JCIf) parameter;
|
|
341 |
result =
|
|
342 |
scan(tree.cond, that.cond)
|
|
343 |
&& scan(tree.thenpart, that.thenpart)
|
|
344 |
&& scan(tree.elsepart, that.elsepart);
|
|
345 |
}
|
|
346 |
|
|
347 |
@Override
|
|
348 |
public void visitImport(JCImport tree) {
|
|
349 |
JCImport that = (JCImport) parameter;
|
|
350 |
result = tree.staticImport == that.staticImport && scan(tree.qualid, that.qualid);
|
|
351 |
}
|
|
352 |
|
|
353 |
@Override
|
|
354 |
public void visitIndexed(JCArrayAccess tree) {
|
|
355 |
JCArrayAccess that = (JCArrayAccess) parameter;
|
|
356 |
result = scan(tree.indexed, that.indexed) && scan(tree.index, that.index);
|
|
357 |
}
|
|
358 |
|
|
359 |
@Override
|
|
360 |
public void visitLabelled(JCLabeledStatement tree) {
|
|
361 |
JCLabeledStatement that = (JCLabeledStatement) parameter;
|
|
362 |
result = tree.label == that.label && scan(tree.body, that.body);
|
|
363 |
}
|
|
364 |
|
|
365 |
@Override
|
|
366 |
public void visitLambda(JCLambda tree) {
|
|
367 |
JCLambda that = (JCLambda) parameter;
|
|
368 |
result =
|
|
369 |
scan(tree.params, that.params)
|
|
370 |
&& scan(tree.body, that.body)
|
|
371 |
&& tree.paramKind == that.paramKind;
|
|
372 |
}
|
|
373 |
|
|
374 |
@Override
|
|
375 |
public void visitLetExpr(LetExpr tree) {
|
|
376 |
LetExpr that = (LetExpr) parameter;
|
|
377 |
result = scan(tree.defs, that.defs) && scan(tree.expr, that.expr);
|
|
378 |
}
|
|
379 |
|
|
380 |
@Override
|
|
381 |
public void visitLiteral(JCLiteral tree) {
|
|
382 |
JCLiteral that = (JCLiteral) parameter;
|
|
383 |
result = tree.typetag == that.typetag && Objects.equals(tree.value, that.value);
|
|
384 |
}
|
|
385 |
|
|
386 |
@Override
|
|
387 |
public void visitMethodDef(JCMethodDecl tree) {
|
|
388 |
JCMethodDecl that = (JCMethodDecl) parameter;
|
|
389 |
result =
|
|
390 |
scan(tree.mods, that.mods)
|
|
391 |
&& tree.name == that.name
|
|
392 |
&& scan(tree.restype, that.restype)
|
|
393 |
&& scan(tree.typarams, that.typarams)
|
|
394 |
&& scan(tree.recvparam, that.recvparam)
|
|
395 |
&& scan(tree.params, that.params)
|
|
396 |
&& scan(tree.thrown, that.thrown)
|
|
397 |
&& scan(tree.body, that.body)
|
|
398 |
&& scan(tree.defaultValue, that.defaultValue);
|
|
399 |
}
|
|
400 |
|
|
401 |
@Override
|
|
402 |
public void visitModifiers(JCModifiers tree) {
|
|
403 |
JCModifiers that = (JCModifiers) parameter;
|
|
404 |
result = tree.flags == that.flags && scan(tree.annotations, that.annotations);
|
|
405 |
}
|
|
406 |
|
|
407 |
@Override
|
|
408 |
public void visitModuleDef(JCModuleDecl tree) {
|
|
409 |
JCModuleDecl that = (JCModuleDecl) parameter;
|
|
410 |
result =
|
|
411 |
scan(tree.mods, that.mods)
|
|
412 |
&& scan(tree.qualId, that.qualId)
|
|
413 |
&& scan(tree.directives, that.directives);
|
|
414 |
}
|
|
415 |
|
|
416 |
@Override
|
|
417 |
public void visitNewArray(JCNewArray tree) {
|
|
418 |
JCNewArray that = (JCNewArray) parameter;
|
|
419 |
result =
|
|
420 |
scan(tree.elemtype, that.elemtype)
|
|
421 |
&& scan(tree.dims, that.dims)
|
|
422 |
&& scan(tree.annotations, that.annotations)
|
|
423 |
&& scanDimAnnotations(tree.dimAnnotations, that.dimAnnotations)
|
|
424 |
&& scan(tree.elems, that.elems);
|
|
425 |
}
|
|
426 |
|
|
427 |
@Override
|
|
428 |
public void visitNewClass(JCNewClass tree) {
|
|
429 |
JCNewClass that = (JCNewClass) parameter;
|
|
430 |
result =
|
|
431 |
scan(tree.encl, that.encl)
|
|
432 |
&& scan(tree.typeargs, that.typeargs)
|
|
433 |
&& scan(tree.clazz, that.clazz)
|
|
434 |
&& scan(tree.args, that.args)
|
|
435 |
&& scan(tree.def, that.def)
|
|
436 |
&& tree.constructor == that.constructor;
|
|
437 |
}
|
|
438 |
|
|
439 |
@Override
|
|
440 |
public void visitOpens(JCOpens tree) {
|
|
441 |
JCOpens that = (JCOpens) parameter;
|
|
442 |
result = scan(tree.qualid, that.qualid) && scan(tree.moduleNames, that.moduleNames);
|
|
443 |
}
|
|
444 |
|
|
445 |
@Override
|
|
446 |
public void visitPackageDef(JCPackageDecl tree) {
|
|
447 |
JCPackageDecl that = (JCPackageDecl) parameter;
|
|
448 |
result =
|
|
449 |
scan(tree.annotations, that.annotations)
|
|
450 |
&& scan(tree.pid, that.pid)
|
|
451 |
&& tree.packge == that.packge;
|
|
452 |
}
|
|
453 |
|
|
454 |
@Override
|
|
455 |
public void visitProvides(JCProvides tree) {
|
|
456 |
JCProvides that = (JCProvides) parameter;
|
|
457 |
result = scan(tree.serviceName, that.serviceName) && scan(tree.implNames, that.implNames);
|
|
458 |
}
|
|
459 |
|
|
460 |
@Override
|
|
461 |
public void visitReference(JCMemberReference tree) {
|
|
462 |
JCMemberReference that = (JCMemberReference) parameter;
|
|
463 |
result =
|
|
464 |
tree.mode == that.mode
|
|
465 |
&& tree.kind == that.kind
|
|
466 |
&& tree.name == that.name
|
|
467 |
&& scan(tree.expr, that.expr)
|
|
468 |
&& scan(tree.typeargs, that.typeargs);
|
|
469 |
}
|
|
470 |
|
|
471 |
@Override
|
|
472 |
public void visitRequires(JCRequires tree) {
|
|
473 |
JCRequires that = (JCRequires) parameter;
|
|
474 |
result =
|
|
475 |
tree.isTransitive == that.isTransitive
|
|
476 |
&& tree.isStaticPhase == that.isStaticPhase
|
|
477 |
&& scan(tree.moduleName, that.moduleName);
|
|
478 |
}
|
|
479 |
|
|
480 |
@Override
|
|
481 |
public void visitReturn(JCReturn tree) {
|
|
482 |
JCReturn that = (JCReturn) parameter;
|
|
483 |
result = scan(tree.expr, that.expr);
|
|
484 |
}
|
|
485 |
|
|
486 |
@Override
|
|
487 |
public void visitSwitch(JCSwitch tree) {
|
|
488 |
JCSwitch that = (JCSwitch) parameter;
|
|
489 |
result = scan(tree.selector, that.selector) && scan(tree.cases, that.cases);
|
|
490 |
}
|
|
491 |
|
|
492 |
@Override
|
|
493 |
public void visitSynchronized(JCSynchronized tree) {
|
|
494 |
JCSynchronized that = (JCSynchronized) parameter;
|
|
495 |
result = scan(tree.lock, that.lock) && scan(tree.body, that.body);
|
|
496 |
}
|
|
497 |
|
|
498 |
@Override
|
|
499 |
public void visitThrow(JCThrow tree) {
|
|
500 |
JCThrow that = (JCThrow) parameter;
|
|
501 |
result = scan(tree.expr, that.expr);
|
|
502 |
}
|
|
503 |
|
|
504 |
@Override
|
|
505 |
public void visitTopLevel(JCCompilationUnit tree) {
|
|
506 |
JCCompilationUnit that = (JCCompilationUnit) parameter;
|
|
507 |
result =
|
|
508 |
scan(tree.defs, that.defs)
|
|
509 |
&& tree.modle == that.modle
|
|
510 |
&& tree.packge == that.packge;
|
|
511 |
}
|
|
512 |
|
|
513 |
@Override
|
|
514 |
public void visitTry(JCTry tree) {
|
|
515 |
JCTry that = (JCTry) parameter;
|
|
516 |
result =
|
|
517 |
scan(tree.body, that.body)
|
|
518 |
&& scan(tree.catchers, that.catchers)
|
|
519 |
&& scan(tree.finalizer, that.finalizer)
|
|
520 |
&& scan(tree.resources, that.resources);
|
|
521 |
}
|
|
522 |
|
|
523 |
@Override
|
|
524 |
public void visitTypeApply(JCTypeApply tree) {
|
|
525 |
JCTypeApply that = (JCTypeApply) parameter;
|
|
526 |
result = scan(tree.clazz, that.clazz) && scan(tree.arguments, that.arguments);
|
|
527 |
}
|
|
528 |
|
|
529 |
@Override
|
|
530 |
public void visitTypeArray(JCArrayTypeTree tree) {
|
|
531 |
JCArrayTypeTree that = (JCArrayTypeTree) parameter;
|
|
532 |
result = scan(tree.elemtype, that.elemtype);
|
|
533 |
}
|
|
534 |
|
|
535 |
@Override
|
|
536 |
public void visitTypeBoundKind(TypeBoundKind tree) {
|
|
537 |
TypeBoundKind that = (TypeBoundKind) parameter;
|
|
538 |
result = tree.kind == that.kind;
|
|
539 |
}
|
|
540 |
|
|
541 |
@Override
|
|
542 |
public void visitTypeCast(JCTypeCast tree) {
|
|
543 |
JCTypeCast that = (JCTypeCast) parameter;
|
|
544 |
result = scan(tree.clazz, that.clazz) && scan(tree.expr, that.expr);
|
|
545 |
}
|
|
546 |
|
|
547 |
@Override
|
|
548 |
public void visitTypeIdent(JCPrimitiveTypeTree tree) {
|
|
549 |
JCPrimitiveTypeTree that = (JCPrimitiveTypeTree) parameter;
|
|
550 |
result = tree.typetag == that.typetag;
|
|
551 |
}
|
|
552 |
|
|
553 |
@Override
|
|
554 |
public void visitTypeIntersection(JCTypeIntersection tree) {
|
|
555 |
JCTypeIntersection that = (JCTypeIntersection) parameter;
|
|
556 |
result = scan(tree.bounds, that.bounds);
|
|
557 |
}
|
|
558 |
|
|
559 |
@Override
|
|
560 |
public void visitTypeParameter(JCTypeParameter tree) {
|
|
561 |
JCTypeParameter that = (JCTypeParameter) parameter;
|
|
562 |
result =
|
|
563 |
tree.name == that.name
|
|
564 |
&& scan(tree.bounds, that.bounds)
|
|
565 |
&& scan(tree.annotations, that.annotations);
|
|
566 |
}
|
|
567 |
|
|
568 |
@Override
|
|
569 |
public void visitTypeTest(JCInstanceOf tree) {
|
|
570 |
JCInstanceOf that = (JCInstanceOf) parameter;
|
|
571 |
result = scan(tree.expr, that.expr) && scan(tree.clazz, that.clazz);
|
|
572 |
}
|
|
573 |
|
|
574 |
@Override
|
|
575 |
public void visitTypeUnion(JCTypeUnion tree) {
|
|
576 |
JCTypeUnion that = (JCTypeUnion) parameter;
|
|
577 |
result = scan(tree.alternatives, that.alternatives);
|
|
578 |
}
|
|
579 |
|
|
580 |
@Override
|
|
581 |
public void visitUnary(JCUnary tree) {
|
|
582 |
JCUnary that = (JCUnary) parameter;
|
|
583 |
result = scan(tree.arg, that.arg) && tree.operator == that.operator;
|
|
584 |
}
|
|
585 |
|
|
586 |
@Override
|
|
587 |
public void visitUses(JCUses tree) {
|
|
588 |
JCUses that = (JCUses) parameter;
|
|
589 |
result = scan(tree.qualid, that.qualid);
|
|
590 |
}
|
|
591 |
|
|
592 |
@Override
|
|
593 |
public void visitVarDef(JCVariableDecl tree) {
|
|
594 |
JCVariableDecl that = (JCVariableDecl) parameter;
|
|
595 |
result =
|
|
596 |
scan(tree.mods, that.mods)
|
|
597 |
&& tree.name == that.name
|
|
598 |
&& scan(tree.nameexpr, that.nameexpr)
|
|
599 |
&& scan(tree.vartype, that.vartype)
|
|
600 |
&& scan(tree.init, that.init);
|
|
601 |
}
|
|
602 |
|
|
603 |
@Override
|
|
604 |
public void visitWhileLoop(JCWhileLoop tree) {
|
|
605 |
JCWhileLoop that = (JCWhileLoop) parameter;
|
|
606 |
result = scan(tree.cond, that.cond) && scan(tree.body, that.body);
|
|
607 |
}
|
|
608 |
|
|
609 |
@Override
|
|
610 |
public void visitWildcard(JCWildcard tree) {
|
|
611 |
JCWildcard that = (JCWildcard) parameter;
|
|
612 |
result = scan(tree.kind, that.kind) && scan(tree.inner, that.inner);
|
|
613 |
}
|
|
614 |
}
|