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 | |
33 | /** |
34 | * A visitor that calculates a deep hash code for a node by using the hash codes of all its properties, |
35 | * and the hash codes of all its child nodes (by visiting those too.) |
36 | */ |
37 | public class HashCodeVisitor implements GenericVisitor<Integer, Void> { |
38 | |
39 | private static final HashCodeVisitor SINGLETON = new HashCodeVisitor(); |
40 | |
41 | private HashCodeVisitor() { |
42 | // hide constructor |
43 | } |
44 | |
45 | public static int hashCode(final Node node) { |
46 | return node.accept(SINGLETON, null); |
47 | } |
48 | |
49 | public Integer visit(final AnnotationDeclaration n, final Void arg) { |
50 | return (n.getMembers().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
51 | } |
52 | |
53 | public Integer visit(final AnnotationMemberDeclaration n, final Void arg) { |
54 | return (n.getDefaultValue().isPresent() ? n.getDefaultValue().get().accept(this, arg) : 0) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
55 | } |
56 | |
57 | public Integer visit(final ArrayAccessExpr n, final Void arg) { |
58 | return (n.getIndex().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
59 | } |
60 | |
61 | public Integer visit(final ArrayCreationExpr n, final Void arg) { |
62 | return (n.getElementType().accept(this, arg)) * 31 + (n.getInitializer().isPresent() ? n.getInitializer().get().accept(this, arg) : 0) * 31 + (n.getLevels().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
63 | } |
64 | |
65 | public Integer visit(final ArrayCreationLevel n, final Void arg) { |
66 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getDimension().isPresent() ? n.getDimension().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
67 | } |
68 | |
69 | public Integer visit(final ArrayInitializerExpr n, final Void arg) { |
70 | return (n.getValues().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
71 | } |
72 | |
73 | public Integer visit(final ArrayType n, final Void arg) { |
74 | return (n.getComponentType().accept(this, arg)) * 31 + (n.getOrigin().hashCode()) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
75 | } |
76 | |
77 | public Integer visit(final AssertStmt n, final Void arg) { |
78 | return (n.getCheck().accept(this, arg)) * 31 + (n.getMessage().isPresent() ? n.getMessage().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
79 | } |
80 | |
81 | public Integer visit(final AssignExpr n, final Void arg) { |
82 | return (n.getOperator().hashCode()) * 31 + (n.getTarget().accept(this, arg)) * 31 + (n.getValue().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
83 | } |
84 | |
85 | public Integer visit(final BinaryExpr n, final Void arg) { |
86 | return (n.getLeft().accept(this, arg)) * 31 + (n.getOperator().hashCode()) * 31 + (n.getRight().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
87 | } |
88 | |
89 | public Integer visit(final BlockComment n, final Void arg) { |
90 | return (n.getContent().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
91 | } |
92 | |
93 | public Integer visit(final BlockStmt n, final Void arg) { |
94 | return (n.getStatements().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
95 | } |
96 | |
97 | public Integer visit(final BooleanLiteralExpr n, final Void arg) { |
98 | return (n.isValue() ? 1 : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
99 | } |
100 | |
101 | public Integer visit(final BreakStmt n, final Void arg) { |
102 | return (n.getLabel().isPresent() ? n.getLabel().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
103 | } |
104 | |
105 | public Integer visit(final CastExpr n, final Void arg) { |
106 | return (n.getExpression().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
107 | } |
108 | |
109 | public Integer visit(final CatchClause n, final Void arg) { |
110 | return (n.getBody().accept(this, arg)) * 31 + (n.getParameter().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
111 | } |
112 | |
113 | public Integer visit(final CharLiteralExpr n, final Void arg) { |
114 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
115 | } |
116 | |
117 | public Integer visit(final ClassExpr n, final Void arg) { |
118 | return (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
119 | } |
120 | |
121 | public Integer visit(final ClassOrInterfaceDeclaration n, final Void arg) { |
122 | return (n.getExtendedTypes().accept(this, arg)) * 31 + (n.getImplementedTypes().accept(this, arg)) * 31 + (n.isInterface() ? 1 : 0) * 31 + (n.getTypeParameters().accept(this, arg)) * 31 + (n.getMembers().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
123 | } |
124 | |
125 | public Integer visit(final ClassOrInterfaceType n, final Void arg) { |
126 | return (n.getName().accept(this, arg)) * 31 + (n.getScope().isPresent() ? n.getScope().get().accept(this, arg) : 0) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
127 | } |
128 | |
129 | public Integer visit(final CompilationUnit n, final Void arg) { |
130 | return (n.getImports().accept(this, arg)) * 31 + (n.getModule().isPresent() ? n.getModule().get().accept(this, arg) : 0) * 31 + (n.getPackageDeclaration().isPresent() ? n.getPackageDeclaration().get().accept(this, arg) : 0) * 31 + (n.getTypes().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
131 | } |
132 | |
133 | public Integer visit(final ConditionalExpr n, final Void arg) { |
134 | return (n.getCondition().accept(this, arg)) * 31 + (n.getElseExpr().accept(this, arg)) * 31 + (n.getThenExpr().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
135 | } |
136 | |
137 | public Integer visit(final ConstructorDeclaration n, final Void arg) { |
138 | return (n.getBody().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getParameters().accept(this, arg)) * 31 + (n.getReceiverParameter().isPresent() ? n.getReceiverParameter().get().accept(this, arg) : 0) * 31 + (n.getThrownExceptions().accept(this, arg)) * 31 + (n.getTypeParameters().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
139 | } |
140 | |
141 | public Integer visit(final ContinueStmt n, final Void arg) { |
142 | return (n.getLabel().isPresent() ? n.getLabel().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
143 | } |
144 | |
145 | public Integer visit(final DoStmt n, final Void arg) { |
146 | return (n.getBody().accept(this, arg)) * 31 + (n.getCondition().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
147 | } |
148 | |
149 | public Integer visit(final DoubleLiteralExpr n, final Void arg) { |
150 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
151 | } |
152 | |
153 | public Integer visit(final EmptyStmt n, final Void arg) { |
154 | return (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
155 | } |
156 | |
157 | public Integer visit(final EnclosedExpr n, final Void arg) { |
158 | return (n.getInner().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
159 | } |
160 | |
161 | public Integer visit(final EnumConstantDeclaration n, final Void arg) { |
162 | return (n.getArguments().accept(this, arg)) * 31 + (n.getClassBody().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
163 | } |
164 | |
165 | public Integer visit(final EnumDeclaration n, final Void arg) { |
166 | return (n.getEntries().accept(this, arg)) * 31 + (n.getImplementedTypes().accept(this, arg)) * 31 + (n.getMembers().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
167 | } |
168 | |
169 | public Integer visit(final ExplicitConstructorInvocationStmt n, final Void arg) { |
170 | return (n.getArguments().accept(this, arg)) * 31 + (n.getExpression().isPresent() ? n.getExpression().get().accept(this, arg) : 0) * 31 + (n.isThis() ? 1 : 0) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
171 | } |
172 | |
173 | public Integer visit(final ExpressionStmt n, final Void arg) { |
174 | return (n.getExpression().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
175 | } |
176 | |
177 | public Integer visit(final FieldAccessExpr n, final Void arg) { |
178 | return (n.getName().accept(this, arg)) * 31 + (n.getScope().accept(this, arg)) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
179 | } |
180 | |
181 | public Integer visit(final FieldDeclaration n, final Void arg) { |
182 | return (n.getModifiers().accept(this, arg)) * 31 + (n.getVariables().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
183 | } |
184 | |
185 | public Integer visit(final ForStmt n, final Void arg) { |
186 | return (n.getBody().accept(this, arg)) * 31 + (n.getCompare().isPresent() ? n.getCompare().get().accept(this, arg) : 0) * 31 + (n.getInitialization().accept(this, arg)) * 31 + (n.getUpdate().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
187 | } |
188 | |
189 | public Integer visit(final ForEachStmt n, final Void arg) { |
190 | return (n.getBody().accept(this, arg)) * 31 + (n.getIterable().accept(this, arg)) * 31 + (n.getVariable().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
191 | } |
192 | |
193 | public Integer visit(final IfStmt n, final Void arg) { |
194 | return (n.getCondition().accept(this, arg)) * 31 + (n.getElseStmt().isPresent() ? n.getElseStmt().get().accept(this, arg) : 0) * 31 + (n.getThenStmt().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
195 | } |
196 | |
197 | public Integer visit(final ImportDeclaration n, final Void arg) { |
198 | return (n.isAsterisk() ? 1 : 0) * 31 + (n.isStatic() ? 1 : 0) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
199 | } |
200 | |
201 | public Integer visit(final InitializerDeclaration n, final Void arg) { |
202 | return (n.getBody().accept(this, arg)) * 31 + (n.isStatic() ? 1 : 0) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
203 | } |
204 | |
205 | public Integer visit(final InstanceOfExpr n, final Void arg) { |
206 | return (n.getExpression().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
207 | } |
208 | |
209 | public Integer visit(final IntegerLiteralExpr n, final Void arg) { |
210 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
211 | } |
212 | |
213 | public Integer visit(final IntersectionType n, final Void arg) { |
214 | return (n.getElements().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
215 | } |
216 | |
217 | public Integer visit(final JavadocComment n, final Void arg) { |
218 | return (n.getContent().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
219 | } |
220 | |
221 | public Integer visit(final LabeledStmt n, final Void arg) { |
222 | return (n.getLabel().accept(this, arg)) * 31 + (n.getStatement().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
223 | } |
224 | |
225 | public Integer visit(final LambdaExpr n, final Void arg) { |
226 | return (n.getBody().accept(this, arg)) * 31 + (n.isEnclosingParameters() ? 1 : 0) * 31 + (n.getParameters().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
227 | } |
228 | |
229 | public Integer visit(final LineComment n, final Void arg) { |
230 | return (n.getContent().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
231 | } |
232 | |
233 | public Integer visit(final LocalClassDeclarationStmt n, final Void arg) { |
234 | return (n.getClassDeclaration().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
235 | } |
236 | |
237 | public Integer visit(final LongLiteralExpr n, final Void arg) { |
238 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
239 | } |
240 | |
241 | public Integer visit(final MarkerAnnotationExpr n, final Void arg) { |
242 | return (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
243 | } |
244 | |
245 | public Integer visit(final MemberValuePair n, final Void arg) { |
246 | return (n.getName().accept(this, arg)) * 31 + (n.getValue().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
247 | } |
248 | |
249 | public Integer visit(final MethodCallExpr n, final Void arg) { |
250 | return (n.getArguments().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getScope().isPresent() ? n.getScope().get().accept(this, arg) : 0) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
251 | } |
252 | |
253 | public Integer visit(final MethodDeclaration n, final Void arg) { |
254 | return (n.getBody().isPresent() ? n.getBody().get().accept(this, arg) : 0) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getParameters().accept(this, arg)) * 31 + (n.getReceiverParameter().isPresent() ? n.getReceiverParameter().get().accept(this, arg) : 0) * 31 + (n.getThrownExceptions().accept(this, arg)) * 31 + (n.getTypeParameters().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
255 | } |
256 | |
257 | public Integer visit(final MethodReferenceExpr n, final Void arg) { |
258 | return (n.getIdentifier().hashCode()) * 31 + (n.getScope().accept(this, arg)) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
259 | } |
260 | |
261 | public Integer visit(final NameExpr n, final Void arg) { |
262 | return (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
263 | } |
264 | |
265 | public Integer visit(final Name n, final Void arg) { |
266 | return (n.getIdentifier().hashCode()) * 31 + (n.getQualifier().isPresent() ? n.getQualifier().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
267 | } |
268 | |
269 | public Integer visit(NodeList n, Void arg) { |
270 | int result = 0; |
271 | for (Object node : n) { |
272 | result += 31 * ((Visitable) node).accept(this, arg); |
273 | } |
274 | return result; |
275 | } |
276 | |
277 | public Integer visit(final NormalAnnotationExpr n, final Void arg) { |
278 | return (n.getPairs().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
279 | } |
280 | |
281 | public Integer visit(final NullLiteralExpr n, final Void arg) { |
282 | return (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
283 | } |
284 | |
285 | public Integer visit(final ObjectCreationExpr n, final Void arg) { |
286 | return (n.getAnonymousClassBody().isPresent() ? n.getAnonymousClassBody().get().accept(this, arg) : 0) * 31 + (n.getArguments().accept(this, arg)) * 31 + (n.getScope().isPresent() ? n.getScope().get().accept(this, arg) : 0) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getTypeArguments().isPresent() ? n.getTypeArguments().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
287 | } |
288 | |
289 | public Integer visit(final PackageDeclaration n, final Void arg) { |
290 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
291 | } |
292 | |
293 | public Integer visit(final Parameter n, final Void arg) { |
294 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.isVarArgs() ? 1 : 0) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getVarArgsAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
295 | } |
296 | |
297 | public Integer visit(final PrimitiveType n, final Void arg) { |
298 | return (n.getType().hashCode()) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
299 | } |
300 | |
301 | public Integer visit(final ReturnStmt n, final Void arg) { |
302 | return (n.getExpression().isPresent() ? n.getExpression().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
303 | } |
304 | |
305 | public Integer visit(final SimpleName n, final Void arg) { |
306 | return (n.getIdentifier().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
307 | } |
308 | |
309 | public Integer visit(final SingleMemberAnnotationExpr n, final Void arg) { |
310 | return (n.getMemberValue().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
311 | } |
312 | |
313 | public Integer visit(final StringLiteralExpr n, final Void arg) { |
314 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
315 | } |
316 | |
317 | public Integer visit(final SuperExpr n, final Void arg) { |
318 | return (n.getTypeName().isPresent() ? n.getTypeName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
319 | } |
320 | |
321 | public Integer visit(final SwitchEntry n, final Void arg) { |
322 | return (n.getLabels().accept(this, arg)) * 31 + (n.getStatements().accept(this, arg)) * 31 + (n.getType().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
323 | } |
324 | |
325 | public Integer visit(final SwitchStmt n, final Void arg) { |
326 | return (n.getEntries().accept(this, arg)) * 31 + (n.getSelector().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
327 | } |
328 | |
329 | public Integer visit(final SynchronizedStmt n, final Void arg) { |
330 | return (n.getBody().accept(this, arg)) * 31 + (n.getExpression().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
331 | } |
332 | |
333 | public Integer visit(final ThisExpr n, final Void arg) { |
334 | return (n.getTypeName().isPresent() ? n.getTypeName().get().accept(this, arg) : 0) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
335 | } |
336 | |
337 | public Integer visit(final ThrowStmt n, final Void arg) { |
338 | return (n.getExpression().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
339 | } |
340 | |
341 | public Integer visit(final TryStmt n, final Void arg) { |
342 | return (n.getCatchClauses().accept(this, arg)) * 31 + (n.getFinallyBlock().isPresent() ? n.getFinallyBlock().get().accept(this, arg) : 0) * 31 + (n.getResources().accept(this, arg)) * 31 + (n.getTryBlock().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
343 | } |
344 | |
345 | public Integer visit(final TypeExpr n, final Void arg) { |
346 | return (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
347 | } |
348 | |
349 | public Integer visit(final TypeParameter n, final Void arg) { |
350 | return (n.getName().accept(this, arg)) * 31 + (n.getTypeBound().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
351 | } |
352 | |
353 | public Integer visit(final UnaryExpr n, final Void arg) { |
354 | return (n.getExpression().accept(this, arg)) * 31 + (n.getOperator().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
355 | } |
356 | |
357 | public Integer visit(final UnionType n, final Void arg) { |
358 | return (n.getElements().accept(this, arg)) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
359 | } |
360 | |
361 | public Integer visit(final UnknownType n, final Void arg) { |
362 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
363 | } |
364 | |
365 | public Integer visit(final VariableDeclarationExpr n, final Void arg) { |
366 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getModifiers().accept(this, arg)) * 31 + (n.getVariables().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
367 | } |
368 | |
369 | public Integer visit(final VariableDeclarator n, final Void arg) { |
370 | return (n.getInitializer().isPresent() ? n.getInitializer().get().accept(this, arg) : 0) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
371 | } |
372 | |
373 | public Integer visit(final VoidType n, final Void arg) { |
374 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
375 | } |
376 | |
377 | public Integer visit(final WhileStmt n, final Void arg) { |
378 | return (n.getBody().accept(this, arg)) * 31 + (n.getCondition().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
379 | } |
380 | |
381 | public Integer visit(final WildcardType n, final Void arg) { |
382 | return (n.getExtendedType().isPresent() ? n.getExtendedType().get().accept(this, arg) : 0) * 31 + (n.getSuperType().isPresent() ? n.getSuperType().get().accept(this, arg) : 0) * 31 + (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
383 | } |
384 | |
385 | public Integer visit(final ModuleDeclaration n, final Void arg) { |
386 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getDirectives().accept(this, arg)) * 31 + (n.isOpen() ? 1 : 0) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
387 | } |
388 | |
389 | public Integer visit(final ModuleRequiresDirective n, final Void arg) { |
390 | return (n.getModifiers().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
391 | } |
392 | |
393 | @Override() |
394 | public Integer visit(final ModuleExportsDirective n, final Void arg) { |
395 | return (n.getModuleNames().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
396 | } |
397 | |
398 | @Override() |
399 | public Integer visit(final ModuleProvidesDirective n, final Void arg) { |
400 | return (n.getName().accept(this, arg)) * 31 + (n.getWith().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
401 | } |
402 | |
403 | @Override() |
404 | public Integer visit(final ModuleUsesDirective n, final Void arg) { |
405 | return (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
406 | } |
407 | |
408 | @Override |
409 | public Integer visit(final ModuleOpensDirective n, final Void arg) { |
410 | return (n.getModuleNames().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
411 | } |
412 | |
413 | @Override |
414 | public Integer visit(final UnparsableStmt n, final Void arg) { |
415 | return (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
416 | } |
417 | |
418 | @Override |
419 | public Integer visit(final ReceiverParameter n, final Void arg) { |
420 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getName().accept(this, arg)) * 31 + (n.getType().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
421 | } |
422 | |
423 | @Override |
424 | public Integer visit(final VarType n, final Void arg) { |
425 | return (n.getAnnotations().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
426 | } |
427 | |
428 | @Override |
429 | public Integer visit(final Modifier n, final Void arg) { |
430 | return (n.getKeyword().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
431 | } |
432 | |
433 | @Override |
434 | public Integer visit(final SwitchExpr n, final Void arg) { |
435 | return (n.getEntries().accept(this, arg)) * 31 + (n.getSelector().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
436 | } |
437 | |
438 | @Override |
439 | public Integer visit(final YieldStmt n, final Void arg) { |
440 | return (n.getExpression().accept(this, arg)) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
441 | } |
442 | |
443 | @Override |
444 | public Integer visit(final TextBlockLiteralExpr n, final Void arg) { |
445 | return (n.getValue().hashCode()) * 31 + (n.getComment().isPresent() ? n.getComment().get().accept(this, arg) : 0); |
446 | } |
447 | } |
448 |
Members