OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
6 import 'package:analyzer/dart/ast/visitor.dart'; | 6 import 'package:analyzer/dart/ast/visitor.dart'; |
7 import 'package:analyzer/dart/element/type.dart'; | 7 import 'package:analyzer/dart/element/type.dart'; |
8 | 8 |
9 /// Visitor that applies resolution data from the front end (obtained via | 9 /// Visitor that applies resolution data from the front end (obtained via |
10 /// [ResolutionStorer]) to an analyzer AST. | 10 /// [ResolutionStorer]) to an analyzer AST. |
(...skipping 27 matching lines...) Expand all Loading... |
38 @override | 38 @override |
39 void visitMethodInvocation(MethodInvocation node) { | 39 void visitMethodInvocation(MethodInvocation node) { |
40 node.target?.accept(this); | 40 node.target?.accept(this); |
41 // TODO(paulberry): store resolution of node.methodName. | 41 // TODO(paulberry): store resolution of node.methodName. |
42 // TODO(paulberry): store resolution of node.typeArguments. | 42 // TODO(paulberry): store resolution of node.typeArguments. |
43 node.argumentList.accept(this); | 43 node.argumentList.accept(this); |
44 node.staticType = _getTypeFor(node.methodName); | 44 node.staticType = _getTypeFor(node.methodName); |
45 } | 45 } |
46 | 46 |
47 @override | 47 @override |
| 48 void visitParenthesizedExpression(ParenthesizedExpression node) { |
| 49 node.visitChildren(this); |
| 50 node.staticType = node.expression.staticType; |
| 51 } |
| 52 |
| 53 @override |
48 void visitVariableDeclaration(VariableDeclaration node) { | 54 void visitVariableDeclaration(VariableDeclaration node) { |
49 if (node.parent is VariableDeclarationList && | 55 if (node.parent is VariableDeclarationList && |
50 node.parent.parent is TopLevelVariableDeclaration) { | 56 node.parent.parent is TopLevelVariableDeclaration) { |
51 // Don't visit the name; resolution for it will come from the outline. | 57 // Don't visit the name; resolution for it will come from the outline. |
52 } else { | 58 } else { |
53 node.name.accept(this); | 59 node.name.accept(this); |
54 } | 60 } |
55 node.initializer?.accept(this); | 61 node.initializer?.accept(this); |
56 } | 62 } |
57 | 63 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DartType _getTypeFor(AstNode node) { | 114 DartType _getTypeFor(AstNode node) { |
109 if (_debug) print('Getting type for $node'); | 115 if (_debug) print('Getting type for $node'); |
110 if (node.offset != _typeOffsets[_typeIndex]) { | 116 if (node.offset != _typeOffsets[_typeIndex]) { |
111 throw new StateError( | 117 throw new StateError( |
112 'Expected a type for analyzer offset ${node.offset}; got one for ' | 118 'Expected a type for analyzer offset ${node.offset}; got one for ' |
113 'kernel offset ${_typeOffsets[_typeIndex]}'); | 119 'kernel offset ${_typeOffsets[_typeIndex]}'); |
114 } | 120 } |
115 return super._getTypeFor(node); | 121 return super._getTypeFor(node); |
116 } | 122 } |
117 } | 123 } |
OLD | NEW |