1 | /******************************************************************************* |
---|---|
2 | * Copyright (c) 2000, 2020 IBM Corporation and others. |
3 | * |
4 | * This program and the accompanying materials |
5 | * are made available under the terms of the Eclipse Public License 2.0 |
6 | * which accompanies this distribution, and is available at |
7 | * https://www.eclipse.org/legal/epl-2.0/ |
8 | * |
9 | * SPDX-License-Identifier: EPL-2.0 |
10 | * |
11 | * Contributors: |
12 | * IBM Corporation - initial API and implementation |
13 | *******************************************************************************/ |
14 | |
15 | package org.eclipse.jdt.core.dom; |
16 | |
17 | import org.eclipse.jdt.core.WorkingCopyOwner; |
18 | import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
19 | import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
20 | import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; |
21 | import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; |
22 | |
23 | /** |
24 | * A binding resolver is an internal mechanism for figuring out the binding |
25 | * for a major declaration, type, or name reference. This also handles |
26 | * the creation and mapping between annotations and the ast nodes that define them. |
27 | * <p> |
28 | * The default implementation serves as the default binding resolver |
29 | * that does no resolving whatsoever. Internal subclasses do all the real work. |
30 | * </p> |
31 | * |
32 | * @see AST#getBindingResolver |
33 | */ |
34 | class BindingResolver { |
35 | |
36 | /** |
37 | * Creates a binding resolver. |
38 | */ |
39 | BindingResolver() { |
40 | // default implementation: do nothing |
41 | } |
42 | |
43 | /** |
44 | * Finds the corresponding AST node from which the given binding originated. |
45 | * Returns <code>null</code> if the binding does not correspond to any node |
46 | * in the compilation unit. |
47 | * <p> |
48 | * The following table indicates the expected node type for the various |
49 | * different kinds of bindings: |
50 | * <ul> |
51 | * <li></li> |
52 | * <li>package - a <code>PackageDeclaration</code></li> |
53 | * <li>class or interface - a <code>TypeDeclaration</code> or a |
54 | * <code>ClassInstanceCreation</code> (for anonymous classes) </li> |
55 | * <li>primitive type - none</li> |
56 | * <li>array type - none</li> |
57 | * <li>field - a <code>VariableDeclarationFragment</code> in a |
58 | * <code>FieldDeclaration</code> </li> |
59 | * <li>local variable - a <code>SingleVariableDeclaration</code>, or |
60 | * a <code>VariableDeclarationFragment</code> in a |
61 | * <code>VariableDeclarationStatement</code> or |
62 | * <code>VariableDeclarationExpression</code></li> |
63 | * <li>method - a <code>MethodDeclaration</code> </li> |
64 | * <li>constructor - a <code>MethodDeclaration</code> </li> |
65 | * <li>annotation type - an <code>AnnotationTypeDeclaration</code> |
66 | * <li>annotation type member - an <code>AnnotationTypeMemberDeclaration</code> |
67 | * </ul> |
68 | * </p> |
69 | * <p> |
70 | * The implementation of <code>CompilationUnit.findDeclaringNode</code> |
71 | * forwards to this method. |
72 | * </p> |
73 | * <p> |
74 | * The default implementation of this method returns <code>null</code>. |
75 | * Subclasses may reimplement. |
76 | * </p> |
77 | * |
78 | * @param binding the binding |
79 | * @return the corresponding node where the bindings is declared, |
80 | * or <code>null</code> if none |
81 | */ |
82 | ASTNode findDeclaringNode(IBinding binding) { |
83 | return null; |
84 | } |
85 | |
86 | /** |
87 | * Finds the corresponding AST node from which the given binding key originated. |
88 | * |
89 | * The default implementation of this method returns <code>null</code>. |
90 | * Subclasses may reimplement. |
91 | * </p> |
92 | * |
93 | * @param bindingKey the binding key |
94 | * @return the corresponding node where the bindings is declared, |
95 | * or <code>null</code> if none |
96 | */ |
97 | ASTNode findDeclaringNode(String bindingKey) { |
98 | return null; |
99 | } |
100 | |
101 | /** |
102 | * Finds the corresponding AST node from which the given annotation instance originated. |
103 | * |
104 | * The default implementation of this method returns <code>null</code>. |
105 | * Subclasses may reimplement. |
106 | * </p> |
107 | * |
108 | * @param instance the dom annotation |
109 | * @return the corresponding node where the bindings is declared, |
110 | * or <code>null</code> if none |
111 | */ |
112 | ASTNode findDeclaringNode(IAnnotationBinding instance) { |
113 | return null; |
114 | } |
115 | |
116 | /** |
117 | * Allows the user to get information about the given old/new pair of |
118 | * AST nodes. |
119 | * <p> |
120 | * The default implementation of this method does nothing. |
121 | * Subclasses may reimplement. |
122 | * </p> |
123 | * |
124 | * @param currentNode the new node |
125 | * @return org.eclipse.jdt.internal.compiler.ast.ASTNode |
126 | */ |
127 | org.eclipse.jdt.internal.compiler.ast.ASTNode getCorrespondingNode(ASTNode currentNode) { |
128 | return null; |
129 | } |
130 | |
131 | /** |
132 | * Returns the new method binding corresponding to the given old method binding. |
133 | * <p> |
134 | * The default implementation of this method returns <code>null</code>. |
135 | * Subclasses may reimplement. |
136 | * </p> |
137 | * |
138 | * @param methodBinding the old method binding |
139 | * @return the new method binding |
140 | */ |
141 | IMethodBinding getMethodBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding) { |
142 | return null; |
143 | } |
144 | |
145 | /** |
146 | * Returns the new member value pair binding corresponding to the given old value pair binding. |
147 | * <p> |
148 | * The default implementation of this method returns <code>null</code>. |
149 | * Subclasses may reimplement. |
150 | * </p> |
151 | * |
152 | * @param valuePair the old value pair binding |
153 | * @return the new member value pair binding |
154 | */ |
155 | IMemberValuePairBinding getMemberValuePairBinding(ElementValuePair valuePair) { |
156 | return null; |
157 | } |
158 | |
159 | /** |
160 | * Returns the new module binding corresponding to the given old module binding. |
161 | * <p> |
162 | * The default implementation of this method returns <code>null</code>. |
163 | * Subclasses may reimplement. |
164 | * </p> |
165 | * |
166 | * @param moduleBinding the old module binding |
167 | * @return the new module binding |
168 | * |
169 | */ |
170 | IModuleBinding getModuleBinding(org.eclipse.jdt.internal.compiler.lookup.ModuleBinding moduleBinding) { |
171 | return null; |
172 | } |
173 | |
174 | /** |
175 | * Returns the new package binding corresponding to the given old package binding. |
176 | * <p> |
177 | * The default implementation of this method returns <code>null</code>. |
178 | * Subclasses may reimplement. |
179 | * </p> |
180 | * |
181 | * @param packageBinding the old package binding |
182 | * @return the new package binding |
183 | */ |
184 | IPackageBinding getPackageBinding(org.eclipse.jdt.internal.compiler.lookup.PackageBinding packageBinding) { |
185 | return null; |
186 | } |
187 | |
188 | /** |
189 | * Returns the new type binding corresponding to the given old type binding. |
190 | * <p> |
191 | * The default implementation of this method returns <code>null</code>. |
192 | * Subclasses may reimplement. |
193 | * </p> |
194 | * |
195 | * @param referenceBinding the old type binding |
196 | * @return the new type binding |
197 | */ |
198 | ITypeBinding getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) { |
199 | return null; |
200 | } |
201 | |
202 | |
203 | /** |
204 | * Returns the new type binding corresponding to the given variableDeclaration. |
205 | * This is used for recovered binding only. |
206 | * <p> |
207 | * The default implementation of this method returns <code>null</code>. |
208 | * Subclasses may reimplement. |
209 | * </p> |
210 | * |
211 | * @param variableDeclaration the given variable declaration |
212 | * @return the new type binding |
213 | */ |
214 | ITypeBinding getTypeBinding(VariableDeclaration variableDeclaration) { |
215 | return null; |
216 | } |
217 | |
218 | /** |
219 | * Returns the new type binding corresponding to the given type. This is used for recovered binding |
220 | * only. |
221 | * <p> |
222 | * The default implementation of this method returns <code>null</code>. |
223 | * Subclasses may reimplement. |
224 | * </p> |
225 | * |
226 | * @param type the given type |
227 | * @return the new type binding |
228 | */ |
229 | ITypeBinding getTypeBinding(Type type) { |
230 | return null; |
231 | } |
232 | |
233 | /** |
234 | * Returns the new type binding corresponding to the given recovered type binding. |
235 | * <p> |
236 | * The default implementation of this method returns <code>null</code>. |
237 | * Subclasses may reimplement. |
238 | * </p> |
239 | * |
240 | * @param recoveredTypeBinding the recovered type binding |
241 | * @param dimensions the dimensions to add the to given type binding dimensions |
242 | * @return the new type binding |
243 | */ |
244 | ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) { |
245 | return null; |
246 | } |
247 | |
248 | /** |
249 | * Returns the new variable binding corresponding to the given old variable binding. |
250 | * <p> |
251 | * The default implementation of this method returns <code>null</code>. |
252 | * Subclasses may reimplement. |
253 | * </p> |
254 | * |
255 | * @param binding the old variable binding |
256 | * @return the new variable binding |
257 | */ |
258 | IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding binding) { |
259 | return null; |
260 | } |
261 | |
262 | /** |
263 | * Return the working copy owner for the receiver. |
264 | * <p> |
265 | * The default implementation of this method returns <code>null</code>. |
266 | * Subclasses may reimplement. |
267 | * </p> |
268 | * @return the working copy owner for the receiver |
269 | */ |
270 | public WorkingCopyOwner getWorkingCopyOwner() { |
271 | return null; |
272 | } |
273 | |
274 | /** |
275 | * Return the new annotation corresponding to the given old annotation |
276 | * <p> |
277 | * The default implementation of this method returns <code>null</code> |
278 | * Subclasses may reimplement. |
279 | * </p> |
280 | * |
281 | * @param instance the old annotation |
282 | * @return the new DOM annotation |
283 | */ |
284 | IAnnotationBinding getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding instance) { |
285 | return null; |
286 | } |
287 | |
288 | boolean isResolvedTypeInferredFromExpectedType(MethodInvocation methodInvocation) { |
289 | return false; |
290 | } |
291 | |
292 | boolean isResolvedTypeInferredFromExpectedType(SuperMethodInvocation methodInvocation) { |
293 | return false; |
294 | } |
295 | |
296 | boolean isResolvedTypeInferredFromExpectedType(ClassInstanceCreation classInstanceCreation) { |
297 | return false; |
298 | } |
299 | |
300 | /** |
301 | * Returns the compiler lookup environment used by this binding resolver. |
302 | * Returns <code>null</code> if none. |
303 | * |
304 | * @return the lookup environment used by this resolver, or <code>null</code> if none. |
305 | */ |
306 | LookupEnvironment lookupEnvironment() { |
307 | return null; |
308 | } |
309 | |
310 | /** |
311 | * This method is used to record the scope and its corresponding node. |
312 | * <p> |
313 | * The default implementation of this method does nothing. |
314 | * Subclasses may reimplement. |
315 | * </p> |
316 | * @param astNode |
317 | */ |
318 | void recordScope(ASTNode astNode, BlockScope blockScope) { |
319 | // default implementation: do nothing |
320 | } |
321 | |
322 | /** |
323 | * Returns whether this expression node is the site of a boxing |
324 | * conversion (JLS3 5.1.7). This information is available only |
325 | * when bindings are requested when the AST is being built. |
326 | * |
327 | * @return <code>true</code> if this expression is the site of a |
328 | * boxing conversion, or <code>false</code> if either no boxing conversion |
329 | * is involved or if bindings were not requested when the AST was created |
330 | * @since 3.1 |
331 | */ |
332 | boolean resolveBoxing(Expression expression) { |
333 | return false; |
334 | } |
335 | |
336 | /** |
337 | * Returns whether this expression node is the site of an unboxing |
338 | * conversion (JLS3 5.1.8). This information is available only |
339 | * when bindings are requested when the AST is being built. |
340 | * |
341 | * @return <code>true</code> if this expression is the site of an |
342 | * unboxing conversion, or <code>false</code> if either no unboxing |
343 | * conversion is involved or if bindings were not requested when the |
344 | * AST was created |
345 | * @since 3.1 |
346 | */ |
347 | boolean resolveUnboxing(Expression expression) { |
348 | return false; |
349 | } |
350 | |
351 | /** |
352 | * Resolves and returns the compile-time constant expression value as |
353 | * specified in JLS2 15.28, if this expression has one. Constant expression |
354 | * values are unavailable unless bindings are requested when the AST is |
355 | * being built. If the type of the value is a primitive type, the result |
356 | * is the boxed equivalent (i.e., int returned as an <code>Integer</code>); |
357 | * if the type of the value is <code>String</code>, the result is the string |
358 | * itself. If the expression does not have a compile-time constant expression |
359 | * value, the result is <code>null</code>. |
360 | * <p> |
361 | * Resolving constant expressions takes into account the value of simple |
362 | * and qualified names that refer to constant variables (JLS2 4.12.4). |
363 | * </p> |
364 | * <p> |
365 | * Note 1: enum constants are not considered constant expressions either. |
366 | * The result is always <code>null</code> for these. |
367 | * </p> |
368 | * <p> |
369 | * Note 2: Compile-time constant expressions cannot denote <code>null</code>. |
370 | * So technically {@link NullLiteral} nodes are not constant expressions. |
371 | * The result is <code>null</code> for these nonetheless. |
372 | * </p> |
373 | * |
374 | * @return the constant expression value, or <code>null</code> if this |
375 | * expression has no constant expression value or if bindings were not |
376 | * requested when the AST was created |
377 | * @since 3.1 |
378 | */ |
379 | Object resolveConstantExpressionValue(Expression expression) { |
380 | return null; |
381 | } |
382 | |
383 | /** |
384 | * Resolves and returns the binding for the constructor being invoked. |
385 | * <p> |
386 | * The implementation of |
387 | * <code>ClassInstanceCreation.resolveConstructor</code> |
388 | * forwards to this method. Which constructor is invoked is often a function |
389 | * of the context in which the expression node is embedded as well as |
390 | * the expression subtree itself. |
391 | * </p> |
392 | * <p> |
393 | * The default implementation of this method returns <code>null</code>. |
394 | * Subclasses may reimplement. |
395 | * </p> |
396 | * |
397 | * @param expression the expression of interest |
398 | * @return the binding for the constructor being invoked, or |
399 | * <code>null</code> if no binding is available |
400 | */ |
401 | IMethodBinding resolveConstructor(ClassInstanceCreation expression) { |
402 | return null; |
403 | } |
404 | |
405 | /** |
406 | * Resolves and returns the binding for the constructor being invoked. |
407 | * <p> |
408 | * The implementation of |
409 | * <code>ConstructorInvocation.resolveConstructor</code> |
410 | * forwards to this method. Which constructor is invoked is often a function |
411 | * of the context in which the expression node is embedded as well as |
412 | * the expression subtree itself. |
413 | * </p> |
414 | * <p> |
415 | * The default implementation of this method returns <code>null</code>. |
416 | * Subclasses may reimplement. |
417 | * </p> |
418 | * |
419 | * @param expression the expression of interest |
420 | * @return the binding for the constructor being invoked, or |
421 | * <code>null</code> if no binding is available |
422 | */ |
423 | IMethodBinding resolveConstructor(ConstructorInvocation expression) { |
424 | return null; |
425 | } |
426 | /** |
427 | * Resolves and returns the binding for the constructor being invoked. |
428 | * <p> |
429 | * The implementation of |
430 | * <code>ConstructorInvocation.resolveConstructor</code> |
431 | * forwards to this method. Which constructor is invoked is often a function |
432 | * of the context in which the expression node is embedded as well as |
433 | * the expression subtree itself. |
434 | * </p> |
435 | * <p> |
436 | * The default implementation of this method returns <code>null</code>. |
437 | * Subclasses may reimplement. |
438 | * </p> |
439 | * |
440 | * @param enumConstantDeclaration the enum constant declaration of interest |
441 | * @return the binding for the constructor being invoked, or |
442 | * <code>null</code> if no binding is available |
443 | */ |
444 | IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) { |
445 | return null; |
446 | } |
447 | /** |
448 | * Resolves and returns the binding for the constructor being invoked. |
449 | * <p> |
450 | * The implementation of |
451 | * <code>SuperConstructorInvocation.resolveConstructor</code> |
452 | * forwards to this method. Which constructor is invoked is often a function |
453 | * of the context in which the expression node is embedded as well as |
454 | * the expression subtree itself. |
455 | * </p> |
456 | * <p> |
457 | * The default implementation of this method returns <code>null</code>. |
458 | * Subclasses may reimplement. |
459 | * </p> |
460 | * |
461 | * @param expression the expression of interest |
462 | * @return the binding for the constructor being invoked, or |
463 | * <code>null</code> if no binding is available |
464 | */ |
465 | IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { |
466 | return null; |
467 | } |
468 | /** |
469 | * Resolves the type of the given expression and returns the type binding |
470 | * for it. |
471 | * <p> |
472 | * The implementation of <code>Expression.resolveTypeBinding</code> |
473 | * forwards to this method. The result is often a function of the context |
474 | * in which the expression node is embedded as well as the expression |
475 | * subtree itself. |
476 | * </p> |
477 | * <p> |
478 | * The default implementation of this method returns <code>null</code>. |
479 | * Subclasses may reimplement. |
480 | * </p> |
481 | * |
482 | * @param expression the expression whose type is of interest |
483 | * @return the binding for the type of the given expression, or |
484 | * <code>null</code> if no binding is available |
485 | */ |
486 | ITypeBinding resolveExpressionType(Expression expression) { |
487 | return null; |
488 | } |
489 | |
490 | /** |
491 | * Resolves the given field access and returns the binding for it. |
492 | * <p> |
493 | * The implementation of <code>FieldAccess.resolveFieldBinding</code> |
494 | * forwards to this method. How the field resolves is often a function of |
495 | * the context in which the field access node is embedded as well as |
496 | * the field access subtree itself. |
497 | * </p> |
498 | * <p> |
499 | * The default implementation of this method returns <code>null</code>. |
500 | * Subclasses may reimplement. |
501 | * </p> |
502 | * |
503 | * @param fieldAccess the field access of interest |
504 | * @return the binding for the given field access, or |
505 | * <code>null</code> if no binding is available |
506 | */ |
507 | IVariableBinding resolveField(FieldAccess fieldAccess) { |
508 | return null; |
509 | } |
510 | |
511 | /** |
512 | * Resolves the given super field access and returns the binding for it. |
513 | * <p> |
514 | * The implementation of <code>SuperFieldAccess.resolveFieldBinding</code> |
515 | * forwards to this method. How the field resolves is often a function of |
516 | * the context in which the super field access node is embedded as well as |
517 | * the super field access subtree itself. |
518 | * </p> |
519 | * <p> |
520 | * The default implementation of this method returns <code>null</code>. |
521 | * Subclasses may reimplement. |
522 | * </p> |
523 | * |
524 | * @param fieldAccess the super field access of interest |
525 | * @return the binding for the given field access, or |
526 | * <code>null</code> if no binding is available |
527 | */ |
528 | IVariableBinding resolveField(SuperFieldAccess fieldAccess) { |
529 | return null; |
530 | } |
531 | |
532 | /** |
533 | * Resolves the given import declaration and returns the binding for it. |
534 | * <p> |
535 | * The implementation of <code>ImportDeclaration.resolveBinding</code> |
536 | * forwards to this method. |
537 | * </p> |
538 | * <p> |
539 | * The default implementation of this method returns <code>null</code>. |
540 | * Subclasses may reimplement. |
541 | * </p> |
542 | * |
543 | * @param importDeclaration the import declaration of interest |
544 | * @return the binding for the given package declaration, or |
545 | * the package binding (for on-demand imports) or type binding |
546 | * (for single-type imports), or <code>null</code> if no binding is |
547 | * available |
548 | */ |
549 | IBinding resolveImport(ImportDeclaration importDeclaration) { |
550 | return null; |
551 | } |
552 | |
553 | /** |
554 | * Resolves the given annotation type declaration and returns the binding |
555 | * for it. |
556 | * <p> |
557 | * The implementation of <code>AnnotationTypeMemberDeclaration.resolveBinding</code> |
558 | * forwards to this method. How the declaration resolves is often a |
559 | * function of the context in which the declaration node is embedded as well |
560 | * as the declaration subtree itself. |
561 | * </p> |
562 | * <p> |
563 | * The default implementation of this method returns <code>null</code>. |
564 | * Subclasses may reimplement. |
565 | * </p> |
566 | * |
567 | * @param member the annotation type member declaration of interest |
568 | * @return the binding for the given annotation type member declaration, or <code>null</code> |
569 | * if no binding is available |
570 | * @since 3.0 |
571 | */ |
572 | IMethodBinding resolveMember(AnnotationTypeMemberDeclaration member) { |
573 | return null; |
574 | } |
575 | |
576 | /** |
577 | * Resolves the given method declaration and returns the binding for it. |
578 | * <p> |
579 | * The implementation of <code>MethodDeclaration.resolveBinding</code> |
580 | * forwards to this method. How the method resolves is often a function of |
581 | * the context in which the method declaration node is embedded as well as |
582 | * the method declaration subtree itself. |
583 | * </p> |
584 | * <p> |
585 | * The default implementation of this method returns <code>null</code>. |
586 | * Subclasses may reimplement. |
587 | * </p> |
588 | * |
589 | * @param method the method or constructor declaration of interest |
590 | * @return the binding for the given method declaration, or |
591 | * <code>null</code> if no binding is available |
592 | */ |
593 | IMethodBinding resolveMethod(MethodDeclaration method) { |
594 | return null; |
595 | } |
596 | |
597 | /** |
598 | * Resolves the given method reference and returns the binding for it. |
599 | * <p> |
600 | * The implementation of <code>MethodReference.resolveMethodBinding</code> |
601 | * forwards to this method. How the method resolves is often a function of |
602 | * the context in which the method reference node is embedded as well as |
603 | * the method reference subtree itself. |
604 | * </p> |
605 | * <p> |
606 | * The default implementation of this method returns <code>null</code>. |
607 | * Subclasses may reimplement. |
608 | * </p> |
609 | * |
610 | * @param methodReference the method reference of interest |
611 | * @return the binding for the given method reference, or |
612 | * <code>null</code> if no binding is available |
613 | * @since 3.10 |
614 | */ |
615 | IMethodBinding resolveMethod(MethodReference methodReference) { |
616 | return null; |
617 | } |
618 | |
619 | /** |
620 | * Resolves the given Lambda Expression and returns the binding for it. |
621 | * <p> |
622 | * The implementation of <code>LambdaExpression.resolveMethodBinding</code> |
623 | * forwards to this method. How the method resolves is often a function of |
624 | * the context in which the method declaration node is embedded as well as |
625 | * the method declaration subtree itself. |
626 | * </p> |
627 | * <p> |
628 | * The default implementation of this method returns <code>null</code>. |
629 | * Subclasses may re-implement. |
630 | * </p> |
631 | * |
632 | * @param lambda LambdaExpression of interest |
633 | * @return the binding for the given lambda expression, or |
634 | * <code>null</code> if no binding is available |
635 | */ |
636 | IMethodBinding resolveMethod(LambdaExpression lambda) { |
637 | return null; |
638 | } |
639 | |
640 | /** |
641 | * Resolves the given method invocation and returns the binding for it. |
642 | * <p> |
643 | * The implementation of <code>MethodInvocation.resolveMethodBinding</code> |
644 | * forwards to this method. How the method resolves is often a function of |
645 | * the context in which the method invocation node is embedded as well as |
646 | * the method invocation subtree itself. |
647 | * </p> |
648 | * <p> |
649 | * The default implementation of this method returns <code>null</code>. |
650 | * Subclasses may reimplement. |
651 | * </p> |
652 | * |
653 | * @param method the method invocation of interest |
654 | * @return the binding for the given method invocation, or |
655 | * <code>null</code> if no binding is available |
656 | */ |
657 | IMethodBinding resolveMethod(MethodInvocation method) { |
658 | return null; |
659 | } |
660 | |
661 | /** |
662 | * Resolves the given method invocation and returns the binding for it. |
663 | * <p> |
664 | * The implementation of <code>MethodInvocation.resolveMethodBinding</code> |
665 | * forwards to this method. How the method resolves is often a function of |
666 | * the context in which the method invocation node is embedded as well as |
667 | * the method invocation subtree itself. |
668 | * </p> |
669 | * <p> |
670 | * The default implementation of this method returns <code>null</code>. |
671 | * Subclasses may reimplement. |
672 | * </p> |
673 | * |
674 | * @param method the method invocation of interest |
675 | * @return the binding for the given method invocation, or |
676 | * <code>null</code> if no binding is available |
677 | */ |
678 | IMethodBinding resolveMethod(SuperMethodInvocation method) { |
679 | return null; |
680 | } |
681 | |
682 | /** |
683 | * Resolves the given module declaration and returns the binding for it. |
684 | * <p> |
685 | * The implementation of <code>ModuleDeclaration.resolveBinding</code> |
686 | * forwards to this method. How the method resolves is often a function of |
687 | * the context in which the method declaration node is embedded as well as |
688 | * the method declaration subtree itself. |
689 | * </p> |
690 | * <p> |
691 | * The default implementation of this method returns <code>null</code>. |
692 | * Subclasses may reimplement. |
693 | * </p> |
694 | * |
695 | * @param module declaration of interest |
696 | * @return the binding for the given module declaration, or |
697 | * <code>null</code> if no binding is available |
698 | * |
699 | * @since 3.14 |
700 | */ |
701 | IModuleBinding resolveModule(ModuleDeclaration module) { |
702 | return null; |
703 | } |
704 | |
705 | /** |
706 | * Resolves the given name and returns the type binding for it. |
707 | * <p> |
708 | * The implementation of <code>Name.resolveBinding</code> forwards to |
709 | * this method. How the name resolves is often a function of the context |
710 | * in which the name node is embedded as well as the name itself. |
711 | * </p> |
712 | * <p> |
713 | * The default implementation of this method returns <code>null</code>. |
714 | * Subclasses may reimplement. |
715 | * </p> |
716 | * |
717 | * @param name the name of interest |
718 | * @return the binding for the name, or <code>null</code> if no binding is |
719 | * available |
720 | */ |
721 | IBinding resolveName(Name name) { |
722 | return null; |
723 | } |
724 | |
725 | /** |
726 | * Resolves the given package declaration and returns the binding for it. |
727 | * <p> |
728 | * The implementation of <code>PackageDeclaration.resolveBinding</code> |
729 | * forwards to this method. |
730 | * </p> |
731 | * <p> |
732 | * The default implementation of this method returns <code>null</code>. |
733 | * Subclasses may reimplement. |
734 | * </p> |
735 | * |
736 | * @param pkg the package declaration of interest |
737 | * @return the binding for the given package declaration, or |
738 | * <code>null</code> if no binding is available |
739 | */ |
740 | IPackageBinding resolvePackage(PackageDeclaration pkg) { |
741 | return null; |
742 | } |
743 | |
744 | /** |
745 | * Resolves the given reference and returns the binding for it. |
746 | * <p> |
747 | * The implementation of <code>MemberRef.resolveBinding</code> forwards to |
748 | * this method. How the name resolves is often a function of the context |
749 | * in which the name node is embedded as well as the name itself. |
750 | * </p> |
751 | * <p> |
752 | * The default implementation of this method returns <code>null</code>. |
753 | * Subclasses may reimplement. |
754 | * </p> |
755 | * |
756 | * @param ref the reference of interest |
757 | * @return the binding for the reference, or <code>null</code> if no binding is |
758 | * available |
759 | * @since 3.0 |
760 | */ |
761 | IBinding resolveReference(MemberRef ref) { |
762 | return null; |
763 | } |
764 | |
765 | /** |
766 | * Resolves the given member value pair and returns the binding for it. |
767 | * <p> |
768 | * The implementation of <code>MemberValuePair.resolveMemberValuePairBinding</code> forwards to |
769 | * this method. How the name resolves is often a function of the context |
770 | * in which the name node is embedded as well as the name itself. |
771 | * </p> |
772 | * <p> |
773 | * The default implementation of this method returns <code>null</code>. |
774 | * Subclasses may reimplement. |
775 | * </p> |
776 | * |
777 | * @param memberValuePair the member value pair of interest |
778 | * @return the binding for the member value pair, or <code>null</code> if no binding is |
779 | * available |
780 | * @since 3.2 |
781 | */ |
782 | IMemberValuePairBinding resolveMemberValuePair(MemberValuePair memberValuePair) { |
783 | return null; |
784 | } |
785 | |
786 | /** |
787 | * Resolves the given reference and returns the binding for it. |
788 | * <p> |
789 | * The implementation of <code>MethodRef.resolveBinding</code> forwards to |
790 | * this method. How the name resolves is often a function of the context |
791 | * in which the name node is embedded as well as the name itself. |
792 | * </p> |
793 | * <p> |
794 | * The default implementation of this method returns <code>null</code>. |
795 | * Subclasses may reimplement. |
796 | * </p> |
797 | * |
798 | * @param ref the reference of interest |
799 | * @return the binding for the reference, or <code>null</code> if no binding is |
800 | * available |
801 | * @since 3.0 |
802 | */ |
803 | IBinding resolveReference(MethodRef ref) { |
804 | return null; |
805 | } |
806 | |
807 | /** |
808 | * Resolves the given annotation type declaration and returns the binding |
809 | * for it. |
810 | * <p> |
811 | * The implementation of <code>AnnotationTypeDeclaration.resolveBinding</code> |
812 | * forwards to this method. How the declaration resolves is often a |
813 | * function of the context in which the declaration node is embedded as well |
814 | * as the declaration subtree itself. |
815 | * </p> |
816 | * <p> |
817 | * The default implementation of this method returns <code>null</code>. |
818 | * Subclasses may reimplement. |
819 | * </p> |
820 | * |
821 | * @param type the annotation type declaration of interest |
822 | * @return the binding for the given annotation type declaration, or <code>null</code> |
823 | * if no binding is available |
824 | * @since 3.0 |
825 | */ |
826 | ITypeBinding resolveType(AnnotationTypeDeclaration type) { |
827 | return null; |
828 | } |
829 | |
830 | /** |
831 | * Resolves the given anonymous class declaration and returns the binding |
832 | * for it. |
833 | * <p> |
834 | * The implementation of <code>AnonymousClassDeclaration.resolveBinding</code> |
835 | * forwards to this method. How the declaration resolves is often a |
836 | * function of the context in which the declaration node is embedded as well |
837 | * as the declaration subtree itself. |
838 | * </p> |
839 | * <p> |
840 | * The default implementation of this method returns <code>null</code>. |
841 | * Subclasses may reimplement. |
842 | * </p> |
843 | * |
844 | * @param type the anonymous class declaration of interest |
845 | * @return the binding for the given class declaration, or <code>null</code> |
846 | * if no binding is available |
847 | */ |
848 | ITypeBinding resolveType(AnonymousClassDeclaration type) { |
849 | return null; |
850 | } |
851 | |
852 | /** |
853 | * Resolves the given enum declaration and returns the binding |
854 | * for it. |
855 | * <p> |
856 | * The implementation of <code>EnumDeclaration.resolveBinding</code> |
857 | * forwards to this method. How the enum declaration resolves is often |
858 | * a function of the context in which the declaration node is embedded |
859 | * as well as the enum declaration subtree itself. |
860 | * </p> |
861 | * <p> |
862 | * The default implementation of this method returns <code>null</code>. |
863 | * Subclasses may reimplement. |
864 | * </p> |
865 | * |
866 | * @param type the enum declaration of interest |
867 | * @return the binding for the given enum declaration, or <code>null</code> |
868 | * if no binding is available |
869 | * @since 3.0 |
870 | */ |
871 | ITypeBinding resolveType(EnumDeclaration type) { |
872 | return null; |
873 | } |
874 | |
875 | /** |
876 | * Resolves the given record declaration and returns the binding |
877 | * for it. |
878 | * <p> |
879 | * The implementation of <code>RecordDeclaration.resolveBinding</code> |
880 | * forwards to this method. How the record declaration resolves is often |
881 | * a function of the context in which the declaration node is embedded |
882 | * as well as the record declaration subtree itself. |
883 | * </p> |
884 | * <p> |
885 | * The default implementation of this method returns <code>null</code>. |
886 | * Subclasses may re implement. |
887 | * </p> |
888 | * |
889 | * @param type the record declaration of interest |
890 | * @return the binding for the given record declaration, or <code>null</code> |
891 | * if no binding is available |
892 | * @since 3.22 |
893 | */ |
894 | ITypeBinding resolveType(RecordDeclaration type) { |
895 | return null; |
896 | } |
897 | |
898 | /** |
899 | * Resolves the given type and returns the type binding for it. |
900 | * <p> |
901 | * The implementation of <code>Type.resolveBinding</code> |
902 | * forwards to this method. How the type resolves is often a function |
903 | * of the context in which the type node is embedded as well as the type |
904 | * subtree itself. |
905 | * </p> |
906 | * <p> |
907 | * The default implementation of this method returns <code>null</code>. |
908 | * Subclasses may reimplement. |
909 | * </p> |
910 | * |
911 | * @param type the type of interest |
912 | * @return the binding for the given type, or <code>null</code> |
913 | * if no binding is available |
914 | */ |
915 | ITypeBinding resolveType(Type type) { |
916 | return null; |
917 | } |
918 | |
919 | /** |
920 | * Resolves the given class or interface declaration and returns the binding |
921 | * for it. |
922 | * <p> |
923 | * The implementation of <code>TypeDeclaration.resolveBinding</code> |
924 | * (and <code>TypeDeclarationStatement.resolveBinding</code>) forwards |
925 | * to this method. How the type declaration resolves is often a function of |
926 | * the context in which the type declaration node is embedded as well as the |
927 | * type declaration subtree itself. |
928 | * </p> |
929 | * <p> |
930 | * The default implementation of this method returns <code>null</code>. |
931 | * Subclasses may reimplement. |
932 | * </p> |
933 | * |
934 | * @param type the class or interface declaration of interest |
935 | * @return the binding for the given type declaration, or <code>null</code> |
936 | * if no binding is available |
937 | */ |
938 | ITypeBinding resolveType(TypeDeclaration type) { |
939 | return null; |
940 | } |
941 | |
942 | /** |
943 | * Resolves the given type parameter and returns the type binding for the |
944 | * type parameter. |
945 | * <p> |
946 | * The implementation of <code>TypeParameter.resolveBinding</code> |
947 | * forwards to this method. How the declaration resolves is often a |
948 | * function of the context in which the declaration node is embedded as well |
949 | * as the declaration subtree itself. |
950 | * </p> |
951 | * <p> |
952 | * The default implementation of this method returns <code>null</code>. |
953 | * Subclasses may reimplement. |
954 | * </p> |
955 | * |
956 | * @param typeParameter the type paramter of interest |
957 | * @return the binding for the given type parameter, or <code>null</code> |
958 | * if no binding is available |
959 | * @since 3.1 |
960 | */ |
961 | ITypeBinding resolveTypeParameter(TypeParameter typeParameter) { |
962 | return null; |
963 | } |
964 | |
965 | /** |
966 | * Resolves the given enum constant declaration and returns the binding for |
967 | * the field. |
968 | * <p> |
969 | * The implementation of <code>EnumConstantDeclaration.resolveVariable</code> |
970 | * forwards to this method. |
971 | * </p> |
972 | * <p> |
973 | * The default implementation of this method returns <code>null</code>. |
974 | * Subclasses may reimplement. |
975 | * </p> |
976 | * |
977 | * @param enumConstant the enum constant declaration of interest |
978 | * @return the field binding for the given enum constant declaration, or |
979 | * <code>null</code> if no binding is available |
980 | * @since 3.0 |
981 | */ |
982 | IVariableBinding resolveVariable(EnumConstantDeclaration enumConstant) { |
983 | return null; |
984 | } |
985 | |
986 | /** |
987 | * Resolves the given variable declaration and returns the binding for it. |
988 | * <p> |
989 | * The implementation of <code>VariableDeclaration.resolveBinding</code> |
990 | * forwards to this method. How the variable declaration resolves is often |
991 | * a function of the context in which the variable declaration node is |
992 | * embedded as well as the variable declaration subtree itself. VariableDeclaration |
993 | * declarations used as local variable, formal parameter and exception |
994 | * variables resolve to local variable bindings; variable declarations |
995 | * used to declare fields resolve to field bindings. |
996 | * </p> |
997 | * <p> |
998 | * The default implementation of this method returns <code>null</code>. |
999 | * Subclasses may reimplement. |
1000 | * </p> |
1001 | * |
1002 | * @param variable the variable declaration of interest |
1003 | * @return the binding for the given variable declaration, or |
1004 | * <code>null</code> if no binding is available |
1005 | */ |
1006 | IVariableBinding resolveVariable(VariableDeclaration variable) { |
1007 | return null; |
1008 | } |
1009 | |
1010 | /** |
1011 | * Resolves the given well known type by name and returns the type binding |
1012 | * for it. |
1013 | * <p> |
1014 | * The implementation of <code>AST.resolveWellKnownType</code> |
1015 | * forwards to this method. |
1016 | * </p> |
1017 | * <p> |
1018 | * The default implementation of this method returns <code>null</code>. |
1019 | * Subclasses may reimplement. |
1020 | * </p> |
1021 | * |
1022 | * @param name the name of a well known type |
1023 | * @return the corresponding type binding, or <code>null<code> if the |
1024 | * named type is not considered well known or if no binding can be found |
1025 | * for it |
1026 | */ |
1027 | ITypeBinding resolveWellKnownType(String name) { |
1028 | return null; |
1029 | } |
1030 | |
1031 | /** |
1032 | * Resolves the given annotation instance and returns the DOM representation for it. |
1033 | * <p> |
1034 | * The implementation of {@link Annotation#resolveAnnotationBinding()} |
1035 | * forwards to this method. |
1036 | * </p> |
1037 | * <p> |
1038 | * The default implementation of this method returns <code>null</code>. |
1039 | * Subclasses may reimplement. |
1040 | * </p> |
1041 | * |
1042 | * @param annotation the annotation ast node of interest |
1043 | * @return the DOM annotation representation for the given ast node, or |
1044 | * <code>null</code> if none is available |
1045 | */ |
1046 | IAnnotationBinding resolveAnnotation(Annotation annotation) { |
1047 | return null; |
1048 | } |
1049 | |
1050 | /** |
1051 | * Answer an array type binding with the given type binding and the given |
1052 | * dimensions. |
1053 | * |
1054 | * <p>If the given type binding is an array binding, then the resulting dimensions is the given dimensions |
1055 | * plus the existing dimensions of the array binding. Otherwise the resulting dimensions is the given |
1056 | * dimensions.</p> |
1057 | * |
1058 | * <p> |
1059 | * The default implementation of this method returns <code>null</code>. |
1060 | * Subclasses may reimplement. |
1061 | * </p> |
1062 | * |
1063 | * @param typeBinding the given type binding |
1064 | * @param dimensions the given dimensions |
1065 | * @return an array type binding with the given type binding and the given |
1066 | * dimensions |
1067 | * @throws IllegalArgumentException if the type binding represents the <code>void</code> type binding |
1068 | */ |
1069 | ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) { |
1070 | return null; |
1071 | } |
1072 | |
1073 | /** |
1074 | * Returns the compilation unit scope used by this binding resolver. |
1075 | * Returns <code>null</code> if none. |
1076 | * |
1077 | * @return the compilation unit scope by this resolver, or <code>null</code> if none. |
1078 | */ |
1079 | public CompilationUnitScope scope() { |
1080 | return null; |
1081 | } |
1082 | |
1083 | /** |
1084 | * Allows the user to store information about the given old/new pair of |
1085 | * AST nodes. |
1086 | * <p> |
1087 | * The default implementation of this method does nothing. |
1088 | * Subclasses may reimplement. |
1089 | * </p> |
1090 | * |
1091 | * @param newNode the new AST node |
1092 | * @param oldASTNode the old AST node |
1093 | */ |
1094 | void store(ASTNode newNode, org.eclipse.jdt.internal.compiler.ast.ASTNode oldASTNode) { |
1095 | // default implementation: do nothing |
1096 | } |
1097 | |
1098 | /** |
1099 | * Allows the user to update information about the given old/new pair of |
1100 | * AST nodes. |
1101 | * <p> |
1102 | * The default implementation of this method does nothing. |
1103 | * Subclasses may reimplement. |
1104 | * </p> |
1105 | * |
1106 | * @param node the old AST node |
1107 | * @param newNode the new AST node |
1108 | */ |
1109 | void updateKey(ASTNode node, ASTNode newNode) { |
1110 | // default implementation: do nothing |
1111 | } |
1112 | } |
1113 |
Members