| 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 Resolution, Parsing; | 8 import '../common/resolution.dart' show Resolution, Parsing; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/constant_constructors.dart'; | 10 import '../constants/constant_constructors.dart'; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 bool get isLocal => false; | 102 bool get isLocal => false; |
| 103 | 103 |
| 104 // TODO(johnniwinther): This breaks for libraries (for which enclosing | 104 // TODO(johnniwinther): This breaks for libraries (for which enclosing |
| 105 // elements are null) and is invalid for top level variable declarations for | 105 // elements are null) and is invalid for top level variable declarations for |
| 106 // which the enclosing element is a VariableDeclarations and not a compilation | 106 // which the enclosing element is a VariableDeclarations and not a compilation |
| 107 // unit. | 107 // unit. |
| 108 bool get isTopLevel { | 108 bool get isTopLevel { |
| 109 return enclosingElement != null && enclosingElement.isCompilationUnit; | 109 return enclosingElement != null && enclosingElement.isCompilationUnit; |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool get isAssignable { | |
| 113 if (isFinal || isConst) return false; | |
| 114 if (isFunction || isConstructor) return false; | |
| 115 return true; | |
| 116 } | |
| 117 | |
| 118 Token get position => null; | 112 Token get position => null; |
| 119 | 113 |
| 120 SourceSpan get sourcePosition { | 114 SourceSpan get sourcePosition { |
| 121 if (position == null) return null; | 115 if (position == null) return null; |
| 122 Uri uri = compilationUnit.script.resourceUri; | 116 Uri uri = compilationUnit.script.resourceUri; |
| 123 return new SourceSpan( | 117 return new SourceSpan( |
| 124 uri, position.charOffset, position.charOffset + position.charCount); | 118 uri, position.charOffset, position.charOffset + position.charCount); |
| 125 } | 119 } |
| 126 | 120 |
| 127 Token findMyName(Token token) { | 121 Token findMyName(Token token) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return null; | 164 return null; |
| 171 } | 165 } |
| 172 | 166 |
| 173 Element get enclosingClassOrCompilationUnit { | 167 Element get enclosingClassOrCompilationUnit { |
| 174 for (Element e = this; e != null; e = e.enclosingElement) { | 168 for (Element e = this; e != null; e = e.enclosingElement) { |
| 175 if (e.isClass || e.isCompilationUnit) return e; | 169 if (e.isClass || e.isCompilationUnit) return e; |
| 176 } | 170 } |
| 177 return null; | 171 return null; |
| 178 } | 172 } |
| 179 | 173 |
| 180 Element get outermostEnclosingMemberOrTopLevel { | |
| 181 // TODO(lrn): Why is this called "Outermost"? | |
| 182 // TODO(johnniwinther): Clean up this method: This method does not return | |
| 183 // the outermost for elements in closure classses, but some call-sites rely | |
| 184 // on that behavior. | |
| 185 for (Element e = this; e != null; e = e.enclosingElement) { | |
| 186 if (e.isClassMember || e.isTopLevel) { | |
| 187 return e; | |
| 188 } | |
| 189 } | |
| 190 return null; | |
| 191 } | |
| 192 | |
| 193 /** | 174 /** |
| 194 * Creates the scope for this element. | 175 * Creates the scope for this element. |
| 195 */ | 176 */ |
| 196 Scope buildScope() => enclosingElement.buildScope(); | 177 Scope buildScope() => enclosingElement.buildScope(); |
| 197 | 178 |
| 198 String toString() { | 179 String toString() { |
| 199 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an | 180 // TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
| 200 // invariant for all element types? | 181 // invariant for all element types? |
| 201 var nameText = name != null ? name : '?'; | 182 var nameText = name != null ? name : '?'; |
| 202 if (enclosingElement != null && !isTopLevel) { | 183 if (enclosingElement != null && !isTopLevel) { |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3284 | 3265 |
| 3285 bool get hasResolvedAst { | 3266 bool get hasResolvedAst { |
| 3286 return definingElement.hasNode && definingElement.hasTreeElements; | 3267 return definingElement.hasNode && definingElement.hasTreeElements; |
| 3287 } | 3268 } |
| 3288 | 3269 |
| 3289 ResolvedAst get resolvedAst { | 3270 ResolvedAst get resolvedAst { |
| 3290 return new ParsedResolvedAst( | 3271 return new ParsedResolvedAst( |
| 3291 declaration, definingElement.node, definingElement.treeElements); | 3272 declaration, definingElement.node, definingElement.treeElements); |
| 3292 } | 3273 } |
| 3293 } | 3274 } |
| OLD | NEW |