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 /** | 5 /** |
6 * Code for classifying the semantics of identifiers appearing in a Dart file. | 6 * Code for classifying the semantics of identifiers appearing in a Dart file. |
7 */ | 7 */ |
8 library analyzer2dart.identifierSemantics; | 8 library analyzer2dart.identifierSemantics; |
9 | 9 |
10 import 'package:analyzer/analyzer.dart'; | 10 import 'package:analyzer/analyzer.dart'; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 static const AccessKind STATIC_METHOD = const AccessKind._('STATIC_METHOD'); | 52 static const AccessKind STATIC_METHOD = const AccessKind._('STATIC_METHOD'); |
53 | 53 |
54 /** | 54 /** |
55 * The destination of the access is a property getter/setter that is defined | 55 * The destination of the access is a property getter/setter that is defined |
56 * statically within a class, or at top level within a library. | 56 * statically within a class, or at top level within a library. |
57 */ | 57 */ |
58 static const AccessKind STATIC_PROPERTY = | 58 static const AccessKind STATIC_PROPERTY = |
59 const AccessKind._('STATIC_PROPERTY'); | 59 const AccessKind._('STATIC_PROPERTY'); |
60 | 60 |
61 /** | 61 /** |
62 * The destination of the access is a toplevel class. | 62 * The destination of the access is a toplevel class, function typedef, mixin |
| 63 * application, or the built-in type "dynamic". |
63 */ | 64 */ |
64 static const AccessKind TOPLEVEL_CLASS = | 65 static const AccessKind TOPLEVEL_TYPE = |
65 const AccessKind._('TOPLEVEL_CLASS'); | 66 const AccessKind._('TOPLEVEL_TYPE'); |
66 | 67 |
67 /** | 68 /** |
68 * The destination of the access is a type parameter of the enclosing class. | 69 * The destination of the access is a type parameter of the enclosing class. |
69 */ | 70 */ |
70 static const AccessKind TYPE_PARAMETER = | 71 static const AccessKind TYPE_PARAMETER = |
71 const AccessKind._('TYPE_PARAMETER'); | 72 const AccessKind._('TYPE_PARAMETER'); |
72 | 73 |
73 final String name; | 74 final String name; |
74 | 75 |
75 String toString() => name; | 76 String toString() => name; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 AccessSemantics.staticMethod(this.identifier, this.element, this.classElement, | 161 AccessSemantics.staticMethod(this.identifier, this.element, this.classElement, |
161 {this.isInvoke: false}) | 162 {this.isInvoke: false}) |
162 : kind = AccessKind.STATIC_METHOD, | 163 : kind = AccessKind.STATIC_METHOD, |
163 target = null; | 164 target = null; |
164 | 165 |
165 AccessSemantics.staticProperty(this.identifier, this.element, | 166 AccessSemantics.staticProperty(this.identifier, this.element, |
166 this.classElement, {this.isInvoke: false}) | 167 this.classElement, {this.isInvoke: false}) |
167 : kind = AccessKind.STATIC_PROPERTY, | 168 : kind = AccessKind.STATIC_PROPERTY, |
168 target = null; | 169 target = null; |
169 | 170 |
170 AccessSemantics.toplevelClass(this.identifier, this.element) | 171 AccessSemantics.toplevelType(this.identifier, this.element) |
171 : kind = AccessKind.TOPLEVEL_CLASS, | 172 : kind = AccessKind.TOPLEVEL_TYPE, |
172 classElement = null, | 173 classElement = null, |
173 isInvoke = false, | 174 isInvoke = false, |
174 target = null; | 175 target = null; |
175 | 176 |
176 AccessSemantics.typeParameter(this.identifier, this.element) | 177 AccessSemantics.typeParameter(this.identifier, this.element) |
177 : kind = AccessKind.TYPE_PARAMETER, | 178 : kind = AccessKind.TYPE_PARAMETER, |
178 classElement = null, | 179 classElement = null, |
179 isInvoke = false, | 180 isInvoke = false, |
180 target = null; | 181 target = null; |
181 | 182 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 Element rhsElement = rhs.staticElement; | 373 Element rhsElement = rhs.staticElement; |
373 if (lhsElement is PrefixElement) { | 374 if (lhsElement is PrefixElement) { |
374 if (rhsElement is PropertyAccessorElement) { | 375 if (rhsElement is PropertyAccessorElement) { |
375 if (rhsElement.isSynthetic) { | 376 if (rhsElement.isSynthetic) { |
376 return new AccessSemantics.staticField(rhs, rhsElement.variable, null)
; | 377 return new AccessSemantics.staticField(rhs, rhsElement.variable, null)
; |
377 } else { | 378 } else { |
378 return new AccessSemantics.staticProperty(rhs, rhsElement, null); | 379 return new AccessSemantics.staticProperty(rhs, rhsElement, null); |
379 } | 380 } |
380 } else if (rhsElement is FunctionElement) { | 381 } else if (rhsElement is FunctionElement) { |
381 return new AccessSemantics.staticMethod(rhs, rhsElement, null); | 382 return new AccessSemantics.staticMethod(rhs, rhsElement, null); |
382 } else if (rhsElement is ClassElement) { | 383 } else if (rhsElement is ClassElement || |
383 return new AccessSemantics.toplevelClass(rhs, rhsElement); | 384 rhsElement is FunctionTypeAliasElement) { |
| 385 return new AccessSemantics.toplevelType(rhs, rhsElement); |
384 } else { | 386 } else { |
385 return new AccessSemantics.dynamic(rhs, null); | 387 return new AccessSemantics.dynamic(rhs, null); |
386 } | 388 } |
387 } else if (lhsElement is ClassElement) { | 389 } else if (lhsElement is ClassElement) { |
388 if (rhsElement is PropertyAccessorElement && rhsElement.isSynthetic) { | 390 if (rhsElement is PropertyAccessorElement && rhsElement.isSynthetic) { |
389 return new AccessSemantics.staticField( | 391 return new AccessSemantics.staticField( |
390 rhs, | 392 rhs, |
391 rhsElement.variable, | 393 rhsElement.variable, |
392 lhsElement); | 394 lhsElement); |
393 } else if (rhsElement is MethodElement) { | 395 } else if (rhsElement is MethodElement) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } else { | 475 } else { |
474 return new AccessSemantics.localFunction(node, staticElement); | 476 return new AccessSemantics.localFunction(node, staticElement); |
475 } | 477 } |
476 } else if (staticElement is MethodElement && staticElement.isStatic) { | 478 } else if (staticElement is MethodElement && staticElement.isStatic) { |
477 return new AccessSemantics.staticMethod( | 479 return new AccessSemantics.staticMethod( |
478 node, | 480 node, |
479 staticElement, | 481 staticElement, |
480 staticElement.enclosingElement); | 482 staticElement.enclosingElement); |
481 } else if (staticElement is TypeParameterElement) { | 483 } else if (staticElement is TypeParameterElement) { |
482 return new AccessSemantics.typeParameter(node, staticElement); | 484 return new AccessSemantics.typeParameter(node, staticElement); |
483 } else if (staticElement is ClassElement) { | 485 } else if (staticElement is ClassElement || |
484 return new AccessSemantics.toplevelClass(node, staticElement); | 486 staticElement is FunctionTypeAliasElement || |
| 487 staticElement is DynamicElementImpl) { |
| 488 return new AccessSemantics.toplevelType(node, staticElement); |
485 } | 489 } |
486 return new AccessSemantics.dynamic(node, null); | 490 return new AccessSemantics.dynamic(node, null); |
487 } | 491 } |
488 } | 492 } |
OLD | NEW |