| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer2dart.semantic_visitor; | 5 library analyzer2dart.semantic_visitor; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 | 9 |
| 10 import 'util.dart'; | 10 import 'util.dart'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 @override | 74 @override |
| 75 R visitMethodInvocation(MethodInvocation node) { | 75 R visitMethodInvocation(MethodInvocation node) { |
| 76 if (node.target != null) { | 76 if (node.target != null) { |
| 77 node.target.accept(this); | 77 node.target.accept(this); |
| 78 } | 78 } |
| 79 node.argumentList.accept(this); | 79 node.argumentList.accept(this); |
| 80 return handleMethodInvocation(node); | 80 return handleMethodInvocation(node); |
| 81 } | 81 } |
| 82 | 82 |
| 83 R handleMethodInvocation(MethodInvocation node) { | 83 R handleMethodInvocation(MethodInvocation node) { |
| 84 AccessSemantics semantics = classifyMethodInvocation(node); | 84 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); |
| 85 switch (semantics.kind) { | 85 switch (semantics.kind) { |
| 86 case AccessKind.DYNAMIC: | 86 case AccessKind.DYNAMIC: |
| 87 return visitDynamicInvocation(node, semantics); | 87 return visitDynamicInvocation(node, semantics); |
| 88 case AccessKind.LOCAL_FUNCTION: | 88 case AccessKind.LOCAL_FUNCTION: |
| 89 return visitLocalFunctionInvocation(node, semantics); | 89 return visitLocalFunctionInvocation(node, semantics); |
| 90 case AccessKind.LOCAL_VARIABLE: | 90 case AccessKind.LOCAL_VARIABLE: |
| 91 return visitLocalVariableInvocation(node, semantics); | 91 return visitLocalVariableInvocation(node, semantics); |
| 92 case AccessKind.PARAMETER: | 92 case AccessKind.PARAMETER: |
| 93 return visitParameterInvocation(node, semantics); | 93 return visitParameterInvocation(node, semantics); |
| 94 case AccessKind.STATIC_FIELD: | 94 case AccessKind.STATIC_FIELD: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 @override | 107 @override |
| 108 R visitPropertyAccess(PropertyAccess node) { | 108 R visitPropertyAccess(PropertyAccess node) { |
| 109 if (node.target != null) { | 109 if (node.target != null) { |
| 110 node.target.accept(this); | 110 node.target.accept(this); |
| 111 } | 111 } |
| 112 return handlePropertyAccess(node); | 112 return handlePropertyAccess(node); |
| 113 } | 113 } |
| 114 | 114 |
| 115 R handlePropertyAccess(PropertyAccess node) { | 115 R handlePropertyAccess(PropertyAccess node) { |
| 116 return _handlePropertyAccess(node, classifyPropertyAccess(node)); | 116 return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 @override | 119 @override |
| 120 R visitPrefixedIdentifier(PrefixedIdentifier node) { | 120 R visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 121 node.prefix.accept(this); | 121 node.prefix.accept(this); |
| 122 return handlePrefixedIdentifier(node); | 122 return handlePrefixedIdentifier(node); |
| 123 } | 123 } |
| 124 | 124 |
| 125 R handlePrefixedIdentifier(PrefixedIdentifier node) { | 125 R handlePrefixedIdentifier(PrefixedIdentifier node) { |
| 126 return _handlePropertyAccess(node, classifyPrefixedIdentifier(node)); | 126 return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 @override | 129 @override |
| 130 R visitSimpleIdentifier(SimpleIdentifier node) { | 130 R visitSimpleIdentifier(SimpleIdentifier node) { |
| 131 AccessSemantics semantics = classifySimpleIdentifier(node); | 131 AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR); |
| 132 if (semantics != null) { | 132 if (semantics != null) { |
| 133 return _handlePropertyAccess(node, semantics); | 133 return _handlePropertyAccess(node, semantics); |
| 134 } else { | 134 } else { |
| 135 return null; | 135 return null; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 R visitDynamicAccess(AstNode node, AccessSemantics semantics) { | 139 R visitDynamicAccess(AstNode node, AccessSemantics semantics) { |
| 140 return giveUp(node, 'visitDynamicAccess of $semantics'); | 140 return giveUp(node, 'visitDynamicAccess of $semantics'); |
| 141 } | 141 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case AccessKind.STATIC_METHOD: | 179 case AccessKind.STATIC_METHOD: |
| 180 return visitStaticMethodAccess(node, semantics); | 180 return visitStaticMethodAccess(node, semantics); |
| 181 case AccessKind.STATIC_PROPERTY: | 181 case AccessKind.STATIC_PROPERTY: |
| 182 return visitStaticPropertyAccess(node, semantics); | 182 return visitStaticPropertyAccess(node, semantics); |
| 183 default: | 183 default: |
| 184 // Unexpected access kind. | 184 // Unexpected access kind. |
| 185 return giveUp(node, | 185 return giveUp(node, |
| 186 'Unexpected ${semantics} in _handlePropertyAccess.'); | 186 'Unexpected ${semantics} in _handlePropertyAccess.'); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 |
| 190 R visitDynamicPropertyAssignment(AssignmentExpression node, |
| 191 AccessSemantics semantics) { |
| 192 return giveUp(node, 'visitDynamicPropertyAssignment of $semantics'); |
| 193 } |
| 194 |
| 195 R visitLocalFunctionAssignment(AssignmentExpression node, |
| 196 AccessSemantics semantics) { |
| 197 return giveUp(node, 'visitLocalFunctionAssignment of $semantics'); |
| 198 } |
| 199 |
| 200 R visitLocalVariableAssignment(AssignmentExpression node, |
| 201 AccessSemantics semantics) { |
| 202 return giveUp(node, 'visitLocalVariableAssignment of $semantics'); |
| 203 } |
| 204 |
| 205 R visitParameterAssignment(AssignmentExpression node, |
| 206 AccessSemantics semantics) { |
| 207 return giveUp(node, 'visitParameterAssignment of $semantics'); |
| 208 } |
| 209 |
| 210 R visitStaticFieldAssignment(AssignmentExpression node, |
| 211 AccessSemantics semantics) { |
| 212 return giveUp(node, 'visitStaticFieldAssignment of $semantics'); |
| 213 } |
| 214 |
| 215 R visitStaticMethodAssignment(AssignmentExpression node, |
| 216 AccessSemantics semantics) { |
| 217 return giveUp(node, 'visitStaticMethodAssignment of $semantics'); |
| 218 } |
| 219 |
| 220 R visitStaticPropertyAssignment(AssignmentExpression node, |
| 221 AccessSemantics semantics) { |
| 222 return giveUp(node, 'visitStaticPropertyAssignment of $semantics'); |
| 223 } |
| 224 |
| 225 @override |
| 226 R visitAssignmentExpression(AssignmentExpression node) { |
| 227 super.visitAssignmentExpression(node); |
| 228 return handleAssignmentExpression(node); |
| 229 } |
| 230 |
| 231 R handleAssignmentExpression(AssignmentExpression node) { |
| 232 AccessSemantics semantics = |
| 233 node.leftHandSide.accept(ACCESS_SEMANTICS_VISITOR); |
| 234 if (semantics == null) { |
| 235 return giveUp(node, 'handleAssignmentExpression with no AccessSemantics'); |
| 236 } else { |
| 237 switch (semantics.kind) { |
| 238 case AccessKind.DYNAMIC: |
| 239 return visitDynamicPropertyAssignment(node, semantics); |
| 240 case AccessKind.LOCAL_FUNCTION: |
| 241 return visitLocalFunctionAssignment(node, semantics); |
| 242 case AccessKind.LOCAL_VARIABLE: |
| 243 return visitLocalVariableAssignment(node, semantics); |
| 244 case AccessKind.PARAMETER: |
| 245 return visitParameterAssignment(node, semantics); |
| 246 case AccessKind.STATIC_FIELD: |
| 247 return visitStaticFieldAssignment(node, semantics); |
| 248 case AccessKind.STATIC_METHOD: |
| 249 return visitStaticMethodAssignment(node, semantics); |
| 250 case AccessKind.STATIC_PROPERTY: |
| 251 return visitStaticPropertyAssignment(node, semantics); |
| 252 default: |
| 253 // Unexpected access kind. |
| 254 return giveUp(node, |
| 255 'Unexpected ${semantics} in _handlePropertyAccess.'); |
| 256 } |
| 257 } |
| 258 } |
| 189 } | 259 } |
| OLD | NEW |