| 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 ConstructorElement lookupDefaultConstructor() { | 2403 Element validateConstructorLookupResults(Selector selector, |
| 2404 ConstructorElement constructor = lookupConstructor(""); | 2404 Element result, |
| 2405 if (constructor != null | 2405 Element noMatch(Element)) { |
| 2406 && constructor.functionSignature.requiredParameterCount == 0) { | 2406 if (result == null |
| 2407 return constructor; | 2407 || !result.isConstructor |
| 2408 || (isPrivateName(selector.name) |
| 2409 && result.library != selector.library)) { |
| 2410 result = noMatch != null ? noMatch(result) : null; |
| 2408 } | 2411 } |
| 2409 return null; | 2412 return result; |
| 2410 } | 2413 } |
| 2411 | 2414 |
| 2412 ConstructorElement lookupConstructor(String name) { | 2415 // TODO(aprelev@gmail.com): Peter believes that it would be great to |
| 2413 Element result = localLookup(name); | 2416 // make noMatch a required argument. Peter's suspicion is that most |
| 2414 return result != null && result.isConstructor ? result : null; | 2417 // callers of this method would benefit from using the noMatch method. |
| 2418 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { |
| 2419 Element result = localLookup(selector.name); |
| 2420 return validateConstructorLookupResults(selector, result, noMatch); |
| 2415 } | 2421 } |
| 2416 | 2422 |
| 2417 Link<Element> get constructors { | 2423 Link<Element> get constructors { |
| 2418 // TODO(ajohnsen): See if we can avoid this method at some point. | 2424 // TODO(ajohnsen): See if we can avoid this method at some point. |
| 2419 Link<Element> result = const Link<Element>(); | 2425 Link<Element> result = const Link<Element>(); |
| 2420 // TODO(johnniwinther): Should we include injected constructors? | 2426 // TODO(johnniwinther): Should we include injected constructors? |
| 2421 forEachMember((_, Element member) { | 2427 forEachMember((_, Element member) { |
| 2422 if (member.isConstructor) result = result.prepend(member); | 2428 if (member.isConstructor) result = result.prepend(member); |
| 2423 }); | 2429 }); |
| 2424 return result; | 2430 return result; |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 AstElement get definingElement; | 3044 AstElement get definingElement; |
| 3039 | 3045 |
| 3040 bool get hasResolvedAst => definingElement.hasTreeElements; | 3046 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3041 | 3047 |
| 3042 ResolvedAst get resolvedAst { | 3048 ResolvedAst get resolvedAst { |
| 3043 return new ResolvedAst(declaration, | 3049 return new ResolvedAst(declaration, |
| 3044 definingElement.node, definingElement.treeElements); | 3050 definingElement.node, definingElement.treeElements); |
| 3045 } | 3051 } |
| 3046 | 3052 |
| 3047 } | 3053 } |
| OLD | NEW |