Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: pkg/analyzer/lib/dart/ast/resolution_accessors.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/element/element.dart';
7 import 'package:analyzer/dart/element/type.dart';
8
9 /**
10 * Return the best element available for the function being invoked at [node].
11 * If resolution was able to find a better element based on type propagation,
12 * that element will be returned. Otherwise, the element found using the
13 * result of static analysis will be returned. If resolution has not been
14 * performed, then `null` will be returned.
15 */
16 ExecutableElement bestElementForFunctionExpressionInvocation(
Brian Wilkerson 2016/12/05 18:22:11 I am concerned about the use of top-level function
Paul Berry 2016/12/07 18:06:16 Fair enough. I reworked to use a similar model to
17 FunctionExpressionInvocation node) =>
18 node.bestElement;
19
20 /**
21 * Return the best element available for the identifier [node]. If resolution
22 * was able to find a better element based on type propagation, that element
23 * will be returned. Otherwise, the element found using the result of static
24 * analysis will be returned. If resolution has not been performed, then `null`
25 * will be returned.
26 */
27 Element bestElementForIdentifier(Identifier node) => node.bestElement;
28
29 /**
30 * Return the best element available for the expression [node]. If resolution
31 * was able to find a better element based on type propagation, that element
32 * will be returned. Otherwise, the element found using the result of static
33 * analysis will be returned. If resolution has not been performed, then
34 * `null` will be returned.
35 */
36 MethodElement bestElementForMethodReference(MethodReferenceExpression node) =>
37 node.bestElement;
38
39 /**
40 * Return the best parameter element information available for the expression
41 * [node]. If type propagation was able to find a better parameter element
42 * than static analysis, that type will be returned. Otherwise, the result of
43 * static analysis will be returned.
44 */
45 ParameterElement bestParameterElementForExpression(Expression node) =>
46 node.bestParameterElement;
47
48 /**
49 * Return the best type information available for the expression [node]. If type
50 * propagation was able to find a better type than static analysis, that type
51 * will be returned. Otherwise, the result of static analysis will be
52 * returned. If no type analysis has been performed, then the type 'dynamic'
53 * will be returned.
54 */
55 DartType bestTypeForExpression(Expression node) => node.bestType;
56
57 /**
58 * Return the element annotation representing the annotation [node] in the
59 * element model.
60 */
61 ElementAnnotation elementAnnotationForAnnotation(Annotation node) =>
62 node.elementAnnotation;
63
64 /**
65 * Return the element associated with the annotation [node], or `null` if the
66 * AST structure has not been resolved or if this annotation could not be
67 * resolved.
68 */
69 Element elementForAnnotation(Annotation node) => node.element;
70
71 /**
72 * Return the element associated with the declaration [node], or `null` if
73 * either this node corresponds to a list of declarations or if the AST
74 * structure has not been resolved.
75 */
76 ClassElement elementForClassDeclaration(ClassDeclaration node) => node.element;
Brian Wilkerson 2016/12/05 18:22:11 Consider renaming functions like this to something
Paul Berry 2016/12/07 18:06:16 Done.
77
78 /**
79 * Return the element associated with the compilation unit [node], or `null` if
80 * the AST structure has not been resolved.
81 */
82 CompilationUnitElement elementForCompilationUnit(CompilationUnit 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 ConstructorElement elementForConstructorDeclaration(
91 ConstructorDeclaration node) =>
92 node.element;
93
94 /**
95 * Return the element associated with the declaration [node], or `null` if
96 * either this node corresponds to a list of declarations or if the AST
97 * structure has not been resolved.
98 */
99 Element elementForDeclaration(Declaration node) => node.element;
100
101 /**
102 * Return the element associated with the declaration [node], or `null` if
103 * either this node corresponds to a list of declarations or if the AST
104 * structure has not been resolved.
105 */
106 LocalVariableElement elementForDeclaredIdentifier(DeclaredIdentifier node) =>
107 node.element;
108
109 /**
110 * Return the element associated with the directive [node], or `null` if the AST
111 * structure has not been resolved or if this directive could not be resolved.
112 */
113 Element elementForDirective(Directive node) => node.element;
114
115 /**
116 * Return the element associated with the declaration [node], or `null` if
117 * either this node corresponds to a list of declarations or if the AST
118 * structure has not been resolved.
119 */
120 ClassElement elementForEnumDeclaration(EnumDeclaration node) => node.element;
121
122 /**
123 * Return the element representing the parameter [node], or `null` if this
124 * parameter has not been resolved.
125 */
126 ParameterElement elementForFormalParameter(FormalParameter node) =>
127 node.element;
128
129 /**
130 * Return the element associated with the declaration [node], or `null` if
131 * either this node corresponds to a list of declarations or if the AST
132 * structure has not been resolved.
133 */
134 ExecutableElement elementForFunctionDeclaration(FunctionDeclaration node) =>
135 node.element;
136
137 /**
138 * Return the element associated with the function expression [node], or `null`
139 * if the AST structure has not been resolved.
140 */
141 ExecutableElement elementForFunctionExpression(FunctionExpression node) =>
142 node.element;
143
144 /**
145 * Return the element associated with the declaration [node], or `null` if
146 * either this node corresponds to a list of declarations or if the AST
147 * structure has not been resolved.
148 */
149 ExecutableElement elementForMethodDeclaration(MethodDeclaration node) =>
150 node.element;
151
152 /**
153 * Return the element representing the parameter being named by the
154 * expression [node], or `null` if the AST structure has not been resolved or if
155 * there is no parameter with the same name as this expression.
156 */
157 ParameterElement elementForNamedExpression(NamedExpression node) =>
158 node.element;
159
160 /**
161 * Return the element associated with the declaration [node], or `null` if
162 * either this node corresponds to a list of declarations or if the AST
163 * structure has not been resolved.
164 */
165 VariableElement elementForVariableDeclaration(VariableDeclaration node) =>
166 node.element;
167
168 /**
169 * Return a list containing the elements representing the parameters in the
170 * list [node]. The list will contain `null`s if the parameters in this list
171 * have not been resolved.
172 */
173 List<ParameterElement> parameterElementsForFormalParameterList(
174 FormalParameterList node) =>
175 node.parameterElements;
176
177 /**
178 * Return the element associated with the function being invoked at [node] based
179 * on propagated type information, or `null` if the AST structure has not been
180 * resolved or the function could not be resolved.
181 */
182 ExecutableElement propagatedElementForFunctionExpressionInvocation(
183 FunctionExpressionInvocation node) =>
184 node.propagatedElement;
185
186 /**
187 * Return the element associated with the identifier [node] based on propagated
188 * type information, or `null` if the AST structure has not been resolved or if
189 * this identifier could not be resolved. One example of the latter case is an
190 * identifier that is not defined within the scope in which it appears.
191 */
192 Element propagatedElementForIdentifier(Identifier node) =>
193 node.propagatedElement;
194
195 /**
196 * Return the element associated with the expression [node] based on propagated
197 * types, or `null` if the AST structure has not been resolved, or there is
198 * no meaningful propagated element to return (e.g. because this is a
199 * non-compound assignment expression, or because the method referred to could
200 * not be resolved).
201 */
202 MethodElement propagatedElementForMethodReference(
203 MethodReferenceExpression node) =>
204 node.propagatedElement;
205
206 /**
207 * If the expression [node] is an argument to an invocation, and the AST
208 * structure has been resolved, and the function being invoked is known based on
209 * propagated type information, and [node] corresponds to one of the
210 * parameters of the function being invoked, then return the parameter element
211 * representing the parameter to which the value of [node] will be
212 * bound. Otherwise, return `null`.
213 */
214 ParameterElement propagatedParameterElementForExpression(Expression node) =>
215 node.propagatedParameterElement;
216
217 /**
218 * Return the propagated type of the expression [node], or `null` if type
219 * propagation has not been performed on the AST structure.
220 */
221 DartType propagatedTypeForExpression(Expression node) => node.propagatedType;
222
223 /**
224 * Return the element associated with the constructor referenced by [node] based
225 * on static type information, or `null` if the AST structure has not been
226 * resolved or if the constructor could not be resolved.
227 */
228 ConstructorElement staticElementForConstructorReference(
229 ConstructorReferenceNode node) =>
230 node.staticElement;
231
232 /**
233 * Return the element associated with the function being invoked at [node] based
234 * on static type information, or `null` if the AST structure has not been
235 * resolved or the function could not be resolved.
236 */
237 ExecutableElement staticElementForFunctionExpressionInvocation(
238 FunctionExpressionInvocation node) =>
239 node.staticElement;
240
241 /**
242 * Return the element associated with the identifier [node] based on static type
243 * information, or `null` if the AST structure has not been resolved or if
244 * this identifier could not be resolved. One example of the latter case is an
245 * identifier that is not defined within the scope in which it appears
246 */
247 Element staticElementForIdentifier(Identifier node) => node.staticElement;
248
249 /**
250 * Return the element associated with the expression [node] based on the static
251 * types, or `null` if the AST structure has not been resolved, or there is no
252 * meaningful static element to return (e.g. because this is a non-compound
253 * assignment expression, or because the method referred to could not be
254 * resolved).
255 */
256 MethodElement staticElementForMethodReference(MethodReferenceExpression node) =>
257 node.staticElement;
258
259 /**
260 * Return the function type of the invocation [node] based on the static type
261 * information, or `null` if the AST structure has not been resolved, or if
262 * the invoke could not be resolved.
263 *
264 * This will usually be a [FunctionType], but it can also be an
265 * [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy`
266 * interface type that implements `Function`.
267 */
268 DartType staticInvokeTypeForInvocationExpression(InvocationExpression node) =>
269 node.staticInvokeType;
270
271 /**
272 * If the expression [node] is an argument to an invocation, and the AST
273 * structure has been resolved, and the function being invoked is known based on
274 * static type information, and [node] corresponds to one of the parameters
275 * of the function being invoked, then return the parameter element
276 * representing the parameter to which the value of [node] will be
277 * bound. Otherwise, return `null`.
278 */
279 ParameterElement staticParameterElementForExpression(Expression node) =>
280 node.staticParameterElement;
281
282 /**
283 * Return the static type of the expression [node], or `null` if the AST
284 * structure has not been resolved.
285 */
286 DartType staticTypeForExpression(Expression node) => node.staticType;
287
288 /**
289 * Return the type being named by [node], or `null` if the AST structure has not
290 * been resolved.
291 */
292 DartType typeForTypeName(TypeName node) => node.type;
293
294 /**
295 * Return the element associated with the uri of the directive [node], or `null`
296 * if the AST structure has not been resolved or if the URI could not be
297 * resolved. Examples of the latter case include a directive that contains an
298 * invalid URL or a URL that does not exist.
299 */
300 Element uriElementForDirective(UriBasedDirective node) => node.uriElement;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698