| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show | 8 import '../common/resolution.dart' show |
| 9 Resolution, | 9 Resolution, |
| 10 Parsing; | 10 Parsing; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // the outermost for elements in closure classses, but some call-sites rely | 201 // the outermost for elements in closure classses, but some call-sites rely |
| 202 // on that behavior. | 202 // on that behavior. |
| 203 for (Element e = this; e != null; e = e.enclosingElement) { | 203 for (Element e = this; e != null; e = e.enclosingElement) { |
| 204 if (e.isClassMember || e.isTopLevel) { | 204 if (e.isClassMember || e.isTopLevel) { |
| 205 return e; | 205 return e; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 return null; | 208 return null; |
| 209 } | 209 } |
| 210 | 210 |
| 211 ClassElement get contextClass { | |
| 212 ClassElement cls; | |
| 213 for (Element e = this; e != null; e = e.enclosingElement) { | |
| 214 if (e.isClass) { | |
| 215 // Record [e] instead of returning it directly. We need the last class | |
| 216 // in the chain since the first classes might be closure classes. | |
| 217 cls = e.declaration; | |
| 218 } | |
| 219 } | |
| 220 return cls; | |
| 221 } | |
| 222 | |
| 223 /** | 211 /** |
| 224 * Creates the scope for this element. | 212 * Creates the scope for this element. |
| 225 */ | 213 */ |
| 226 Scope buildScope() => enclosingElement.buildScope(); | 214 Scope buildScope() => enclosingElement.buildScope(); |
| 227 | 215 |
| 228 String toString() { | 216 String toString() { |
| 229 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an | 217 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
| 230 // invariant for all element types? | 218 // invariant for all element types? |
| 231 var nameText = name != null ? name : '?'; | 219 var nameText = name != null ? name : '?'; |
| 232 if (enclosingElement != null && !isTopLevel) { | 220 if (enclosingElement != null && !isTopLevel) { |
| (...skipping 2988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3221 AstElement get definingElement; | 3209 AstElement get definingElement; |
| 3222 | 3210 |
| 3223 bool get hasResolvedAst => definingElement.hasTreeElements; | 3211 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3224 | 3212 |
| 3225 ResolvedAst get resolvedAst { | 3213 ResolvedAst get resolvedAst { |
| 3226 return new ResolvedAst(declaration, | 3214 return new ResolvedAst(declaration, |
| 3227 definingElement.node, definingElement.treeElements); | 3215 definingElement.node, definingElement.treeElements); |
| 3228 } | 3216 } |
| 3229 | 3217 |
| 3230 } | 3218 } |
| OLD | NEW |