| 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 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 Element noMatch(Element)) { | 2186 Element noMatch(Element)) { |
| 2187 if (result == null | 2187 if (result == null |
| 2188 || !result.isConstructor | 2188 || !result.isConstructor |
| 2189 || (isPrivateName(selector.name) | 2189 || (isPrivateName(selector.name) |
| 2190 && result.library != selector.library)) { | 2190 && result.library != selector.library)) { |
| 2191 result = noMatch != null ? noMatch(result) : null; | 2191 result = noMatch != null ? noMatch(result) : null; |
| 2192 } | 2192 } |
| 2193 return result; | 2193 return result; |
| 2194 } | 2194 } |
| 2195 | 2195 |
| 2196 // TODO(aprelev@gmail.com): Peter believes that it would be great to | 2196 ConstructorElement lookupDefaultConstructor() { |
| 2197 // make noMatch a required argument. Peter's suspicion is that most | 2197 ConstructorElement constructor = lookupConstructor(""); |
| 2198 // callers of this method would benefit from using the noMatch method. | 2198 if (constructor != null |
| 2199 Element lookupConstructor(Selector selector, [Element noMatch(Element)]) { | 2199 && constructor.functionSignature.requiredParameterCount == 0) { |
| 2200 Element result = localLookup(selector.name); | 2200 return constructor; |
| 2201 return validateConstructorLookupResults(selector, result, noMatch); | 2201 } |
| 2202 return null; |
| 2203 } |
| 2204 |
| 2205 ConstructorElement lookupConstructor(String name) { |
| 2206 Element result = localLookup(name); |
| 2207 return result != null && result.isConstructor ? result : null; |
| 2202 } | 2208 } |
| 2203 | 2209 |
| 2204 Link<Element> get constructors { | 2210 Link<Element> get constructors { |
| 2205 // TODO(ajohnsen): See if we can avoid this method at some point. | 2211 // TODO(ajohnsen): See if we can avoid this method at some point. |
| 2206 Link<Element> result = const Link<Element>(); | 2212 Link<Element> result = const Link<Element>(); |
| 2207 // TODO(johnniwinther): Should we include injected constructors? | 2213 // TODO(johnniwinther): Should we include injected constructors? |
| 2208 forEachMember((_, Element member) { | 2214 forEachMember((_, Element member) { |
| 2209 if (member.isConstructor) result = result.prepend(member); | 2215 if (member.isConstructor) result = result.prepend(member); |
| 2210 }); | 2216 }); |
| 2211 return result; | 2217 return result; |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 AstElement get definingElement; | 2831 AstElement get definingElement; |
| 2826 | 2832 |
| 2827 bool get hasResolvedAst => definingElement.hasTreeElements; | 2833 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 2828 | 2834 |
| 2829 ResolvedAst get resolvedAst { | 2835 ResolvedAst get resolvedAst { |
| 2830 return new ResolvedAst(declaration, | 2836 return new ResolvedAst(declaration, |
| 2831 definingElement.node, definingElement.treeElements); | 2837 definingElement.node, definingElement.treeElements); |
| 2832 } | 2838 } |
| 2833 | 2839 |
| 2834 } | 2840 } |
| OLD | NEW |