| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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; | 5 library elements; |
| 6 | 6 |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 | 8 |
| 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 import '../../compiler.dart' as api_e; | 10 import '../../compiler.dart' as api_e; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool isFunction() => identical(kind, ElementKind.FUNCTION); | 154 bool isFunction() => identical(kind, ElementKind.FUNCTION); |
| 155 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); | 155 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); |
| 156 bool isClosure() => false; | 156 bool isClosure() => false; |
| 157 bool isMember() { | 157 bool isMember() { |
| 158 // Check that this element is defined in the scope of a Class. | 158 // Check that this element is defined in the scope of a Class. |
| 159 return enclosingElement != null && enclosingElement.isClass(); | 159 return enclosingElement != null && enclosingElement.isClass(); |
| 160 } | 160 } |
| 161 bool isInstanceMember() => false; | 161 bool isInstanceMember() => false; |
| 162 |
| 163 /** |
| 164 * Returns [:true:] if this element is enclosed in a static member or is |
| 165 * itself a static member. |
| 166 */ |
| 167 bool isInStaticMember() { |
| 168 Element member = getEnclosingMember(); |
| 169 return member != null && member.modifiers.isStatic(); |
| 170 } |
| 171 |
| 162 bool isFactoryConstructor() => modifiers.isFactory(); | 172 bool isFactoryConstructor() => modifiers.isFactory(); |
| 163 bool isGenerativeConstructor() => | 173 bool isGenerativeConstructor() => |
| 164 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR); | 174 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR); |
| 165 bool isGenerativeConstructorBody() => | 175 bool isGenerativeConstructorBody() => |
| 166 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY); | 176 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY); |
| 167 bool isCompilationUnit() => identical(kind, ElementKind.COMPILATION_UNIT); | 177 bool isCompilationUnit() => identical(kind, ElementKind.COMPILATION_UNIT); |
| 168 bool isClass() => identical(kind, ElementKind.CLASS); | 178 bool isClass() => identical(kind, ElementKind.CLASS); |
| 169 bool isPrefix() => identical(kind, ElementKind.PREFIX); | 179 bool isPrefix() => identical(kind, ElementKind.PREFIX); |
| 170 bool isVariable() => identical(kind, ElementKind.VARIABLE); | 180 bool isVariable() => identical(kind, ElementKind.VARIABLE); |
| 171 bool isParameter() => identical(kind, ElementKind.PARAMETER); | 181 bool isParameter() => identical(kind, ElementKind.PARAMETER); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return null; | 299 return null; |
| 290 } | 300 } |
| 291 | 301 |
| 292 Element getEnclosingClassOrCompilationUnit() { | 302 Element getEnclosingClassOrCompilationUnit() { |
| 293 for (Element e = this; e != null; e = e.enclosingElement) { | 303 for (Element e = this; e != null; e = e.enclosingElement) { |
| 294 if (e.isClass() || e.isCompilationUnit()) return e; | 304 if (e.isClass() || e.isCompilationUnit()) return e; |
| 295 } | 305 } |
| 296 return null; | 306 return null; |
| 297 } | 307 } |
| 298 | 308 |
| 309 /** |
| 310 * Returns the member enclosing this element or the element itself if it is a |
| 311 * member. If no enclosing element is found, [:null:] is returned. |
| 312 */ |
| 299 Element getEnclosingMember() { | 313 Element getEnclosingMember() { |
| 300 for (Element e = this; e != null; e = e.enclosingElement) { | 314 for (Element e = this; e != null; e = e.enclosingElement) { |
| 301 if (e.isMember()) return e; | 315 if (e.isMember()) return e; |
| 302 } | 316 } |
| 303 return null; | 317 return null; |
| 304 } | 318 } |
| 305 | 319 |
| 306 Element getOutermostEnclosingMemberOrTopLevel() { | 320 Element getOutermostEnclosingMemberOrTopLevel() { |
| 307 // TODO(lrn): Why is this called "Outermost"? | 321 // TODO(lrn): Why is this called "Outermost"? |
| 308 for (Element e = this; e != null; e = e.enclosingElement) { | 322 for (Element e = this; e != null; e = e.enclosingElement) { |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 | 1945 |
| 1932 MetadataAnnotation ensureResolved(Compiler compiler) { | 1946 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1933 if (resolutionState == STATE_NOT_STARTED) { | 1947 if (resolutionState == STATE_NOT_STARTED) { |
| 1934 compiler.resolver.resolveMetadataAnnotation(this); | 1948 compiler.resolver.resolveMetadataAnnotation(this); |
| 1935 } | 1949 } |
| 1936 return this; | 1950 return this; |
| 1937 } | 1951 } |
| 1938 | 1952 |
| 1939 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1953 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1940 } | 1954 } |
| OLD | NEW |