| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../helpers/helpers.dart'; // Included for debug helpers. | 9 import '../helpers/helpers.dart'; // Included for debug helpers. |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 // same library. | 2393 // same library. |
| 2394 return true; | 2394 return true; |
| 2395 } | 2395 } |
| 2396 } | 2396 } |
| 2397 } | 2397 } |
| 2398 lookupClass = lookupClass.superclass; | 2398 lookupClass = lookupClass.superclass; |
| 2399 } | 2399 } |
| 2400 return false; | 2400 return false; |
| 2401 } | 2401 } |
| 2402 | 2402 |
| 2403 Element validateConstructorLookupResults(Selector selector, | 2403 ConstructorElement lookupDefaultConstructor() { |
| 2404 Element result, | 2404 ConstructorElement constructor = lookupConstructor(""); |
| 2405 Element noMatch(Element)) { | 2405 // This method might be called on constructors that have not been |
| 2406 if (result == null | 2406 // resolved. As we query the live world, we return `null` in such cases |
| 2407 || !result.isConstructor | 2407 // as no default constructor exists in the live world. |
| 2408 || (isPrivateName(selector.name) | 2408 if (constructor != null && |
| 2409 && result.library != selector.library)) { | 2409 constructor.hasFunctionSignature && |
| 2410 result = noMatch != null ? noMatch(result) : null; | 2410 constructor.functionSignature.requiredParameterCount == 0) { |
| 2411 return constructor; |
| 2411 } | 2412 } |
| 2412 return result; | 2413 return null; |
| 2413 } | 2414 } |
| 2414 | 2415 |
| 2415 // TODO(aprelev@gmail.com): Peter believes that it would be great to | 2416 ConstructorElement lookupConstructor(String name) { |
| 2416 // make noMatch a required argument. Peter's suspicion is that most | 2417 Element result = localLookup(name); |
| 2417 // callers of this method would benefit from using the noMatch method. | 2418 return result != null && result.isConstructor ? result : null; |
| 2418 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { | |
| 2419 Element result = localLookup(selector.name); | |
| 2420 return validateConstructorLookupResults(selector, result, noMatch); | |
| 2421 } | 2419 } |
| 2422 | 2420 |
| 2423 Link<Element> get constructors { | 2421 Link<Element> get constructors { |
| 2424 // TODO(ajohnsen): See if we can avoid this method at some point. | 2422 // TODO(ajohnsen): See if we can avoid this method at some point. |
| 2425 Link<Element> result = const Link<Element>(); | 2423 Link<Element> result = const Link<Element>(); |
| 2426 // TODO(johnniwinther): Should we include injected constructors? | 2424 // TODO(johnniwinther): Should we include injected constructors? |
| 2427 forEachMember((_, Element member) { | 2425 forEachMember((_, Element member) { |
| 2428 if (member.isConstructor) result = result.prepend(member); | 2426 if (member.isConstructor) result = result.prepend(member); |
| 2429 }); | 2427 }); |
| 2430 return result; | 2428 return result; |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3044 AstElement get definingElement; | 3042 AstElement get definingElement; |
| 3045 | 3043 |
| 3046 bool get hasResolvedAst => definingElement.hasTreeElements; | 3044 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3047 | 3045 |
| 3048 ResolvedAst get resolvedAst { | 3046 ResolvedAst get resolvedAst { |
| 3049 return new ResolvedAst(declaration, | 3047 return new ResolvedAst(declaration, |
| 3050 definingElement.node, definingElement.treeElements); | 3048 definingElement.node, definingElement.treeElements); |
| 3051 } | 3049 } |
| 3052 | 3050 |
| 3053 } | 3051 } |
| OLD | NEW |