1 | /* |
---|---|
2 | * Copyright (C) 2007-2010 JĂșlio Vilmar Gesser. |
3 | * Copyright (C) 2011, 2013-2020 The JavaParser Team. |
4 | * |
5 | * This file is part of JavaParser. |
6 | * |
7 | * JavaParser can be used either under the terms of |
8 | * a) the GNU Lesser General Public License as published by |
9 | * the Free Software Foundation, either version 3 of the License, or |
10 | * (at your option) any later version. |
11 | * b) the terms of the Apache License |
12 | * |
13 | * You should have received a copy of both licenses in LICENCE.LGPL and |
14 | * LICENCE.APACHE. Please refer to those files for details. |
15 | * |
16 | * JavaParser is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU Lesser General Public License for more details. |
20 | */ |
21 | package com.github.javaparser.ast.visitor; |
22 | |
23 | import com.github.javaparser.ast.*; |
24 | import com.github.javaparser.ast.body.*; |
25 | import com.github.javaparser.ast.comments.BlockComment; |
26 | import com.github.javaparser.ast.comments.JavadocComment; |
27 | import com.github.javaparser.ast.comments.LineComment; |
28 | import com.github.javaparser.ast.expr.*; |
29 | import com.github.javaparser.ast.modules.*; |
30 | import com.github.javaparser.ast.stmt.*; |
31 | import com.github.javaparser.ast.type.*; |
32 | import java.util.Optional; |
33 | |
34 | public class NoCommentEqualsVisitor implements GenericVisitor<Boolean, Visitable> { |
35 | |
36 | private static final NoCommentEqualsVisitor SINGLETON = new NoCommentEqualsVisitor(); |
37 | |
38 | public static boolean equals(final Node n, final Node n2) { |
39 | return SINGLETON.nodeEquals(n, n2); |
40 | } |
41 | |
42 | private <N extends Node> boolean nodesEquals(NodeList<N> n, NodeList<N> n2) { |
43 | if (n == n2) { |
44 | return true; |
45 | } |
46 | if (n == null || n2 == null) { |
47 | return false; |
48 | } |
49 | if (n.size() != n2.size()) { |
50 | return false; |
51 | } |
52 | for (int i = 0; i < n.size(); i++) { |
53 | if (!nodeEquals(n.get(i), n2.get(i))) { |
54 | return false; |
55 | } |
56 | } |
57 | return true; |
58 | } |
59 | |
60 | private <T extends Node> boolean nodeEquals(final T n, final T n2) { |
61 | if (n == n2) { |
62 | return true; |
63 | } |
64 | if (n == null || n2 == null) { |
65 | return false; |
66 | } |
67 | if (n.getClass() != n2.getClass()) { |
68 | return false; |
69 | } |
70 | return n.accept(this, n2); |
71 | } |
72 | |
73 | private <T extends Node> boolean nodeEquals(final Optional<T> n, final Optional<T> n2) { |
74 | return nodeEquals(n.orElse(null), n2.orElse(null)); |
75 | } |
76 | |
77 | private <T extends Node> boolean nodesEquals(final Optional<NodeList<T>> n, final Optional<NodeList<T>> n2) { |
78 | return nodesEquals(n.orElse(null), n2.orElse(null)); |
79 | } |
80 | |
81 | private boolean objEquals(final Object n, final Object n2) { |
82 | if (n == n2) { |
83 | return true; |
84 | } |
85 | if (n == null || n2 == null) { |
86 | return false; |
87 | } |
88 | return n.equals(n2); |
89 | } |
90 | |
91 | @Override |
92 | public Boolean visit(final CompilationUnit n, final Visitable arg) { |
93 | final CompilationUnit n2 = (CompilationUnit) arg; |
94 | if (!nodesEquals(n.getImports(), n2.getImports())) |
95 | return false; |
96 | if (!nodeEquals(n.getModule(), n2.getModule())) |
97 | return false; |
98 | if (!nodeEquals(n.getPackageDeclaration(), n2.getPackageDeclaration())) |
99 | return false; |
100 | if (!nodesEquals(n.getTypes(), n2.getTypes())) |
101 | return false; |
102 | return true; |
103 | } |
104 | |
105 | @Override |
106 | public Boolean visit(final PackageDeclaration n, final Visitable arg) { |
107 | final PackageDeclaration n2 = (PackageDeclaration) arg; |
108 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
109 | return false; |
110 | if (!nodeEquals(n.getName(), n2.getName())) |
111 | return false; |
112 | return true; |
113 | } |
114 | |
115 | @Override |
116 | public Boolean visit(final TypeParameter n, final Visitable arg) { |
117 | final TypeParameter n2 = (TypeParameter) arg; |
118 | if (!nodeEquals(n.getName(), n2.getName())) |
119 | return false; |
120 | if (!nodesEquals(n.getTypeBound(), n2.getTypeBound())) |
121 | return false; |
122 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
123 | return false; |
124 | return true; |
125 | } |
126 | |
127 | @Override |
128 | public Boolean visit(final LineComment n, final Visitable arg) { |
129 | return true; |
130 | } |
131 | |
132 | @Override |
133 | public Boolean visit(final BlockComment n, final Visitable arg) { |
134 | return true; |
135 | } |
136 | |
137 | @Override |
138 | public Boolean visit(final ClassOrInterfaceDeclaration n, final Visitable arg) { |
139 | final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg; |
140 | if (!nodesEquals(n.getExtendedTypes(), n2.getExtendedTypes())) |
141 | return false; |
142 | if (!nodesEquals(n.getImplementedTypes(), n2.getImplementedTypes())) |
143 | return false; |
144 | if (!objEquals(n.isInterface(), n2.isInterface())) |
145 | return false; |
146 | if (!nodesEquals(n.getTypeParameters(), n2.getTypeParameters())) |
147 | return false; |
148 | if (!nodesEquals(n.getMembers(), n2.getMembers())) |
149 | return false; |
150 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
151 | return false; |
152 | if (!nodeEquals(n.getName(), n2.getName())) |
153 | return false; |
154 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
155 | return false; |
156 | return true; |
157 | } |
158 | |
159 | @Override |
160 | public Boolean visit(final EnumDeclaration n, final Visitable arg) { |
161 | final EnumDeclaration n2 = (EnumDeclaration) arg; |
162 | if (!nodesEquals(n.getEntries(), n2.getEntries())) |
163 | return false; |
164 | if (!nodesEquals(n.getImplementedTypes(), n2.getImplementedTypes())) |
165 | return false; |
166 | if (!nodesEquals(n.getMembers(), n2.getMembers())) |
167 | return false; |
168 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
169 | return false; |
170 | if (!nodeEquals(n.getName(), n2.getName())) |
171 | return false; |
172 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
173 | return false; |
174 | return true; |
175 | } |
176 | |
177 | @Override |
178 | public Boolean visit(final EnumConstantDeclaration n, final Visitable arg) { |
179 | final EnumConstantDeclaration n2 = (EnumConstantDeclaration) arg; |
180 | if (!nodesEquals(n.getArguments(), n2.getArguments())) |
181 | return false; |
182 | if (!nodesEquals(n.getClassBody(), n2.getClassBody())) |
183 | return false; |
184 | if (!nodeEquals(n.getName(), n2.getName())) |
185 | return false; |
186 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
187 | return false; |
188 | return true; |
189 | } |
190 | |
191 | @Override |
192 | public Boolean visit(final AnnotationDeclaration n, final Visitable arg) { |
193 | final AnnotationDeclaration n2 = (AnnotationDeclaration) arg; |
194 | if (!nodesEquals(n.getMembers(), n2.getMembers())) |
195 | return false; |
196 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
197 | return false; |
198 | if (!nodeEquals(n.getName(), n2.getName())) |
199 | return false; |
200 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
201 | return false; |
202 | return true; |
203 | } |
204 | |
205 | @Override |
206 | public Boolean visit(final AnnotationMemberDeclaration n, final Visitable arg) { |
207 | final AnnotationMemberDeclaration n2 = (AnnotationMemberDeclaration) arg; |
208 | if (!nodeEquals(n.getDefaultValue(), n2.getDefaultValue())) |
209 | return false; |
210 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
211 | return false; |
212 | if (!nodeEquals(n.getName(), n2.getName())) |
213 | return false; |
214 | if (!nodeEquals(n.getType(), n2.getType())) |
215 | return false; |
216 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
217 | return false; |
218 | return true; |
219 | } |
220 | |
221 | @Override |
222 | public Boolean visit(final FieldDeclaration n, final Visitable arg) { |
223 | final FieldDeclaration n2 = (FieldDeclaration) arg; |
224 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
225 | return false; |
226 | if (!nodesEquals(n.getVariables(), n2.getVariables())) |
227 | return false; |
228 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
229 | return false; |
230 | return true; |
231 | } |
232 | |
233 | @Override |
234 | public Boolean visit(final VariableDeclarator n, final Visitable arg) { |
235 | final VariableDeclarator n2 = (VariableDeclarator) arg; |
236 | if (!nodeEquals(n.getInitializer(), n2.getInitializer())) |
237 | return false; |
238 | if (!nodeEquals(n.getName(), n2.getName())) |
239 | return false; |
240 | if (!nodeEquals(n.getType(), n2.getType())) |
241 | return false; |
242 | return true; |
243 | } |
244 | |
245 | @Override |
246 | public Boolean visit(final ConstructorDeclaration n, final Visitable arg) { |
247 | final ConstructorDeclaration n2 = (ConstructorDeclaration) arg; |
248 | if (!nodeEquals(n.getBody(), n2.getBody())) |
249 | return false; |
250 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
251 | return false; |
252 | if (!nodeEquals(n.getName(), n2.getName())) |
253 | return false; |
254 | if (!nodesEquals(n.getParameters(), n2.getParameters())) |
255 | return false; |
256 | if (!nodeEquals(n.getReceiverParameter(), n2.getReceiverParameter())) |
257 | return false; |
258 | if (!nodesEquals(n.getThrownExceptions(), n2.getThrownExceptions())) |
259 | return false; |
260 | if (!nodesEquals(n.getTypeParameters(), n2.getTypeParameters())) |
261 | return false; |
262 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
263 | return false; |
264 | return true; |
265 | } |
266 | |
267 | @Override |
268 | public Boolean visit(final MethodDeclaration n, final Visitable arg) { |
269 | final MethodDeclaration n2 = (MethodDeclaration) arg; |
270 | if (!nodeEquals(n.getBody(), n2.getBody())) |
271 | return false; |
272 | if (!nodeEquals(n.getType(), n2.getType())) |
273 | return false; |
274 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
275 | return false; |
276 | if (!nodeEquals(n.getName(), n2.getName())) |
277 | return false; |
278 | if (!nodesEquals(n.getParameters(), n2.getParameters())) |
279 | return false; |
280 | if (!nodeEquals(n.getReceiverParameter(), n2.getReceiverParameter())) |
281 | return false; |
282 | if (!nodesEquals(n.getThrownExceptions(), n2.getThrownExceptions())) |
283 | return false; |
284 | if (!nodesEquals(n.getTypeParameters(), n2.getTypeParameters())) |
285 | return false; |
286 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
287 | return false; |
288 | return true; |
289 | } |
290 | |
291 | @Override |
292 | public Boolean visit(final Parameter n, final Visitable arg) { |
293 | final Parameter n2 = (Parameter) arg; |
294 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
295 | return false; |
296 | if (!objEquals(n.isVarArgs(), n2.isVarArgs())) |
297 | return false; |
298 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
299 | return false; |
300 | if (!nodeEquals(n.getName(), n2.getName())) |
301 | return false; |
302 | if (!nodeEquals(n.getType(), n2.getType())) |
303 | return false; |
304 | if (!nodesEquals(n.getVarArgsAnnotations(), n2.getVarArgsAnnotations())) |
305 | return false; |
306 | return true; |
307 | } |
308 | |
309 | @Override |
310 | public Boolean visit(final InitializerDeclaration n, final Visitable arg) { |
311 | final InitializerDeclaration n2 = (InitializerDeclaration) arg; |
312 | if (!nodeEquals(n.getBody(), n2.getBody())) |
313 | return false; |
314 | if (!objEquals(n.isStatic(), n2.isStatic())) |
315 | return false; |
316 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
317 | return false; |
318 | return true; |
319 | } |
320 | |
321 | @Override |
322 | public Boolean visit(final JavadocComment n, final Visitable arg) { |
323 | return true; |
324 | } |
325 | |
326 | @Override |
327 | public Boolean visit(final ClassOrInterfaceType n, final Visitable arg) { |
328 | final ClassOrInterfaceType n2 = (ClassOrInterfaceType) arg; |
329 | if (!nodeEquals(n.getName(), n2.getName())) |
330 | return false; |
331 | if (!nodeEquals(n.getScope(), n2.getScope())) |
332 | return false; |
333 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
334 | return false; |
335 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
336 | return false; |
337 | return true; |
338 | } |
339 | |
340 | @Override |
341 | public Boolean visit(final PrimitiveType n, final Visitable arg) { |
342 | final PrimitiveType n2 = (PrimitiveType) arg; |
343 | if (!objEquals(n.getType(), n2.getType())) |
344 | return false; |
345 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
346 | return false; |
347 | return true; |
348 | } |
349 | |
350 | @Override |
351 | public Boolean visit(final ArrayType n, final Visitable arg) { |
352 | final ArrayType n2 = (ArrayType) arg; |
353 | if (!nodeEquals(n.getComponentType(), n2.getComponentType())) |
354 | return false; |
355 | if (!objEquals(n.getOrigin(), n2.getOrigin())) |
356 | return false; |
357 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
358 | return false; |
359 | return true; |
360 | } |
361 | |
362 | @Override |
363 | public Boolean visit(final ArrayCreationLevel n, final Visitable arg) { |
364 | final ArrayCreationLevel n2 = (ArrayCreationLevel) arg; |
365 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
366 | return false; |
367 | if (!nodeEquals(n.getDimension(), n2.getDimension())) |
368 | return false; |
369 | return true; |
370 | } |
371 | |
372 | @Override |
373 | public Boolean visit(final IntersectionType n, final Visitable arg) { |
374 | final IntersectionType n2 = (IntersectionType) arg; |
375 | if (!nodesEquals(n.getElements(), n2.getElements())) |
376 | return false; |
377 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
378 | return false; |
379 | return true; |
380 | } |
381 | |
382 | @Override |
383 | public Boolean visit(final UnionType n, final Visitable arg) { |
384 | final UnionType n2 = (UnionType) arg; |
385 | if (!nodesEquals(n.getElements(), n2.getElements())) |
386 | return false; |
387 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
388 | return false; |
389 | return true; |
390 | } |
391 | |
392 | @Override |
393 | public Boolean visit(final VoidType n, final Visitable arg) { |
394 | final VoidType n2 = (VoidType) arg; |
395 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
396 | return false; |
397 | return true; |
398 | } |
399 | |
400 | @Override |
401 | public Boolean visit(final WildcardType n, final Visitable arg) { |
402 | final WildcardType n2 = (WildcardType) arg; |
403 | if (!nodeEquals(n.getExtendedType(), n2.getExtendedType())) |
404 | return false; |
405 | if (!nodeEquals(n.getSuperType(), n2.getSuperType())) |
406 | return false; |
407 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
408 | return false; |
409 | return true; |
410 | } |
411 | |
412 | @Override |
413 | public Boolean visit(final UnknownType n, final Visitable arg) { |
414 | final UnknownType n2 = (UnknownType) arg; |
415 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
416 | return false; |
417 | return true; |
418 | } |
419 | |
420 | @Override |
421 | public Boolean visit(final ArrayAccessExpr n, final Visitable arg) { |
422 | final ArrayAccessExpr n2 = (ArrayAccessExpr) arg; |
423 | if (!nodeEquals(n.getIndex(), n2.getIndex())) |
424 | return false; |
425 | if (!nodeEquals(n.getName(), n2.getName())) |
426 | return false; |
427 | return true; |
428 | } |
429 | |
430 | @Override |
431 | public Boolean visit(final ArrayCreationExpr n, final Visitable arg) { |
432 | final ArrayCreationExpr n2 = (ArrayCreationExpr) arg; |
433 | if (!nodeEquals(n.getElementType(), n2.getElementType())) |
434 | return false; |
435 | if (!nodeEquals(n.getInitializer(), n2.getInitializer())) |
436 | return false; |
437 | if (!nodesEquals(n.getLevels(), n2.getLevels())) |
438 | return false; |
439 | return true; |
440 | } |
441 | |
442 | @Override |
443 | public Boolean visit(final ArrayInitializerExpr n, final Visitable arg) { |
444 | final ArrayInitializerExpr n2 = (ArrayInitializerExpr) arg; |
445 | if (!nodesEquals(n.getValues(), n2.getValues())) |
446 | return false; |
447 | return true; |
448 | } |
449 | |
450 | @Override |
451 | public Boolean visit(final AssignExpr n, final Visitable arg) { |
452 | final AssignExpr n2 = (AssignExpr) arg; |
453 | if (!objEquals(n.getOperator(), n2.getOperator())) |
454 | return false; |
455 | if (!nodeEquals(n.getTarget(), n2.getTarget())) |
456 | return false; |
457 | if (!nodeEquals(n.getValue(), n2.getValue())) |
458 | return false; |
459 | return true; |
460 | } |
461 | |
462 | @Override |
463 | public Boolean visit(final BinaryExpr n, final Visitable arg) { |
464 | final BinaryExpr n2 = (BinaryExpr) arg; |
465 | if (!nodeEquals(n.getLeft(), n2.getLeft())) |
466 | return false; |
467 | if (!objEquals(n.getOperator(), n2.getOperator())) |
468 | return false; |
469 | if (!nodeEquals(n.getRight(), n2.getRight())) |
470 | return false; |
471 | return true; |
472 | } |
473 | |
474 | @Override |
475 | public Boolean visit(final CastExpr n, final Visitable arg) { |
476 | final CastExpr n2 = (CastExpr) arg; |
477 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
478 | return false; |
479 | if (!nodeEquals(n.getType(), n2.getType())) |
480 | return false; |
481 | return true; |
482 | } |
483 | |
484 | @Override |
485 | public Boolean visit(final ClassExpr n, final Visitable arg) { |
486 | final ClassExpr n2 = (ClassExpr) arg; |
487 | if (!nodeEquals(n.getType(), n2.getType())) |
488 | return false; |
489 | return true; |
490 | } |
491 | |
492 | @Override |
493 | public Boolean visit(final ConditionalExpr n, final Visitable arg) { |
494 | final ConditionalExpr n2 = (ConditionalExpr) arg; |
495 | if (!nodeEquals(n.getCondition(), n2.getCondition())) |
496 | return false; |
497 | if (!nodeEquals(n.getElseExpr(), n2.getElseExpr())) |
498 | return false; |
499 | if (!nodeEquals(n.getThenExpr(), n2.getThenExpr())) |
500 | return false; |
501 | return true; |
502 | } |
503 | |
504 | @Override |
505 | public Boolean visit(final EnclosedExpr n, final Visitable arg) { |
506 | final EnclosedExpr n2 = (EnclosedExpr) arg; |
507 | if (!nodeEquals(n.getInner(), n2.getInner())) |
508 | return false; |
509 | return true; |
510 | } |
511 | |
512 | @Override |
513 | public Boolean visit(final FieldAccessExpr n, final Visitable arg) { |
514 | final FieldAccessExpr n2 = (FieldAccessExpr) arg; |
515 | if (!nodeEquals(n.getName(), n2.getName())) |
516 | return false; |
517 | if (!nodeEquals(n.getScope(), n2.getScope())) |
518 | return false; |
519 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
520 | return false; |
521 | return true; |
522 | } |
523 | |
524 | @Override |
525 | public Boolean visit(final InstanceOfExpr n, final Visitable arg) { |
526 | final InstanceOfExpr n2 = (InstanceOfExpr) arg; |
527 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
528 | return false; |
529 | if (!nodeEquals(n.getType(), n2.getType())) |
530 | return false; |
531 | return true; |
532 | } |
533 | |
534 | @Override |
535 | public Boolean visit(final StringLiteralExpr n, final Visitable arg) { |
536 | final StringLiteralExpr n2 = (StringLiteralExpr) arg; |
537 | if (!objEquals(n.getValue(), n2.getValue())) |
538 | return false; |
539 | return true; |
540 | } |
541 | |
542 | @Override |
543 | public Boolean visit(final IntegerLiteralExpr n, final Visitable arg) { |
544 | final IntegerLiteralExpr n2 = (IntegerLiteralExpr) arg; |
545 | if (!objEquals(n.getValue(), n2.getValue())) |
546 | return false; |
547 | return true; |
548 | } |
549 | |
550 | @Override |
551 | public Boolean visit(final LongLiteralExpr n, final Visitable arg) { |
552 | final LongLiteralExpr n2 = (LongLiteralExpr) arg; |
553 | if (!objEquals(n.getValue(), n2.getValue())) |
554 | return false; |
555 | return true; |
556 | } |
557 | |
558 | @Override |
559 | public Boolean visit(final CharLiteralExpr n, final Visitable arg) { |
560 | final CharLiteralExpr n2 = (CharLiteralExpr) arg; |
561 | if (!objEquals(n.getValue(), n2.getValue())) |
562 | return false; |
563 | return true; |
564 | } |
565 | |
566 | @Override |
567 | public Boolean visit(final DoubleLiteralExpr n, final Visitable arg) { |
568 | final DoubleLiteralExpr n2 = (DoubleLiteralExpr) arg; |
569 | if (!objEquals(n.getValue(), n2.getValue())) |
570 | return false; |
571 | return true; |
572 | } |
573 | |
574 | @Override |
575 | public Boolean visit(final BooleanLiteralExpr n, final Visitable arg) { |
576 | final BooleanLiteralExpr n2 = (BooleanLiteralExpr) arg; |
577 | if (!objEquals(n.isValue(), n2.isValue())) |
578 | return false; |
579 | return true; |
580 | } |
581 | |
582 | @Override |
583 | public Boolean visit(final NullLiteralExpr n, final Visitable arg) { |
584 | return true; |
585 | } |
586 | |
587 | @Override |
588 | public Boolean visit(final MethodCallExpr n, final Visitable arg) { |
589 | final MethodCallExpr n2 = (MethodCallExpr) arg; |
590 | if (!nodesEquals(n.getArguments(), n2.getArguments())) |
591 | return false; |
592 | if (!nodeEquals(n.getName(), n2.getName())) |
593 | return false; |
594 | if (!nodeEquals(n.getScope(), n2.getScope())) |
595 | return false; |
596 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
597 | return false; |
598 | return true; |
599 | } |
600 | |
601 | @Override |
602 | public Boolean visit(final NameExpr n, final Visitable arg) { |
603 | final NameExpr n2 = (NameExpr) arg; |
604 | if (!nodeEquals(n.getName(), n2.getName())) |
605 | return false; |
606 | return true; |
607 | } |
608 | |
609 | @Override |
610 | public Boolean visit(final ObjectCreationExpr n, final Visitable arg) { |
611 | final ObjectCreationExpr n2 = (ObjectCreationExpr) arg; |
612 | if (!nodesEquals(n.getAnonymousClassBody(), n2.getAnonymousClassBody())) |
613 | return false; |
614 | if (!nodesEquals(n.getArguments(), n2.getArguments())) |
615 | return false; |
616 | if (!nodeEquals(n.getScope(), n2.getScope())) |
617 | return false; |
618 | if (!nodeEquals(n.getType(), n2.getType())) |
619 | return false; |
620 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
621 | return false; |
622 | return true; |
623 | } |
624 | |
625 | @Override |
626 | public Boolean visit(final Name n, final Visitable arg) { |
627 | final Name n2 = (Name) arg; |
628 | if (!objEquals(n.getIdentifier(), n2.getIdentifier())) |
629 | return false; |
630 | if (!nodeEquals(n.getQualifier(), n2.getQualifier())) |
631 | return false; |
632 | return true; |
633 | } |
634 | |
635 | @Override |
636 | public Boolean visit(final SimpleName n, final Visitable arg) { |
637 | final SimpleName n2 = (SimpleName) arg; |
638 | if (!objEquals(n.getIdentifier(), n2.getIdentifier())) |
639 | return false; |
640 | return true; |
641 | } |
642 | |
643 | @Override |
644 | public Boolean visit(final ThisExpr n, final Visitable arg) { |
645 | final ThisExpr n2 = (ThisExpr) arg; |
646 | if (!nodeEquals(n.getTypeName(), n2.getTypeName())) |
647 | return false; |
648 | return true; |
649 | } |
650 | |
651 | @Override |
652 | public Boolean visit(final SuperExpr n, final Visitable arg) { |
653 | final SuperExpr n2 = (SuperExpr) arg; |
654 | if (!nodeEquals(n.getTypeName(), n2.getTypeName())) |
655 | return false; |
656 | return true; |
657 | } |
658 | |
659 | @Override |
660 | public Boolean visit(final UnaryExpr n, final Visitable arg) { |
661 | final UnaryExpr n2 = (UnaryExpr) arg; |
662 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
663 | return false; |
664 | if (!objEquals(n.getOperator(), n2.getOperator())) |
665 | return false; |
666 | return true; |
667 | } |
668 | |
669 | @Override |
670 | public Boolean visit(final VariableDeclarationExpr n, final Visitable arg) { |
671 | final VariableDeclarationExpr n2 = (VariableDeclarationExpr) arg; |
672 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
673 | return false; |
674 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
675 | return false; |
676 | if (!nodesEquals(n.getVariables(), n2.getVariables())) |
677 | return false; |
678 | return true; |
679 | } |
680 | |
681 | @Override |
682 | public Boolean visit(final MarkerAnnotationExpr n, final Visitable arg) { |
683 | final MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg; |
684 | if (!nodeEquals(n.getName(), n2.getName())) |
685 | return false; |
686 | return true; |
687 | } |
688 | |
689 | @Override |
690 | public Boolean visit(final SingleMemberAnnotationExpr n, final Visitable arg) { |
691 | final SingleMemberAnnotationExpr n2 = (SingleMemberAnnotationExpr) arg; |
692 | if (!nodeEquals(n.getMemberValue(), n2.getMemberValue())) |
693 | return false; |
694 | if (!nodeEquals(n.getName(), n2.getName())) |
695 | return false; |
696 | return true; |
697 | } |
698 | |
699 | @Override |
700 | public Boolean visit(final NormalAnnotationExpr n, final Visitable arg) { |
701 | final NormalAnnotationExpr n2 = (NormalAnnotationExpr) arg; |
702 | if (!nodesEquals(n.getPairs(), n2.getPairs())) |
703 | return false; |
704 | if (!nodeEquals(n.getName(), n2.getName())) |
705 | return false; |
706 | return true; |
707 | } |
708 | |
709 | @Override |
710 | public Boolean visit(final MemberValuePair n, final Visitable arg) { |
711 | final MemberValuePair n2 = (MemberValuePair) arg; |
712 | if (!nodeEquals(n.getName(), n2.getName())) |
713 | return false; |
714 | if (!nodeEquals(n.getValue(), n2.getValue())) |
715 | return false; |
716 | return true; |
717 | } |
718 | |
719 | @Override |
720 | public Boolean visit(final ExplicitConstructorInvocationStmt n, final Visitable arg) { |
721 | final ExplicitConstructorInvocationStmt n2 = (ExplicitConstructorInvocationStmt) arg; |
722 | if (!nodesEquals(n.getArguments(), n2.getArguments())) |
723 | return false; |
724 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
725 | return false; |
726 | if (!objEquals(n.isThis(), n2.isThis())) |
727 | return false; |
728 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
729 | return false; |
730 | return true; |
731 | } |
732 | |
733 | @Override |
734 | public Boolean visit(final LocalClassDeclarationStmt n, final Visitable arg) { |
735 | final LocalClassDeclarationStmt n2 = (LocalClassDeclarationStmt) arg; |
736 | if (!nodeEquals(n.getClassDeclaration(), n2.getClassDeclaration())) |
737 | return false; |
738 | return true; |
739 | } |
740 | |
741 | @Override |
742 | public Boolean visit(final AssertStmt n, final Visitable arg) { |
743 | final AssertStmt n2 = (AssertStmt) arg; |
744 | if (!nodeEquals(n.getCheck(), n2.getCheck())) |
745 | return false; |
746 | if (!nodeEquals(n.getMessage(), n2.getMessage())) |
747 | return false; |
748 | return true; |
749 | } |
750 | |
751 | @Override |
752 | public Boolean visit(final BlockStmt n, final Visitable arg) { |
753 | final BlockStmt n2 = (BlockStmt) arg; |
754 | if (!nodesEquals(n.getStatements(), n2.getStatements())) |
755 | return false; |
756 | return true; |
757 | } |
758 | |
759 | @Override |
760 | public Boolean visit(final LabeledStmt n, final Visitable arg) { |
761 | final LabeledStmt n2 = (LabeledStmt) arg; |
762 | if (!nodeEquals(n.getLabel(), n2.getLabel())) |
763 | return false; |
764 | if (!nodeEquals(n.getStatement(), n2.getStatement())) |
765 | return false; |
766 | return true; |
767 | } |
768 | |
769 | @Override |
770 | public Boolean visit(final EmptyStmt n, final Visitable arg) { |
771 | return true; |
772 | } |
773 | |
774 | @Override |
775 | public Boolean visit(final ExpressionStmt n, final Visitable arg) { |
776 | final ExpressionStmt n2 = (ExpressionStmt) arg; |
777 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
778 | return false; |
779 | return true; |
780 | } |
781 | |
782 | @Override |
783 | public Boolean visit(final SwitchStmt n, final Visitable arg) { |
784 | final SwitchStmt n2 = (SwitchStmt) arg; |
785 | if (!nodesEquals(n.getEntries(), n2.getEntries())) |
786 | return false; |
787 | if (!nodeEquals(n.getSelector(), n2.getSelector())) |
788 | return false; |
789 | return true; |
790 | } |
791 | |
792 | @Override |
793 | public Boolean visit(final SwitchEntry n, final Visitable arg) { |
794 | final SwitchEntry n2 = (SwitchEntry) arg; |
795 | if (!nodesEquals(n.getLabels(), n2.getLabels())) |
796 | return false; |
797 | if (!nodesEquals(n.getStatements(), n2.getStatements())) |
798 | return false; |
799 | if (!objEquals(n.getType(), n2.getType())) |
800 | return false; |
801 | return true; |
802 | } |
803 | |
804 | @Override |
805 | public Boolean visit(final BreakStmt n, final Visitable arg) { |
806 | final BreakStmt n2 = (BreakStmt) arg; |
807 | if (!nodeEquals(n.getLabel(), n2.getLabel())) |
808 | return false; |
809 | return true; |
810 | } |
811 | |
812 | @Override |
813 | public Boolean visit(final ReturnStmt n, final Visitable arg) { |
814 | final ReturnStmt n2 = (ReturnStmt) arg; |
815 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
816 | return false; |
817 | return true; |
818 | } |
819 | |
820 | @Override |
821 | public Boolean visit(final IfStmt n, final Visitable arg) { |
822 | final IfStmt n2 = (IfStmt) arg; |
823 | if (!nodeEquals(n.getCondition(), n2.getCondition())) |
824 | return false; |
825 | if (!nodeEquals(n.getElseStmt(), n2.getElseStmt())) |
826 | return false; |
827 | if (!nodeEquals(n.getThenStmt(), n2.getThenStmt())) |
828 | return false; |
829 | return true; |
830 | } |
831 | |
832 | @Override |
833 | public Boolean visit(final WhileStmt n, final Visitable arg) { |
834 | final WhileStmt n2 = (WhileStmt) arg; |
835 | if (!nodeEquals(n.getBody(), n2.getBody())) |
836 | return false; |
837 | if (!nodeEquals(n.getCondition(), n2.getCondition())) |
838 | return false; |
839 | return true; |
840 | } |
841 | |
842 | @Override |
843 | public Boolean visit(final ContinueStmt n, final Visitable arg) { |
844 | final ContinueStmt n2 = (ContinueStmt) arg; |
845 | if (!nodeEquals(n.getLabel(), n2.getLabel())) |
846 | return false; |
847 | return true; |
848 | } |
849 | |
850 | @Override |
851 | public Boolean visit(final DoStmt n, final Visitable arg) { |
852 | final DoStmt n2 = (DoStmt) arg; |
853 | if (!nodeEquals(n.getBody(), n2.getBody())) |
854 | return false; |
855 | if (!nodeEquals(n.getCondition(), n2.getCondition())) |
856 | return false; |
857 | return true; |
858 | } |
859 | |
860 | @Override |
861 | public Boolean visit(final ForEachStmt n, final Visitable arg) { |
862 | final ForEachStmt n2 = (ForEachStmt) arg; |
863 | if (!nodeEquals(n.getBody(), n2.getBody())) |
864 | return false; |
865 | if (!nodeEquals(n.getIterable(), n2.getIterable())) |
866 | return false; |
867 | if (!nodeEquals(n.getVariable(), n2.getVariable())) |
868 | return false; |
869 | return true; |
870 | } |
871 | |
872 | @Override |
873 | public Boolean visit(final ForStmt n, final Visitable arg) { |
874 | final ForStmt n2 = (ForStmt) arg; |
875 | if (!nodeEquals(n.getBody(), n2.getBody())) |
876 | return false; |
877 | if (!nodeEquals(n.getCompare(), n2.getCompare())) |
878 | return false; |
879 | if (!nodesEquals(n.getInitialization(), n2.getInitialization())) |
880 | return false; |
881 | if (!nodesEquals(n.getUpdate(), n2.getUpdate())) |
882 | return false; |
883 | return true; |
884 | } |
885 | |
886 | @Override |
887 | public Boolean visit(final ThrowStmt n, final Visitable arg) { |
888 | final ThrowStmt n2 = (ThrowStmt) arg; |
889 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
890 | return false; |
891 | return true; |
892 | } |
893 | |
894 | @Override |
895 | public Boolean visit(final SynchronizedStmt n, final Visitable arg) { |
896 | final SynchronizedStmt n2 = (SynchronizedStmt) arg; |
897 | if (!nodeEquals(n.getBody(), n2.getBody())) |
898 | return false; |
899 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
900 | return false; |
901 | return true; |
902 | } |
903 | |
904 | @Override |
905 | public Boolean visit(final TryStmt n, final Visitable arg) { |
906 | final TryStmt n2 = (TryStmt) arg; |
907 | if (!nodesEquals(n.getCatchClauses(), n2.getCatchClauses())) |
908 | return false; |
909 | if (!nodeEquals(n.getFinallyBlock(), n2.getFinallyBlock())) |
910 | return false; |
911 | if (!nodesEquals(n.getResources(), n2.getResources())) |
912 | return false; |
913 | if (!nodeEquals(n.getTryBlock(), n2.getTryBlock())) |
914 | return false; |
915 | return true; |
916 | } |
917 | |
918 | @Override |
919 | public Boolean visit(final CatchClause n, final Visitable arg) { |
920 | final CatchClause n2 = (CatchClause) arg; |
921 | if (!nodeEquals(n.getBody(), n2.getBody())) |
922 | return false; |
923 | if (!nodeEquals(n.getParameter(), n2.getParameter())) |
924 | return false; |
925 | return true; |
926 | } |
927 | |
928 | @Override |
929 | public Boolean visit(final LambdaExpr n, final Visitable arg) { |
930 | final LambdaExpr n2 = (LambdaExpr) arg; |
931 | if (!nodeEquals(n.getBody(), n2.getBody())) |
932 | return false; |
933 | if (!objEquals(n.isEnclosingParameters(), n2.isEnclosingParameters())) |
934 | return false; |
935 | if (!nodesEquals(n.getParameters(), n2.getParameters())) |
936 | return false; |
937 | return true; |
938 | } |
939 | |
940 | @Override |
941 | public Boolean visit(final MethodReferenceExpr n, final Visitable arg) { |
942 | final MethodReferenceExpr n2 = (MethodReferenceExpr) arg; |
943 | if (!objEquals(n.getIdentifier(), n2.getIdentifier())) |
944 | return false; |
945 | if (!nodeEquals(n.getScope(), n2.getScope())) |
946 | return false; |
947 | if (!nodesEquals(n.getTypeArguments(), n2.getTypeArguments())) |
948 | return false; |
949 | return true; |
950 | } |
951 | |
952 | @Override |
953 | public Boolean visit(final TypeExpr n, final Visitable arg) { |
954 | final TypeExpr n2 = (TypeExpr) arg; |
955 | if (!nodeEquals(n.getType(), n2.getType())) |
956 | return false; |
957 | return true; |
958 | } |
959 | |
960 | @Override |
961 | public Boolean visit(final ImportDeclaration n, final Visitable arg) { |
962 | final ImportDeclaration n2 = (ImportDeclaration) arg; |
963 | if (!objEquals(n.isAsterisk(), n2.isAsterisk())) |
964 | return false; |
965 | if (!objEquals(n.isStatic(), n2.isStatic())) |
966 | return false; |
967 | if (!nodeEquals(n.getName(), n2.getName())) |
968 | return false; |
969 | return true; |
970 | } |
971 | |
972 | @Override |
973 | public Boolean visit(NodeList n, Visitable arg) { |
974 | return nodesEquals((NodeList<Node>) n, (NodeList<Node>) arg); |
975 | } |
976 | |
977 | @Override |
978 | public Boolean visit(final ModuleDeclaration n, final Visitable arg) { |
979 | final ModuleDeclaration n2 = (ModuleDeclaration) arg; |
980 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
981 | return false; |
982 | if (!nodesEquals(n.getDirectives(), n2.getDirectives())) |
983 | return false; |
984 | if (!objEquals(n.isOpen(), n2.isOpen())) |
985 | return false; |
986 | if (!nodeEquals(n.getName(), n2.getName())) |
987 | return false; |
988 | return true; |
989 | } |
990 | |
991 | @Override |
992 | public Boolean visit(final ModuleRequiresDirective n, final Visitable arg) { |
993 | final ModuleRequiresDirective n2 = (ModuleRequiresDirective) arg; |
994 | if (!nodesEquals(n.getModifiers(), n2.getModifiers())) |
995 | return false; |
996 | if (!nodeEquals(n.getName(), n2.getName())) |
997 | return false; |
998 | return true; |
999 | } |
1000 | |
1001 | @Override() |
1002 | public Boolean visit(final ModuleExportsDirective n, final Visitable arg) { |
1003 | final ModuleExportsDirective n2 = (ModuleExportsDirective) arg; |
1004 | if (!nodesEquals(n.getModuleNames(), n2.getModuleNames())) |
1005 | return false; |
1006 | if (!nodeEquals(n.getName(), n2.getName())) |
1007 | return false; |
1008 | return true; |
1009 | } |
1010 | |
1011 | @Override() |
1012 | public Boolean visit(final ModuleProvidesDirective n, final Visitable arg) { |
1013 | final ModuleProvidesDirective n2 = (ModuleProvidesDirective) arg; |
1014 | if (!nodeEquals(n.getName(), n2.getName())) |
1015 | return false; |
1016 | if (!nodesEquals(n.getWith(), n2.getWith())) |
1017 | return false; |
1018 | return true; |
1019 | } |
1020 | |
1021 | @Override() |
1022 | public Boolean visit(final ModuleUsesDirective n, final Visitable arg) { |
1023 | final ModuleUsesDirective n2 = (ModuleUsesDirective) arg; |
1024 | if (!nodeEquals(n.getName(), n2.getName())) |
1025 | return false; |
1026 | return true; |
1027 | } |
1028 | |
1029 | @Override |
1030 | public Boolean visit(final ModuleOpensDirective n, final Visitable arg) { |
1031 | final ModuleOpensDirective n2 = (ModuleOpensDirective) arg; |
1032 | if (!nodesEquals(n.getModuleNames(), n2.getModuleNames())) |
1033 | return false; |
1034 | if (!nodeEquals(n.getName(), n2.getName())) |
1035 | return false; |
1036 | return true; |
1037 | } |
1038 | |
1039 | @Override |
1040 | public Boolean visit(final UnparsableStmt n, final Visitable arg) { |
1041 | return true; |
1042 | } |
1043 | |
1044 | @Override |
1045 | public Boolean visit(final ReceiverParameter n, final Visitable arg) { |
1046 | final ReceiverParameter n2 = (ReceiverParameter) arg; |
1047 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
1048 | return false; |
1049 | if (!nodeEquals(n.getName(), n2.getName())) |
1050 | return false; |
1051 | if (!nodeEquals(n.getType(), n2.getType())) |
1052 | return false; |
1053 | return true; |
1054 | } |
1055 | |
1056 | @Override |
1057 | public Boolean visit(final VarType n, final Visitable arg) { |
1058 | final VarType n2 = (VarType) arg; |
1059 | if (!nodesEquals(n.getAnnotations(), n2.getAnnotations())) |
1060 | return false; |
1061 | return true; |
1062 | } |
1063 | |
1064 | @Override |
1065 | public Boolean visit(final Modifier n, final Visitable arg) { |
1066 | final Modifier n2 = (Modifier) arg; |
1067 | if (!objEquals(n.getKeyword(), n2.getKeyword())) |
1068 | return false; |
1069 | return true; |
1070 | } |
1071 | |
1072 | @Override |
1073 | public Boolean visit(final SwitchExpr n, final Visitable arg) { |
1074 | final SwitchExpr n2 = (SwitchExpr) arg; |
1075 | if (!nodesEquals(n.getEntries(), n2.getEntries())) |
1076 | return false; |
1077 | if (!nodeEquals(n.getSelector(), n2.getSelector())) |
1078 | return false; |
1079 | return true; |
1080 | } |
1081 | |
1082 | @Override |
1083 | public Boolean visit(final YieldStmt n, final Visitable arg) { |
1084 | final YieldStmt n2 = (YieldStmt) arg; |
1085 | if (!nodeEquals(n.getExpression(), n2.getExpression())) |
1086 | return false; |
1087 | return true; |
1088 | } |
1089 | |
1090 | @Override |
1091 | public Boolean visit(final TextBlockLiteralExpr n, final Visitable arg) { |
1092 | final TextBlockLiteralExpr n2 = (TextBlockLiteralExpr) arg; |
1093 | if (!objEquals(n.getValue(), n2.getValue())) |
1094 | return false; |
1095 | return true; |
1096 | } |
1097 | } |
1098 |
Members