Index: pkg/analyzer/lib/src/dart/ast/resolution_map.dart |
diff --git a/pkg/analyzer/lib/src/dart/ast/resolution_map.dart b/pkg/analyzer/lib/src/dart/ast/resolution_map.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..af5bb31c946ece21e9196b4523af1a07f816d34a |
--- /dev/null |
+++ b/pkg/analyzer/lib/src/dart/ast/resolution_map.dart |
@@ -0,0 +1,352 @@ |
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'package:analyzer/dart/ast/ast.dart'; |
+import 'package:analyzer/dart/ast/resolution_map.dart'; |
+import 'package:analyzer/dart/element/element.dart'; |
+import 'package:analyzer/dart/element/type.dart'; |
+ |
+/** |
+ * Concrete implementation of [ResolutionMap] based on the standard AST |
+ * implementation. |
+ */ |
+class ResolutionMapImpl implements ResolutionMap { |
+ /** |
+ * Return the best element available for the function being invoked at [node]. |
+ * If resolution was able to find a better element based on type propagation, |
+ * that element will be returned. Otherwise, the element found using the |
+ * result of static analysis will be returned. If resolution has not been |
+ * performed, then `null` will be returned. |
+ */ |
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.
|
+ @override |
+ ExecutableElement bestElementForFunctionExpressionInvocation( |
+ FunctionExpressionInvocation node) => |
+ node.bestElement; |
+ |
+ /** |
+ * Return the best element available for the identifier [node]. If resolution |
+ * was able to find a better element based on type propagation, that element |
+ * will be returned. Otherwise, the element found using the result of static |
+ * analysis will be returned. If resolution has not been performed, then |
+ * `null` will be returned. |
+ */ |
+ @override |
+ Element bestElementForIdentifier(Identifier node) => node.bestElement; |
+ |
+ /** |
+ * Return the best element available for the expression [node]. If resolution |
+ * was able to find a better element based on type propagation, that element |
+ * will be returned. Otherwise, the element found using the result of static |
+ * analysis will be returned. If resolution has not been performed, then |
+ * `null` will be returned. |
+ */ |
+ @override |
+ MethodElement bestElementForMethodReference(MethodReferenceExpression node) => |
+ node.bestElement; |
+ |
+ /** |
+ * Return the best parameter element information available for the expression |
+ * [node]. If type propagation was able to find a better parameter element |
+ * than static analysis, that type will be returned. Otherwise, the result of |
+ * static analysis will be returned. |
+ */ |
+ @override |
+ ParameterElement bestParameterElementForExpression(Expression node) => |
+ node.bestParameterElement; |
+ |
+ /** |
+ * Return the best type information available for the expression [node]. If |
+ * type propagation was able to find a better type than static analysis, that |
+ * type will be returned. Otherwise, the result of static analysis will be |
+ * returned. If no type analysis has been performed, then the type 'dynamic' |
+ * will be returned. |
+ */ |
+ @override |
+ DartType bestTypeForExpression(Expression node) => node.bestType; |
+ |
+ /** |
+ * Return the element annotation representing the annotation [node] in the |
+ * element model. |
+ */ |
+ @override |
+ ElementAnnotation elementAnnotationForAnnotation(Annotation node) => |
+ node.elementAnnotation; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ ClassElement elementDeclaredByClassDeclaration(ClassDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ ConstructorElement elementDeclaredByConstructorDeclaration( |
+ ConstructorDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ Element elementDeclaredByDeclaration(Declaration node) => node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ LocalVariableElement elementDeclaredByDeclaredIdentifier( |
+ DeclaredIdentifier node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the directive [node], or `null` if the |
+ * AST structure has not been resolved or if this directive could not be |
+ * resolved. |
+ */ |
+ @override |
+ Element elementDeclaredByDirective(Directive node) => node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ ClassElement elementDeclaredByEnumDeclaration(EnumDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element representing the parameter [node], or `null` if this |
+ * parameter has not been resolved. |
+ */ |
+ @override |
+ ParameterElement elementDeclaredByFormalParameter(FormalParameter node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ ExecutableElement elementDeclaredByFunctionDeclaration( |
+ FunctionDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the function expression [node], or |
+ * `null` if the AST structure has not been resolved. |
+ */ |
+ @override |
+ ExecutableElement elementDeclaredByFunctionExpression( |
+ FunctionExpression node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ ExecutableElement elementDeclaredByMethodDeclaration( |
+ MethodDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the declaration [node], or `null` if |
+ * either this node corresponds to a list of declarations or if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ VariableElement elementDeclaredByVariableDeclaration( |
+ VariableDeclaration node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element associated with the annotation [node], or `null` if the |
+ * AST structure has not been resolved or if this annotation could not be |
+ * resolved. |
+ */ |
+ @override |
+ Element elementForAnnotation(Annotation node) => node.element; |
+ |
+ /** |
+ * Return the element associated with the compilation unit [node], or `null` |
+ * if the AST structure has not been resolved. |
+ */ |
+ @override |
+ CompilationUnitElement elementForCompilationUnit(CompilationUnit node) => |
+ node.element; |
+ |
+ /** |
+ * Return the element representing the parameter being named by the |
+ * expression [node], or `null` if the AST structure has not been resolved or |
+ * if there is no parameter with the same name as this expression. |
+ */ |
+ @override |
+ ParameterElement elementForNamedExpression(NamedExpression node) => |
+ node.element; |
+ |
+ /** |
+ * Return a list containing the elements representing the parameters in the |
+ * list [node]. The list will contain `null`s if the parameters in this list |
+ * have not been resolved. |
+ */ |
+ @override |
+ List<ParameterElement> parameterElementsForFormalParameterList( |
+ FormalParameterList node) => |
+ node.parameterElements; |
+ |
+ /** |
+ * Return the element associated with the function being invoked at [node] |
+ * based on propagated type information, or `null` if the AST structure has |
+ * not been resolved or the function could not be resolved. |
+ */ |
+ @override |
+ ExecutableElement propagatedElementForFunctionExpressionInvocation( |
+ FunctionExpressionInvocation node) => |
+ node.propagatedElement; |
+ |
+ /** |
+ * Return the element associated with the identifier [node] based on |
+ * propagated type information, or `null` if the AST structure has not been |
+ * resolved or if this identifier could not be resolved. One example of the |
+ * latter case is an identifier that is not defined within the scope in which |
+ * it appears. |
+ */ |
+ @override |
+ Element propagatedElementForIdentifier(Identifier node) => |
+ node.propagatedElement; |
+ |
+ /** |
+ * Return the element associated with the expression [node] based on |
+ * propagated types, or `null` if the AST structure has not been resolved, or |
+ * there is no meaningful propagated element to return (e.g. because this is a |
+ * non-compound assignment expression, or because the method referred to could |
+ * not be resolved). |
+ */ |
+ @override |
+ MethodElement propagatedElementForMethodReference( |
+ MethodReferenceExpression node) => |
+ node.propagatedElement; |
+ |
+ /** |
+ * If the expression [node] is an argument to an invocation, and the AST |
+ * structure has been resolved, and the function being invoked is known based |
+ * on propagated type information, and [node] corresponds to one of the |
+ * parameters of the function being invoked, then return the parameter element |
+ * representing the parameter to which the value of [node] will be |
+ * bound. Otherwise, return `null`. |
+ */ |
+ @override |
+ ParameterElement propagatedParameterElementForExpression(Expression node) => |
+ node.propagatedParameterElement; |
+ |
+ /** |
+ * Return the propagated type of the expression [node], or `null` if type |
+ * propagation has not been performed on the AST structure. |
+ */ |
+ @override |
+ DartType propagatedTypeForExpression(Expression node) => node.propagatedType; |
+ |
+ /** |
+ * Return the element associated with the constructor referenced by [node] |
+ * based on static type information, or `null` if the AST structure has not |
+ * been resolved or if the constructor could not be resolved. |
+ */ |
+ @override |
+ ConstructorElement staticElementForConstructorReference( |
+ ConstructorReferenceNode node) => |
+ node.staticElement; |
+ |
+ /** |
+ * Return the element associated with the function being invoked at [node] |
+ * based on static type information, or `null` if the AST structure has not |
+ * been resolved or the function could not be resolved. |
+ */ |
+ @override |
+ ExecutableElement staticElementForFunctionExpressionInvocation( |
+ FunctionExpressionInvocation node) => |
+ node.staticElement; |
+ |
+ /** |
+ * Return the element associated with the identifier [node] based on static |
+ * type information, or `null` if the AST structure has not been resolved or |
+ * if this identifier could not be resolved. One example of the latter case is |
+ * an identifier that is not defined within the scope in which it appears |
+ */ |
+ @override |
+ Element staticElementForIdentifier(Identifier node) => node.staticElement; |
+ |
+ /** |
+ * Return the element associated with the expression [node] based on the |
+ * static types, or `null` if the AST structure has not been resolved, or |
+ * there is no meaningful static element to return (e.g. because this is a |
+ * non-compound assignment expression, or because the method referred to could |
+ * not be resolved). |
+ */ |
+ @override |
+ MethodElement staticElementForMethodReference( |
+ MethodReferenceExpression node) => |
+ node.staticElement; |
+ |
+ /** |
+ * Return the function type of the invocation [node] based on the static type |
+ * information, or `null` if the AST structure has not been resolved, or if |
+ * the invoke could not be resolved. |
+ * |
+ * This will usually be a [FunctionType], but it can also be an |
+ * [InterfaceType] with a `call` method, `dynamic`, `Function`, or a `@proxy` |
+ * interface type that implements `Function`. |
+ */ |
+ @override |
+ DartType staticInvokeTypeForInvocationExpression(InvocationExpression node) => |
+ node.staticInvokeType; |
+ |
+ /** |
+ * If the expression [node] is an argument to an invocation, and the AST |
+ * structure has been resolved, and the function being invoked is known based |
+ * on static type information, and [node] corresponds to one of the parameters |
+ * of the function being invoked, then return the parameter element |
+ * representing the parameter to which the value of [node] will be |
+ * bound. Otherwise, return `null`. |
+ */ |
+ @override |
+ ParameterElement staticParameterElementForExpression(Expression node) => |
+ node.staticParameterElement; |
+ |
+ /** |
+ * Return the static type of the expression [node], or `null` if the AST |
+ * structure has not been resolved. |
+ */ |
+ @override |
+ DartType staticTypeForExpression(Expression node) => node.staticType; |
+ |
+ /** |
+ * Return the type being named by [node], or `null` if the AST structure has |
+ * not been resolved. |
+ */ |
+ @override |
+ DartType typeForTypeName(TypeName node) => node.type; |
+ |
+ /** |
+ * Return the element associated with the uri of the directive [node], or |
+ * `null` if the AST structure has not been resolved or if the URI could not |
+ * be resolved. Examples of the latter case include a directive that contains |
+ * an invalid URL or a URL that does not exist. |
+ */ |
+ @override |
+ Element uriElementForDirective(UriBasedDirective node) => node.uriElement; |
+} |