Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/element.dart |
| diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart |
| index 5615521c812c571d223f9cc072fb4164d687a599..3eddadf0c56275659629a31209bf4832a761aa0a 100644 |
| --- a/pkg/analyzer/lib/src/generated/element.dart |
| +++ b/pkg/analyzer/lib/src/generated/element.dart |
| @@ -3384,6 +3384,26 @@ abstract class ElementImpl implements Element { |
| return shortName; |
| } |
| + /** |
| + * Return `true` if this element is used or potentially can be used. |
| + * |
| + * For a top-level element: it is public, or it is private and used in the |
| + * defining library. |
| + * |
| + * For a local variable: its value is used (i.e. purely read or invoked) |
| + * somewhere in its scope. |
| + * |
| + * This information is only available for local variables (including |
| + * parameters) and only after the compilation unit containing the element |
| + * has been resolved. |
| + */ |
| + bool get isUsed { |
| + if (isPublic) { |
| + return true; |
| + } |
| + return hasModifier(Modifier.IS_USED); |
| + } |
| + |
| @override |
| LibraryElement get library => getAncestor((element) => element is LibraryElement); |
| @@ -3551,6 +3571,13 @@ abstract class ElementImpl implements Element { |
| bool hasModifier(Modifier modifier) => BooleanArray.getEnum(_modifiers, modifier); |
| /** |
| + * Specifies that the element is used. |
| + */ |
| + void markUsed() { |
| + setModifier(Modifier.IS_USED, true); |
| + } |
| + |
| + /** |
| * If the given child is not `null`, use the given visitor to visit it. |
| * |
| * @param child the child to be visited |
| @@ -8270,6 +8297,11 @@ class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria |
| accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); |
| @override |
| + bool get isUsed { |
| + return hasModifier(Modifier.IS_USED); |
| + } |
| + |
| + @override |
| ElementKind get kind => ElementKind.LOCAL_VARIABLE; |
| @override |
| @@ -8295,9 +8327,6 @@ class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria |
| @override |
| bool get isPotentiallyMutatedInScope => hasModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE); |
| - @override |
| - bool get isUsed => hasModifier(Modifier.IS_USED_VARIABLE); |
| - |
| /** |
| * Specifies that this variable is potentially mutated somewhere in closure. |
| */ |
| @@ -8313,13 +8342,6 @@ class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria |
| } |
| /** |
| - * Specifies that the value of this variable is used. |
| - */ |
| - void markUsed() { |
| - setModifier(Modifier.IS_USED_VARIABLE, true); |
| - } |
| - |
| - /** |
| * Set the toolkit specific information objects attached to this variable. |
| * |
| * @param toolkitObjects the toolkit objects attached to this variable |
| @@ -8780,9 +8802,16 @@ class Modifier extends Enum<Modifier> { |
| static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 9); |
| /** |
| - * Indicates that the value of a variable is used - read or invoked. |
| + * Indicates that the element is used. |
| + * |
| + * |
| + * For a top-level element: it is public, or it is private and used in the |
| + * defining library. |
| + * |
| + * For a local variable: its value is used (i.e. purely read or invoked) |
| + * somewhere in its scope. |
| */ |
| - static const Modifier IS_USED_VARIABLE = const Modifier('IS_USED_VARIABLE', 10); |
| + static const Modifier IS_USED = const Modifier('IS_USED', 10); |
|
Brian Wilkerson
2014/11/10 23:34:47
This might be less misleading if it were named IS_
scheglov
2014/11/11 02:57:06
Done.
|
| /** |
| * Indicates that a class can validly be used as a mixin. |
| @@ -8838,7 +8867,7 @@ class Modifier extends Enum<Modifier> { |
| GENERATOR, |
| GETTER, |
| HAS_EXT_URI, |
| - IS_USED_VARIABLE, |
| + IS_USED, |
| MIXIN, |
| POTENTIALLY_MUTATED_IN_CONTEXT, |
| POTENTIALLY_MUTATED_IN_SCOPE, |
| @@ -11621,14 +11650,6 @@ abstract class VariableElementImpl extends ElementImpl implements VariableElemen |
| bool get isFinal => hasModifier(Modifier.FINAL); |
| /** |
| - * Return `true` if this variable is used (i.e. purely read or invoked) |
| - * somewhere in its scope. This information is only available for local |
| - * variables (including parameters) and only after the compilation unit |
| - * containing the variable has been resolved. |
| - */ |
| - bool get isUsed => false; |
| - |
| - /** |
| * Return `true` if this variable is potentially mutated somewhere in a closure. This |
| * information is only available for local variables (including parameters) and only after the |
| * compilation unit containing the variable has been resolved. |