| 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/element/element.dart'; |
| 7 import 'package:analyzer/dart/element/type.dart'; |
| 8 |
| 9 /** |
| 10 * A collection of methods which may be used to map from nodes in a resolved AST |
| 11 * to elements and types in the element model. |
| 12 * |
| 13 * Clients should not extend, implement or mix-in this class. |
| 14 */ |
| 15 abstract class ResolutionMap { |
| 16 /** |
| 17 * Return the best element available for the function being invoked at [node]. |
| 18 * If resolution was able to find a better element based on type propagation, |
| 19 * that element will be returned. Otherwise, the element found using the |
| 20 * result of static analysis will be returned. If resolution has not been |
| 21 * performed, then `null` will be returned. |
| 22 */ |
| 23 ExecutableElement bestElementForFunctionExpressionInvocation( |
| 24 FunctionExpressionInvocation node); |
| 25 |
| 26 /** |
| 27 * Return the best element available for the identifier [node]. If resolution |
| 28 * was able to find a better element based on type propagation, that element |
| 29 * will be returned. Otherwise, the element found using the result of static |
| 30 * analysis will be returned. If resolution has not been performed, then |
| 31 * `null` will be returned. |
| 32 */ |
| 33 Element bestElementForIdentifier(Identifier node); |
| 34 |
| 35 /** |
| 36 * Return the best element available for the expression [node]. If resolution |
| 37 * was able to find a better element based on type propagation, that element |
| 38 * will be returned. Otherwise, the element found using the result of static |
| 39 * analysis will be returned. If resolution has not been performed, then |
| 40 * `null` will be returned. |
| 41 */ |
| 42 MethodElement bestElementForMethodReference(MethodReferenceExpression node); |
| 43 |
| 44 /** |
| 45 * Return the best parameter element information available for the expression |
| 46 * [node]. If type propagation was able to find a better parameter element |
| 47 * than static analysis, that type will be returned. Otherwise, the result of |
| 48 * static analysis will be returned. |
| 49 */ |
| 50 ParameterElement bestParameterElementForExpression(Expression node); |
| 51 |
| 52 /** |
| 53 * Return the best type information available for the expression [node]. If |
| 54 * type propagation was able to find a better type than static analysis, that |
| 55 * type will be returned. Otherwise, the result of static analysis will be |
| 56 * returned. If no type analysis has been performed, then the type 'dynamic' |
| 57 * will be returned. |
| 58 */ |
| 59 DartType bestTypeForExpression(Expression node); |
| 60 |
| 61 /** |
| 62 * Return the element annotation representing the annotation [node] in the |
| 63 * element model. |
| 64 */ |
| 65 ElementAnnotation elementAnnotationForAnnotation(Annotation node); |
| 66 |
| 67 /** |
| 68 * Return the element associated with the declaration [node], or `null` if |
| 69 * either this node corresponds to a list of declarations or if the AST |
| 70 * structure has not been resolved. |
| 71 */ |
| 72 ClassElement elementDeclaredByClassDeclaration(ClassDeclaration node); |
| 73 |
| 74 /** |
| 75 * Return the element associated with the compilation unit [node], or `null` |
| 76 * if the AST structure has not been resolved. |
| 77 */ |
| 78 CompilationUnitElement elementDeclaredByCompilationUnit(CompilationUnit node); |
| 79 |
| 80 /** |
| 81 * Return the element associated with the declaration [node], or `null` if |
| 82 * either this node corresponds to a list of declarations or if the AST |
| 83 * structure has not been resolved. |
| 84 */ |
| 85 ConstructorElement elementDeclaredByConstructorDeclaration( |
| 86 ConstructorDeclaration node); |
| 87 |
| 88 /** |
| 89 * Return the element associated with the declaration [node], or `null` if |
| 90 * either this node corresponds to a list of declarations or if the AST |
| 91 * structure has not been resolved. |
| 92 */ |
| 93 Element elementDeclaredByDeclaration(Declaration node); |
| 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 LocalVariableElement elementDeclaredByDeclaredIdentifier( |
| 101 DeclaredIdentifier node); |
| 102 |
| 103 /** |
| 104 * Return the element associated with the directive [node], or `null` if the |
| 105 * AST structure has not been resolved or if this directive could not be |
| 106 * resolved. |
| 107 */ |
| 108 Element elementDeclaredByDirective(Directive node); |
| 109 |
| 110 /** |
| 111 * Return the element associated with the declaration [node], or `null` if |
| 112 * either this node corresponds to a list of declarations or if the AST |
| 113 * structure has not been resolved. |
| 114 */ |
| 115 ClassElement elementDeclaredByEnumDeclaration(EnumDeclaration node); |
| 116 |
| 117 /** |
| 118 * Return the element representing the parameter [node], or `null` if this |
| 119 * parameter has not been resolved. |
| 120 */ |
| 121 ParameterElement elementDeclaredByFormalParameter(FormalParameter node); |
| 122 |
| 123 /** |
| 124 * Return the element associated with the declaration [node], or `null` if |
| 125 * either this node corresponds to a list of declarations or if the AST |
| 126 * structure has not been resolved. |
| 127 */ |
| 128 ExecutableElement elementDeclaredByFunctionDeclaration( |
| 129 FunctionDeclaration node); |
| 130 |
| 131 /** |
| 132 * Return the element associated with the function expression [node], or |
| 133 * `null` if the AST structure has not been resolved. |
| 134 */ |
| 135 ExecutableElement elementDeclaredByFunctionExpression( |
| 136 FunctionExpression node); |
| 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 ExecutableElement elementDeclaredByMethodDeclaration(MethodDeclaration node); |
| 144 |
| 145 /** |
| 146 * Return the element associated with the declaration [node], or `null` if |
| 147 * either this node corresponds to a list of declarations or if the AST |
| 148 * structure has not been resolved. |
| 149 */ |
| 150 VariableElement elementDeclaredByVariableDeclaration( |
| 151 VariableDeclaration node); |
| 152 |
| 153 /** |
| 154 * Return the element associated with the annotation [node], or `null` if the |
| 155 * AST structure has not been resolved or if this annotation could not be |
| 156 * resolved. |
| 157 */ |
| 158 Element elementForAnnotation(Annotation node); |
| 159 |
| 160 /** |
| 161 * Return the element representing the parameter being named by the |
| 162 * expression [node], or `null` if the AST structure has not been resolved or |
| 163 * if there is no parameter with the same name as this expression. |
| 164 */ |
| 165 ParameterElement elementForNamedExpression(NamedExpression node); |
| 166 |
| 167 /** |
| 168 * Return a list containing the elements representing the parameters in the |
| 169 * list [node]. The list will contain `null`s if the parameters in this list |
| 170 * have not been resolved. |
| 171 */ |
| 172 List<ParameterElement> parameterElementsForFormalParameterList( |
| 173 FormalParameterList node); |
| 174 |
| 175 /** |
| 176 * Return the element associated with the function being invoked at [node] |
| 177 * based on propagated type information, or `null` if the AST structure has |
| 178 * not been resolved or the function could not be resolved. |
| 179 */ |
| 180 ExecutableElement propagatedElementForFunctionExpressionInvocation( |
| 181 FunctionExpressionInvocation node); |
| 182 |
| 183 /** |
| 184 * Return the element associated with the identifier [node] based on |
| 185 * propagated type information, or `null` if the AST structure has not been |
| 186 * resolved or if this identifier could not be resolved. One example of the |
| 187 * latter case is an identifier that is not defined within the scope in which |
| 188 * it appears. |
| 189 */ |
| 190 Element propagatedElementForIdentifier(Identifier node); |
| 191 |
| 192 /** |
| 193 * Return the element associated with the expression [node] based on |
| 194 * propagated types, or `null` if the AST structure has not been resolved, or |
| 195 * there is no meaningful propagated element to return (e.g. because this is a |
| 196 * non-compound assignment expression, or because the method referred to could |
| 197 * not be resolved). |
| 198 */ |
| 199 MethodElement propagatedElementForMethodReference( |
| 200 MethodReferenceExpression node); |
| 201 |
| 202 /** |
| 203 * If the expression [node] is an argument to an invocation, and the AST |
| 204 * structure has been resolved, and the function being invoked is known based |
| 205 * on propagated type information, and [node] corresponds to one of the |
| 206 * parameters of the function being invoked, then return the parameter element |
| 207 * representing the parameter to which the value of [node] will be |
| 208 * bound. Otherwise, return `null`. |
| 209 */ |
| 210 ParameterElement propagatedParameterElementForExpression(Expression node); |
| 211 |
| 212 /** |
| 213 * Return the propagated type of the expression [node], or `null` if type |
| 214 * propagation has not been performed on the AST structure. |
| 215 */ |
| 216 DartType propagatedTypeForExpression(Expression node); |
| 217 |
| 218 /** |
| 219 * Return the element associated with the constructor referenced by [node] |
| 220 * based on static type information, or `null` if the AST structure has not |
| 221 * been resolved or if the constructor could not be resolved. |
| 222 */ |
| 223 ConstructorElement staticElementForConstructorReference( |
| 224 ConstructorReferenceNode node); |
| 225 |
| 226 /** |
| 227 * Return the element associated with the function being invoked at [node] |
| 228 * based on static type information, or `null` if the AST structure has not |
| 229 * been resolved or the function could not be resolved. |
| 230 */ |
| 231 ExecutableElement staticElementForFunctionExpressionInvocation( |
| 232 FunctionExpressionInvocation node); |
| 233 |
| 234 /** |
| 235 * Return the element associated with the identifier [node] based on static |
| 236 * type information, or `null` if the AST structure has not been resolved or |
| 237 * if this identifier could not be resolved. One example of the latter case is |
| 238 * an identifier that is not defined within the scope in which it appears |
| 239 */ |
| 240 Element staticElementForIdentifier(Identifier node); |
| 241 |
| 242 /** |
| 243 * Return the element associated with the expression [node] based on the |
| 244 * static types, or `null` if the AST structure has not been resolved, or |
| 245 * there is no meaningful static element to return (e.g. because this is a |
| 246 * non-compound assignment expression, or because the method referred to could |
| 247 * not be resolved). |
| 248 */ |
| 249 MethodElement staticElementForMethodReference(MethodReferenceExpression node); |
| 250 |
| 251 /** |
| 252 * Return the function type of the invocation [node] based on the static type |
| 253 * information, or `null` if the AST structure has not been resolved, or if |
| 254 * the invoke could not be resolved. |
| 255 * |
| 256 * This will usually be a [FunctionType], but it can also be an |
| 257 * [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy` |
| 258 * interface type that implements `Function`. |
| 259 */ |
| 260 DartType staticInvokeTypeForInvocationExpression(InvocationExpression node); |
| 261 |
| 262 /** |
| 263 * If the expression [node] is an argument to an invocation, and the AST |
| 264 * structure has been resolved, and the function being invoked is known based |
| 265 * on static type information, and [node] corresponds to one of the parameters |
| 266 * of the function being invoked, then return the parameter element |
| 267 * representing the parameter to which the value of [node] will be |
| 268 * bound. Otherwise, return `null`. |
| 269 */ |
| 270 ParameterElement staticParameterElementForExpression(Expression node); |
| 271 |
| 272 /** |
| 273 * Return the static type of the expression [node], or `null` if the AST |
| 274 * structure has not been resolved. |
| 275 */ |
| 276 DartType staticTypeForExpression(Expression node); |
| 277 |
| 278 /** |
| 279 * Return the type being named by [node], or `null` if the AST structure has |
| 280 * not been resolved. |
| 281 */ |
| 282 DartType typeForTypeName(TypeName node); |
| 283 |
| 284 /** |
| 285 * Return the element associated with the uri of the directive [node], or |
| 286 * `null` if the AST structure has not been resolved or if the URI could not |
| 287 * be resolved. Examples of the latter case include a directive that contains |
| 288 * an invalid URL or a URL that does not exist. |
| 289 */ |
| 290 Element uriElementForDirective(UriBasedDirective node); |
| 291 } |
| OLD | NEW |