| 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 | 7 |
| 8 import '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
| 9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 bool get isConst; | 326 bool get isConst; |
| 327 | 327 |
| 328 /// `true` if this element is a top level or local variable, static or | 328 /// `true` if this element is a top level or local variable, static or |
| 329 /// instance field, or parameter that is declared `final`. | 329 /// instance field, or parameter that is declared `final`. |
| 330 bool get isFinal; | 330 bool get isFinal; |
| 331 | 331 |
| 332 /// `true` if this element is a method, getter, setter or field that | 332 /// `true` if this element is a method, getter, setter or field that |
| 333 /// is declared `static`. | 333 /// is declared `static`. |
| 334 bool get isStatic; | 334 bool get isStatic; |
| 335 | 335 |
| 336 /// `true` if this element is local element, that is, a local variable, |
| 337 /// local function or parameter. |
| 338 bool get isLocal; |
| 339 |
| 336 bool get impliesType; | 340 bool get impliesType; |
| 337 | 341 |
| 338 Token get position; | 342 Token get position; |
| 339 | 343 |
| 340 CompilationUnitElement get compilationUnit; | 344 CompilationUnitElement get compilationUnit; |
| 341 LibraryElement get library; | 345 LibraryElement get library; |
| 342 LibraryElement get implementationLibrary; | 346 LibraryElement get implementationLibrary; |
| 343 ClassElement get enclosingClass; | 347 ClassElement get enclosingClass; |
| 344 Element get enclosingClassOrCompilationUnit; | 348 Element get enclosingClassOrCompilationUnit; |
| 345 Element get outermostEnclosingMemberOrTopLevel; | 349 Element get outermostEnclosingMemberOrTopLevel; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 440 } |
| 437 return element; | 441 return element; |
| 438 } | 442 } |
| 439 | 443 |
| 440 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; | 444 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; |
| 441 static bool isTypedef(Element e) { | 445 static bool isTypedef(Element e) { |
| 442 return e != null && e.kind == ElementKind.TYPEDEF; | 446 return e != null && e.kind == ElementKind.TYPEDEF; |
| 443 } | 447 } |
| 444 | 448 |
| 445 static bool isLocal(Element element) { | 449 static bool isLocal(Element element) { |
| 446 return !Elements.isUnresolved(element) | 450 return !Elements.isUnresolved(element) && element.isLocal; |
| 447 && !element.isInstanceMember | |
| 448 && !isStaticOrTopLevelField(element) | |
| 449 && !isStaticOrTopLevelFunction(element) | |
| 450 && (identical(element.kind, ElementKind.VARIABLE) || | |
| 451 identical(element.kind, ElementKind.PARAMETER) || | |
| 452 identical(element.kind, ElementKind.FUNCTION)); | |
| 453 } | 451 } |
| 454 | 452 |
| 455 static bool isInstanceField(Element element) { | 453 static bool isInstanceField(Element element) { |
| 456 return !Elements.isUnresolved(element) | 454 return !Elements.isUnresolved(element) |
| 457 && element.isInstanceMember | 455 && element.isInstanceMember |
| 458 && (identical(element.kind, ElementKind.FIELD) | 456 && (identical(element.kind, ElementKind.FIELD) |
| 459 || identical(element.kind, ElementKind.GETTER) | 457 || identical(element.kind, ElementKind.GETTER) |
| 460 || identical(element.kind, ElementKind.SETTER)); | 458 || identical(element.kind, ElementKind.SETTER)); |
| 461 } | 459 } |
| 462 | 460 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 VariableDefinitions get node; | 1041 VariableDefinitions get node; |
| 1044 } | 1042 } |
| 1045 | 1043 |
| 1046 /// A formal parameter of a function or constructor. | 1044 /// A formal parameter of a function or constructor. |
| 1047 /// | 1045 /// |
| 1048 /// Normal parameter that introduce a local variable are modeled by | 1046 /// Normal parameter that introduce a local variable are modeled by |
| 1049 /// [LocalParameterElement] whereas initializing formals, that is parameter of | 1047 /// [LocalParameterElement] whereas initializing formals, that is parameter of |
| 1050 /// the form `this.x`, are modeled by [InitializingFormalParameter]. | 1048 /// the form `this.x`, are modeled by [InitializingFormalParameter]. |
| 1051 abstract class ParameterElement extends Element | 1049 abstract class ParameterElement extends Element |
| 1052 implements VariableElement, FormalElement, LocalElement { | 1050 implements VariableElement, FormalElement, LocalElement { |
| 1051 /// Use [functionDeclaration] instead. |
| 1052 @deprecated |
| 1053 get enclosingElement; |
| 1054 |
| 1053 /// The function on which this parameter is declared. | 1055 /// The function on which this parameter is declared. |
| 1054 FunctionElement get functionDeclaration; | 1056 FunctionElement get functionDeclaration; |
| 1055 } | 1057 } |
| 1056 | 1058 |
| 1057 /// A formal parameter on a function or constructor that introduces a local | 1059 /// A formal parameter on a function or constructor that introduces a local |
| 1058 /// variable in the scope of the function or constructor. | 1060 /// variable in the scope of the function or constructor. |
| 1059 abstract class LocalParameterElement extends ParameterElement | 1061 abstract class LocalParameterElement extends ParameterElement |
| 1060 implements LocalVariableElement { | 1062 implements LocalVariableElement { |
| 1061 } | 1063 } |
| 1062 | 1064 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 bool get isDeclaredByField; | 1558 bool get isDeclaredByField; |
| 1557 | 1559 |
| 1558 /// Returns `true` if this member is abstract. | 1560 /// Returns `true` if this member is abstract. |
| 1559 bool get isAbstract; | 1561 bool get isAbstract; |
| 1560 | 1562 |
| 1561 /// If abstract, [implementation] points to the overridden concrete member, | 1563 /// If abstract, [implementation] points to the overridden concrete member, |
| 1562 /// if any. Otherwise [implementation] points to the member itself. | 1564 /// if any. Otherwise [implementation] points to the member itself. |
| 1563 Member get implementation; | 1565 Member get implementation; |
| 1564 } | 1566 } |
| 1565 | 1567 |
| OLD | NEW |