OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'package:analyzer/dart/ast/ast.dart'; | |
6 import 'package:analyzer/dart/ast/resolution_map.dart'; | |
7 import 'package:analyzer/dart/element/element.dart'; | |
8 import 'package:analyzer/dart/element/type.dart'; | |
9 | |
10 /** | |
11 * Concrete implementation of [ResolutionMap] based on the standard AST | |
12 * implementation. | |
13 */ | |
14 class ResolutionMapImpl implements ResolutionMap { | |
15 /** | |
16 * Return the best element available for the function being invoked at [node]. | |
17 * If resolution was able to find a better element based on type propagation, | |
18 * that element will be returned. Otherwise, the element found using the | |
19 * result of static analysis will be returned. If resolution has not been | |
20 * performed, then `null` will be returned. | |
21 */ | |
Brian Wilkerson
2016/12/07 18:26:20
nit: Given that the comments are all on the overri
Paul Berry
2016/12/07 18:55:02
Done.
| |
22 @override | |
23 ExecutableElement bestElementForFunctionExpressionInvocation( | |
24 FunctionExpressionInvocation node) => | |
25 node.bestElement; | |
26 | |
27 /** | |
28 * Return the best element available for the identifier [node]. If resolution | |
29 * was able to find a better element based on type propagation, that element | |
30 * will be returned. Otherwise, the element found using the result of static | |
31 * analysis will be returned. If resolution has not been performed, then | |
32 * `null` will be returned. | |
33 */ | |
34 @override | |
35 Element bestElementForIdentifier(Identifier node) => node.bestElement; | |
36 | |
37 /** | |
38 * Return the best element available for the expression [node]. If resolution | |
39 * was able to find a better element based on type propagation, that element | |
40 * will be returned. Otherwise, the element found using the result of static | |
41 * analysis will be returned. If resolution has not been performed, then | |
42 * `null` will be returned. | |
43 */ | |
44 @override | |
45 MethodElement bestElementForMethodReference(MethodReferenceExpression node) => | |
46 node.bestElement; | |
47 | |
48 /** | |
49 * Return the best parameter element information available for the expression | |
50 * [node]. If type propagation was able to find a better parameter element | |
51 * than static analysis, that type will be returned. Otherwise, the result of | |
52 * static analysis will be returned. | |
53 */ | |
54 @override | |
55 ParameterElement bestParameterElementForExpression(Expression node) => | |
56 node.bestParameterElement; | |
57 | |
58 /** | |
59 * Return the best type information available for the expression [node]. If | |
60 * type propagation was able to find a better type than static analysis, that | |
61 * type will be returned. Otherwise, the result of static analysis will be | |
62 * returned. If no type analysis has been performed, then the type 'dynamic' | |
63 * will be returned. | |
64 */ | |
65 @override | |
66 DartType bestTypeForExpression(Expression node) => node.bestType; | |
67 | |
68 /** | |
69 * Return the element annotation representing the annotation [node] in the | |
70 * element model. | |
71 */ | |
72 @override | |
73 ElementAnnotation elementAnnotationForAnnotation(Annotation node) => | |
74 node.elementAnnotation; | |
75 | |
76 /** | |
77 * Return the element associated with the declaration [node], or `null` if | |
78 * either this node corresponds to a list of declarations or if the AST | |
79 * structure has not been resolved. | |
80 */ | |
81 @override | |
82 ClassElement elementDeclaredByClassDeclaration(ClassDeclaration node) => | |
83 node.element; | |
84 | |
85 /** | |
86 * Return the element associated with the declaration [node], or `null` if | |
87 * either this node corresponds to a list of declarations or if the AST | |
88 * structure has not been resolved. | |
89 */ | |
90 @override | |
91 ConstructorElement elementDeclaredByConstructorDeclaration( | |
92 ConstructorDeclaration node) => | |
93 node.element; | |
94 | |
95 /** | |
96 * Return the element associated with the declaration [node], or `null` if | |
97 * either this node corresponds to a list of declarations or if the AST | |
98 * structure has not been resolved. | |
99 */ | |
100 @override | |
101 Element elementDeclaredByDeclaration(Declaration node) => node.element; | |
102 | |
103 /** | |
104 * Return the element associated with the declaration [node], or `null` if | |
105 * either this node corresponds to a list of declarations or if the AST | |
106 * structure has not been resolved. | |
107 */ | |
108 @override | |
109 LocalVariableElement elementDeclaredByDeclaredIdentifier( | |
110 DeclaredIdentifier node) => | |
111 node.element; | |
112 | |
113 /** | |
114 * Return the element associated with the directive [node], or `null` if the | |
115 * AST structure has not been resolved or if this directive could not be | |
116 * resolved. | |
117 */ | |
118 @override | |
119 Element elementDeclaredByDirective(Directive node) => node.element; | |
120 | |
121 /** | |
122 * Return the element associated with the declaration [node], or `null` if | |
123 * either this node corresponds to a list of declarations or if the AST | |
124 * structure has not been resolved. | |
125 */ | |
126 @override | |
127 ClassElement elementDeclaredByEnumDeclaration(EnumDeclaration node) => | |
128 node.element; | |
129 | |
130 /** | |
131 * Return the element representing the parameter [node], or `null` if this | |
132 * parameter has not been resolved. | |
133 */ | |
134 @override | |
135 ParameterElement elementDeclaredByFormalParameter(FormalParameter node) => | |
136 node.element; | |
137 | |
138 /** | |
139 * Return the element associated with the declaration [node], or `null` if | |
140 * either this node corresponds to a list of declarations or if the AST | |
141 * structure has not been resolved. | |
142 */ | |
143 @override | |
144 ExecutableElement elementDeclaredByFunctionDeclaration( | |
145 FunctionDeclaration node) => | |
146 node.element; | |
147 | |
148 /** | |
149 * Return the element associated with the function expression [node], or | |
150 * `null` if the AST structure has not been resolved. | |
151 */ | |
152 @override | |
153 ExecutableElement elementDeclaredByFunctionExpression( | |
154 FunctionExpression node) => | |
155 node.element; | |
156 | |
157 /** | |
158 * Return the element associated with the declaration [node], or `null` if | |
159 * either this node corresponds to a list of declarations or if the AST | |
160 * structure has not been resolved. | |
161 */ | |
162 @override | |
163 ExecutableElement elementDeclaredByMethodDeclaration( | |
164 MethodDeclaration node) => | |
165 node.element; | |
166 | |
167 /** | |
168 * Return the element associated with the declaration [node], or `null` if | |
169 * either this node corresponds to a list of declarations or if the AST | |
170 * structure has not been resolved. | |
171 */ | |
172 @override | |
173 VariableElement elementDeclaredByVariableDeclaration( | |
174 VariableDeclaration node) => | |
175 node.element; | |
176 | |
177 /** | |
178 * Return the element associated with the annotation [node], or `null` if the | |
179 * AST structure has not been resolved or if this annotation could not be | |
180 * resolved. | |
181 */ | |
182 @override | |
183 Element elementForAnnotation(Annotation node) => node.element; | |
184 | |
185 /** | |
186 * Return the element associated with the compilation unit [node], or `null` | |
187 * if the AST structure has not been resolved. | |
188 */ | |
189 @override | |
190 CompilationUnitElement elementForCompilationUnit(CompilationUnit node) => | |
191 node.element; | |
192 | |
193 /** | |
194 * Return the element representing the parameter being named by the | |
195 * expression [node], or `null` if the AST structure has not been resolved or | |
196 * if there is no parameter with the same name as this expression. | |
197 */ | |
198 @override | |
199 ParameterElement elementForNamedExpression(NamedExpression node) => | |
200 node.element; | |
201 | |
202 /** | |
203 * Return a list containing the elements representing the parameters in the | |
204 * list [node]. The list will contain `null`s if the parameters in this list | |
205 * have not been resolved. | |
206 */ | |
207 @override | |
208 List<ParameterElement> parameterElementsForFormalParameterList( | |
209 FormalParameterList node) => | |
210 node.parameterElements; | |
211 | |
212 /** | |
213 * Return the element associated with the function being invoked at [node] | |
214 * based on propagated type information, or `null` if the AST structure has | |
215 * not been resolved or the function could not be resolved. | |
216 */ | |
217 @override | |
218 ExecutableElement propagatedElementForFunctionExpressionInvocation( | |
219 FunctionExpressionInvocation node) => | |
220 node.propagatedElement; | |
221 | |
222 /** | |
223 * Return the element associated with the identifier [node] based on | |
224 * propagated type information, or `null` if the AST structure has not been | |
225 * resolved or if this identifier could not be resolved. One example of the | |
226 * latter case is an identifier that is not defined within the scope in which | |
227 * it appears. | |
228 */ | |
229 @override | |
230 Element propagatedElementForIdentifier(Identifier node) => | |
231 node.propagatedElement; | |
232 | |
233 /** | |
234 * Return the element associated with the expression [node] based on | |
235 * propagated types, or `null` if the AST structure has not been resolved, or | |
236 * there is no meaningful propagated element to return (e.g. because this is a | |
237 * non-compound assignment expression, or because the method referred to could | |
238 * not be resolved). | |
239 */ | |
240 @override | |
241 MethodElement propagatedElementForMethodReference( | |
242 MethodReferenceExpression node) => | |
243 node.propagatedElement; | |
244 | |
245 /** | |
246 * If the expression [node] is an argument to an invocation, and the AST | |
247 * structure has been resolved, and the function being invoked is known based | |
248 * on propagated type information, and [node] corresponds to one of the | |
249 * parameters of the function being invoked, then return the parameter element | |
250 * representing the parameter to which the value of [node] will be | |
251 * bound. Otherwise, return `null`. | |
252 */ | |
253 @override | |
254 ParameterElement propagatedParameterElementForExpression(Expression node) => | |
255 node.propagatedParameterElement; | |
256 | |
257 /** | |
258 * Return the propagated type of the expression [node], or `null` if type | |
259 * propagation has not been performed on the AST structure. | |
260 */ | |
261 @override | |
262 DartType propagatedTypeForExpression(Expression node) => node.propagatedType; | |
263 | |
264 /** | |
265 * Return the element associated with the constructor referenced by [node] | |
266 * based on static type information, or `null` if the AST structure has not | |
267 * been resolved or if the constructor could not be resolved. | |
268 */ | |
269 @override | |
270 ConstructorElement staticElementForConstructorReference( | |
271 ConstructorReferenceNode node) => | |
272 node.staticElement; | |
273 | |
274 /** | |
275 * Return the element associated with the function being invoked at [node] | |
276 * based on static type information, or `null` if the AST structure has not | |
277 * been resolved or the function could not be resolved. | |
278 */ | |
279 @override | |
280 ExecutableElement staticElementForFunctionExpressionInvocation( | |
281 FunctionExpressionInvocation node) => | |
282 node.staticElement; | |
283 | |
284 /** | |
285 * Return the element associated with the identifier [node] based on static | |
286 * type information, or `null` if the AST structure has not been resolved or | |
287 * if this identifier could not be resolved. One example of the latter case is | |
288 * an identifier that is not defined within the scope in which it appears | |
289 */ | |
290 @override | |
291 Element staticElementForIdentifier(Identifier node) => node.staticElement; | |
292 | |
293 /** | |
294 * Return the element associated with the expression [node] based on the | |
295 * static types, or `null` if the AST structure has not been resolved, or | |
296 * there is no meaningful static element to return (e.g. because this is a | |
297 * non-compound assignment expression, or because the method referred to could | |
298 * not be resolved). | |
299 */ | |
300 @override | |
301 MethodElement staticElementForMethodReference( | |
302 MethodReferenceExpression node) => | |
303 node.staticElement; | |
304 | |
305 /** | |
306 * Return the function type of the invocation [node] based on the static type | |
307 * information, or `null` if the AST structure has not been resolved, or if | |
308 * the invoke could not be resolved. | |
309 * | |
310 * This will usually be a [FunctionType], but it can also be an | |
311 * [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy` | |
312 * interface type that implements `Function`. | |
313 */ | |
314 @override | |
315 DartType staticInvokeTypeForInvocationExpression(InvocationExpression node) => | |
316 node.staticInvokeType; | |
317 | |
318 /** | |
319 * If the expression [node] is an argument to an invocation, and the AST | |
320 * structure has been resolved, and the function being invoked is known based | |
321 * on static type information, and [node] corresponds to one of the parameters | |
322 * of the function being invoked, then return the parameter element | |
323 * representing the parameter to which the value of [node] will be | |
324 * bound. Otherwise, return `null`. | |
325 */ | |
326 @override | |
327 ParameterElement staticParameterElementForExpression(Expression node) => | |
328 node.staticParameterElement; | |
329 | |
330 /** | |
331 * Return the static type of the expression [node], or `null` if the AST | |
332 * structure has not been resolved. | |
333 */ | |
334 @override | |
335 DartType staticTypeForExpression(Expression node) => node.staticType; | |
336 | |
337 /** | |
338 * Return the type being named by [node], or `null` if the AST structure has | |
339 * not been resolved. | |
340 */ | |
341 @override | |
342 DartType typeForTypeName(TypeName node) => node.type; | |
343 | |
344 /** | |
345 * Return the element associated with the uri of the directive [node], or | |
346 * `null` if the AST structure has not been resolved or if the URI could not | |
347 * be resolved. Examples of the latter case include a directive that contains | |
348 * an invalid URL or a URL that does not exist. | |
349 */ | |
350 @override | |
351 Element uriElementForDirective(UriBasedDirective node) => node.uriElement; | |
352 } | |
OLD | NEW |