Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: packages/analyzer/lib/src/dart/element/handle.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: packages/analyzer/lib/src/dart/element/handle.dart
diff --git a/packages/analyzer/lib/src/generated/element_handle.dart b/packages/analyzer/lib/src/dart/element/handle.dart
similarity index 67%
copy from packages/analyzer/lib/src/generated/element_handle.dart
copy to packages/analyzer/lib/src/dart/element/handle.dart
index f4966021d875d32d305cb9a7e08d512f2a7486c7..93edecad41538793a9143d03ab4504eb85542f3e 100644
--- a/packages/analyzer/lib/src/generated/element_handle.dart
+++ b/packages/analyzer/lib/src/dart/element/handle.dart
@@ -2,28 +2,31 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library engine.element_handle;
+library analyzer.src.generated.element_handle;
-import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/constant.dart';
-import 'package:analyzer/src/generated/element.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/constant/value.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/java_core.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
/**
- * Instances of the class `ClassElementHandle` implement a handle to a `ClassElement`.
+ * A handle to a [ClassElement].
*/
class ClassElementHandle extends ElementHandle implements ClassElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ClassElementHandle(ClassElement element) : super(element);
+ ClassElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
List<PropertyAccessorElement> get accessors => actualElement.accessors;
@@ -58,6 +61,9 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
@override
bool get isEnum => actualElement.isEnum;
+ @override
+ bool get isJS => actualElement.isJS;
+
@override
bool get isMixinApplication => actualElement.isMixinApplication;
@@ -68,8 +74,7 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
bool get isProxy => actualElement.isProxy;
@override
- @deprecated
- bool get isTypedef => actualElement.isMixinApplication;
+ bool get isRequired => actualElement.isRequired;
@override
bool get isValidMixin => actualElement.isValidMixin;
@@ -95,6 +100,9 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
@override
ConstructorElement get unnamedConstructor => actualElement.unnamedConstructor;
+ @override
+ NamedCompilationUnitMember computeNode() => super.computeNode();
+
@override
FieldElement getField(String fieldName) => actualElement.getField(fieldName);
@@ -145,8 +153,9 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
@override
MethodElement lookUpInheritedMethod(
- String methodName, LibraryElement library) =>
- actualElement.lookUpInheritedMethod(methodName, library);
+ String methodName, LibraryElement library) {
+ return actualElement.lookUpInheritedMethod(methodName, library);
+ }
@override
MethodElement lookUpMethod(String methodName, LibraryElement library) =>
@@ -159,17 +168,18 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
}
/**
- * Instances of the class `CompilationUnitElementHandle` implements a handle to a
- * [CompilationUnitElement].
+ * A handle to a [CompilationUnitElement].
*/
class CompilationUnitElementHandle extends ElementHandle
implements CompilationUnitElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- CompilationUnitElementHandle(CompilationUnitElement element) : super(element);
+ CompilationUnitElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
List<PropertyAccessorElement> get accessors => actualElement.accessors;
@@ -233,17 +243,18 @@ class CompilationUnitElementHandle extends ElementHandle
}
/**
- * Instances of the class `ConstructorElementHandle` implement a handle to a
- * `ConstructorElement`.
+ * A handle to a [ConstructorElement].
*/
class ConstructorElementHandle extends ExecutableElementHandle
implements ConstructorElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ConstructorElementHandle(ConstructorElement element) : super(element);
+ ConstructorElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ConstructorElement get actualElement =>
@@ -279,8 +290,7 @@ class ConstructorElementHandle extends ExecutableElementHandle
}
/**
- * The abstract class `ElementHandle` implements the behavior common to objects that implement
- * a handle to an [Element].
+ * A handle to an [Element].
*/
abstract class ElementHandle implements Element {
/**
@@ -289,56 +299,49 @@ abstract class ElementHandle implements Element {
final int id = 0;
/**
- * The context in which the element is defined.
+ * The [ElementResynthesizer] which will be used to resynthesize elements on
+ * demand.
*/
- AnalysisContext _context;
+ final ElementResynthesizer _resynthesizer;
/**
- * The location of this element, used to reconstitute the element if it has been garbage
- * collected.
+ * The location of this element, used to reconstitute the element if it has
+ * not yet been resynthesized.
*/
- ElementLocation _location;
+ final ElementLocation _location;
/**
- * A reference to the element being referenced by this handle, or `null` if the element has
- * been garbage collected.
+ * A reference to the element being referenced by this handle, or `null` if
+ * the element has not yet been resynthesized.
*/
- WeakReference<Element> _elementReference;
+ Element _elementReference;
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ElementHandle(Element element) {
- _context = element.context;
- _location = element.location;
- _elementReference = new WeakReference<Element>(element);
- }
+ ElementHandle(this._resynthesizer, this._location);
/**
- * Return the element being represented by this handle, reconstituting the element if the
- * reference has been set to `null`.
- *
- * @return the element being represented by this handle
+ * Return the element being represented by this handle, reconstituting the
+ * element if the reference has been set to `null`.
*/
Element get actualElement {
- Element element = _elementReference.get();
- if (element == null) {
- element = _context.getElement(_location);
- _elementReference = new WeakReference<Element>(element);
+ if (_elementReference == null) {
+ _elementReference = _resynthesizer.getElement(_location);
}
- return element;
+ return _elementReference;
}
@override
- AnalysisContext get context => _context;
+ AnalysisContext get context => _resynthesizer.context;
@override
String get displayName => actualElement.displayName;
@override
- SourceRange get docRange => actualElement.docRange;
+ String get documentationComment => actualElement.documentationComment;
@override
Element get enclosingElement => actualElement.enclosingElement;
@@ -349,15 +352,27 @@ abstract class ElementHandle implements Element {
@override
bool get isDeprecated => actualElement.isDeprecated;
+ @override
+ bool get isFactory => actualElement.isFactory;
+
+ @override
+ bool get isJS => actualElement.isJS;
+
@override
bool get isOverride => actualElement.isOverride;
@override
bool get isPrivate => actualElement.isPrivate;
+ @override
+ bool get isProtected => actualElement.isProtected;
+
@override
bool get isPublic => actualElement.isPublic;
+ @override
+ bool get isRequired => actualElement.isRequired;
+
@override
bool get isSynthetic => actualElement.isSynthetic;
@@ -365,6 +380,9 @@ abstract class ElementHandle implements Element {
LibraryElement get library =>
getAncestor((element) => element is LibraryElement);
+ @override
+ Source get librarySource => actualElement.librarySource;
+
@override
ElementLocation get location => _location;
@@ -380,10 +398,6 @@ abstract class ElementHandle implements Element {
@override
int get nameOffset => actualElement.nameOffset;
- @deprecated
- @override
- AstNode get node => computeNode();
-
@override
Source get source => actualElement.source;
@@ -398,14 +412,14 @@ abstract class ElementHandle implements Element {
accept(ElementVisitor visitor) => actualElement.accept(visitor);
@override
- String computeDocumentationComment() =>
- actualElement.computeDocumentationComment();
+ String computeDocumentationComment() => documentationComment;
@override
AstNode computeNode() => actualElement.computeNode();
@override
- Element getAncestor(Predicate<Element> predicate) =>
+ Element/*=E*/ getAncestor/*<E extends Element >*/(
+ Predicate<Element> predicate) =>
actualElement.getAncestor(predicate);
@override
@@ -416,100 +430,51 @@ abstract class ElementHandle implements Element {
bool isAccessibleIn(LibraryElement library) =>
actualElement.isAccessibleIn(library);
+ @override
+ String toString() => actualElement.toString();
+
@override
void visitChildren(ElementVisitor visitor) {
actualElement.visitChildren(visitor);
}
+}
+/**
+ * Interface which allows an [Element] handle to be resynthesized based on an
+ * [ElementLocation]. The concrete classes implementing element handles use
+ * this interface to retrieve the underlying elements when queried.
+ */
+abstract class ElementResynthesizer {
/**
- * Return a handle on the given element. If the element is already a handle, then it will be
- * returned directly, otherwise a handle of the appropriate class will be constructed.
- *
- * @param element the element for which a handle is to be constructed
- * @return a handle on the given element
+ * The context that owns the element to be resynthesized.
*/
- static Element forElement(Element element) {
- if (element is ElementHandle) {
- return element;
- }
- while (true) {
- if (element.kind == ElementKind.CLASS) {
- return new ClassElementHandle(element as ClassElement);
- } else if (element.kind == ElementKind.COMPILATION_UNIT) {
- return new CompilationUnitElementHandle(
- element as CompilationUnitElement);
- } else if (element.kind == ElementKind.CONSTRUCTOR) {
- return new ConstructorElementHandle(element as ConstructorElement);
- } else if (element.kind == ElementKind.EXPORT) {
- return new ExportElementHandle(element as ExportElement);
- } else if (element.kind == ElementKind.FIELD) {
- return new FieldElementHandle(element as FieldElement);
- } else if (element.kind == ElementKind.FUNCTION) {
- return new FunctionElementHandle(element as FunctionElement);
- } else if (element.kind == ElementKind.GETTER) {
- return new PropertyAccessorElementHandle(
- element as PropertyAccessorElement);
- } else if (element.kind == ElementKind.IMPORT) {
- return new ImportElementHandle(element as ImportElement);
- } else if (element.kind == ElementKind.LABEL) {
- return new LabelElementHandle(element as LabelElement);
- } else if (element.kind == ElementKind.LIBRARY) {
- return new LibraryElementHandle(element as LibraryElement);
- } else if (element.kind == ElementKind.LOCAL_VARIABLE) {
- return new LocalVariableElementHandle(element as LocalVariableElement);
- } else if (element.kind == ElementKind.METHOD) {
- return new MethodElementHandle(element as MethodElement);
- } else if (element.kind == ElementKind.PARAMETER) {
- return new ParameterElementHandle(element as ParameterElement);
- } else if (element.kind == ElementKind.PREFIX) {
- return new PrefixElementHandle(element as PrefixElement);
- } else if (element.kind == ElementKind.SETTER) {
- return new PropertyAccessorElementHandle(
- element as PropertyAccessorElement);
- } else if (element.kind == ElementKind.TOP_LEVEL_VARIABLE) {
- return new TopLevelVariableElementHandle(
- element as TopLevelVariableElement);
- } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) {
- return new FunctionTypeAliasElementHandle(
- element as FunctionTypeAliasElement);
- } else if (element.kind == ElementKind.TYPE_PARAMETER) {
- return new TypeParameterElementHandle(element as TypeParameterElement);
- } else {
- throw new UnsupportedOperationException();
- }
- break;
- }
- }
+ final AnalysisContext context;
/**
- * Return an array of the same size as the given array where each element of the returned array is
- * a handle for the corresponding element of the given array.
- *
- * @param elements the elements for which handles are to be created
- * @return an array of handles to the given elements
+ * Initialize a newly created resynthesizer to resynthesize elements in the
+ * given [context].
*/
- static List<Element> forElements(List<Element> elements) {
- int length = elements.length;
- List<Element> handles = new List<Element>.from(elements);
- for (int i = 0; i < length; i++) {
- handles[i] = forElement(elements[i]);
- }
- return handles;
- }
+ ElementResynthesizer(this.context);
+
+ /**
+ * Return the element referenced by the given [location].
+ */
+ Element getElement(ElementLocation location);
}
/**
- * The abstract class `ExecutableElementHandle` implements the behavior common to objects that
- * implement a handle to an [ExecutableElement].
+ * A handle to an [ExecutableElement].
*/
abstract class ExecutableElementHandle extends ElementHandle
implements ExecutableElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ExecutableElementHandle(ExecutableElement element) : super(element);
+ ExecutableElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ExecutableElement get actualElement =>
@@ -562,16 +527,17 @@ abstract class ExecutableElementHandle extends ElementHandle
}
/**
- * Instances of the class `ExportElementHandle` implement a handle to an `ExportElement`
- * .
+ * A handle to an [ExportElement].
*/
class ExportElementHandle extends ElementHandle implements ExportElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ExportElementHandle(ExportElement element) : super(element);
+ ExportElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ExportElement get actualElement => super.actualElement as ExportElement;
@@ -596,16 +562,18 @@ class ExportElementHandle extends ElementHandle implements ExportElement {
}
/**
- * Instances of the class `FieldElementHandle` implement a handle to a `FieldElement`.
+ * A handle to a [FieldElement].
*/
class FieldElementHandle extends PropertyInducingElementHandle
implements FieldElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- FieldElementHandle(FieldElement element) : super(element);
+ FieldElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
FieldElement get actualElement => super.actualElement as FieldElement;
@@ -616,6 +584,9 @@ class FieldElementHandle extends PropertyInducingElementHandle
@override
bool get isEnumConstant => actualElement.isEnumConstant;
+ @override
+ bool get isVirtual => actualElement.isVirtual;
+
@override
ElementKind get kind => ElementKind.FIELD;
@@ -624,17 +595,18 @@ class FieldElementHandle extends PropertyInducingElementHandle
}
/**
- * Instances of the class `FunctionElementHandle` implement a handle to a
- * `FunctionElement`.
+ * A handle to a [FunctionElement].
*/
class FunctionElementHandle extends ExecutableElementHandle
implements FunctionElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- FunctionElementHandle(FunctionElement element) : super(element);
+ FunctionElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
FunctionElement get actualElement => super.actualElement as FunctionElement;
@@ -653,18 +625,18 @@ class FunctionElementHandle extends ExecutableElementHandle
}
/**
- * Instances of the class `FunctionTypeAliasElementHandle` implement a handle to a
- * `FunctionTypeAliasElement`.
+ * A handle to a [FunctionTypeAliasElement].
*/
class FunctionTypeAliasElementHandle extends ElementHandle
implements FunctionTypeAliasElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- FunctionTypeAliasElementHandle(FunctionTypeAliasElement element)
- : super(element);
+ FunctionTypeAliasElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
FunctionTypeAliasElement get actualElement =>
@@ -694,16 +666,17 @@ class FunctionTypeAliasElementHandle extends ElementHandle
}
/**
- * Instances of the class `ImportElementHandle` implement a handle to an `ImportElement`
- * .
+ * A handle to an [ImportElement].
*/
class ImportElementHandle extends ElementHandle implements ImportElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ImportElementHandle(ImportElement element) : super(element);
+ ImportElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ImportElement get actualElement => super.actualElement as ImportElement;
@@ -737,15 +710,17 @@ class ImportElementHandle extends ElementHandle implements ImportElement {
}
/**
- * Instances of the class `LabelElementHandle` implement a handle to a `LabelElement`.
+ * A handle to a [LabelElement].
*/
class LabelElementHandle extends ElementHandle implements LabelElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- LabelElementHandle(LabelElement element) : super(element);
+ LabelElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ExecutableElement get enclosingElement =>
@@ -756,16 +731,17 @@ class LabelElementHandle extends ElementHandle implements LabelElement {
}
/**
- * Instances of the class `LibraryElementHandle` implement a handle to a
- * `LibraryElement`.
+ * A handle to a [LibraryElement].
*/
class LibraryElementHandle extends ElementHandle implements LibraryElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- LibraryElementHandle(LibraryElement element) : super(element);
+ LibraryElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
LibraryElement get actualElement => super.actualElement as LibraryElement;
@@ -792,6 +768,9 @@ class LibraryElementHandle extends ElementHandle implements LibraryElement {
@override
bool get hasLoadLibraryFunction => actualElement.hasLoadLibraryFunction;
+ @override
+ String get identifier => location.components.last;
+
@override
List<LibraryElement> get importedLibraries => actualElement.importedLibraries;
@@ -801,6 +780,9 @@ class LibraryElementHandle extends ElementHandle implements LibraryElement {
@override
bool get isBrowserApplication => actualElement.isBrowserApplication;
+ @override
+ bool get isDartAsync => actualElement.isDartAsync;
+
@override
bool get isDartCore => actualElement.isDartCore;
@@ -810,6 +792,9 @@ class LibraryElementHandle extends ElementHandle implements LibraryElement {
@override
ElementKind get kind => ElementKind.LIBRARY;
+ @override
+ List<LibraryElement> get libraryCycle => actualElement.libraryCycle;
+
@override
FunctionElement get loadLibraryFunction => actualElement.loadLibraryFunction;
@@ -825,32 +810,27 @@ class LibraryElementHandle extends ElementHandle implements LibraryElement {
@override
List<CompilationUnitElement> get units => actualElement.units;
- @override
- List<LibraryElement> get visibleLibraries => actualElement.visibleLibraries;
-
@override
List<ImportElement> getImportsWithPrefix(PrefixElement prefixElement) =>
actualElement.getImportsWithPrefix(prefixElement);
@override
ClassElement getType(String className) => actualElement.getType(className);
-
- @override
- bool isUpToDate(int timeStamp) => actualElement.isUpToDate(timeStamp);
}
/**
- * Instances of the class `LocalVariableElementHandle` implement a handle to a
- * `LocalVariableElement`.
+ * A handle to a [LocalVariableElement].
*/
class LocalVariableElementHandle extends VariableElementHandle
implements LocalVariableElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- LocalVariableElementHandle(LocalVariableElement element) : super(element);
+ LocalVariableElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
LocalVariableElement get actualElement =>
@@ -867,16 +847,18 @@ class LocalVariableElementHandle extends VariableElementHandle
}
/**
- * Instances of the class `MethodElementHandle` implement a handle to a `MethodElement`.
+ * A handle to a [MethodElement].
*/
class MethodElementHandle extends ExecutableElementHandle
implements MethodElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- MethodElementHandle(MethodElement element) : super(element);
+ MethodElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
MethodElement get actualElement => super.actualElement as MethodElement;
@@ -895,18 +877,19 @@ class MethodElementHandle extends ExecutableElementHandle
}
/**
- * Instances of the class `ParameterElementHandle` implement a handle to a
- * `ParameterElement`.
+ * A handle to a [ParameterElement].
*/
class ParameterElementHandle extends VariableElementHandle
with ParameterElementMixin
implements ParameterElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- ParameterElementHandle(ParameterElement element) : super(element);
+ ParameterElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ParameterElement get actualElement => super.actualElement as ParameterElement;
@@ -914,6 +897,9 @@ class ParameterElementHandle extends VariableElementHandle
@override
String get defaultValueCode => actualElement.defaultValueCode;
+ @override
+ bool get isCovariant => actualElement.isCovariant;
+
@override
bool get isInitializingFormal => actualElement.isInitializingFormal;
@@ -931,18 +917,23 @@ class ParameterElementHandle extends VariableElementHandle
@override
SourceRange get visibleRange => actualElement.visibleRange;
+
+ @override
+ FormalParameter computeNode() => super.computeNode();
}
/**
- * Instances of the class `PrefixElementHandle` implement a handle to a `PrefixElement`.
+ * A handle to a [PrefixElement].
*/
class PrefixElementHandle extends ElementHandle implements PrefixElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- PrefixElementHandle(PrefixElement element) : super(element);
+ PrefixElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
PrefixElement get actualElement => super.actualElement as PrefixElement;
@@ -952,25 +943,25 @@ class PrefixElementHandle extends ElementHandle implements PrefixElement {
super.enclosingElement as LibraryElement;
@override
- List<LibraryElement> get importedLibraries => actualElement.importedLibraries;
+ List<LibraryElement> get importedLibraries => LibraryElement.EMPTY_LIST;
@override
ElementKind get kind => ElementKind.PREFIX;
}
/**
- * Instances of the class `PropertyAccessorElementHandle` implement a handle to a
- * `PropertyAccessorElement`.
+ * A handle to a [PropertyAccessorElement].
*/
class PropertyAccessorElementHandle extends ExecutableElementHandle
implements PropertyAccessorElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- PropertyAccessorElementHandle(PropertyAccessorElement element)
- : super(element);
+ PropertyAccessorElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
PropertyAccessorElement get actualElement =>
@@ -985,10 +976,10 @@ class PropertyAccessorElementHandle extends ExecutableElementHandle
actualElement.correspondingSetter;
@override
- bool get isGetter => actualElement.isGetter;
+ bool get isGetter => !isSetter;
@override
- bool get isSetter => actualElement.isSetter;
+ bool get isSetter => location.components.last.endsWith('=');
@override
ElementKind get kind {
@@ -1004,18 +995,18 @@ class PropertyAccessorElementHandle extends ExecutableElementHandle
}
/**
- * The abstract class `PropertyInducingElementHandle` implements the behavior common to
- * objects that implement a handle to an `PropertyInducingElement`.
+ * A handle to an [PropertyInducingElement].
*/
abstract class PropertyInducingElementHandle extends VariableElementHandle
implements PropertyInducingElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- PropertyInducingElementHandle(PropertyInducingElement element)
- : super(element);
+ PropertyInducingElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
PropertyInducingElement get actualElement =>
@@ -1032,35 +1023,39 @@ abstract class PropertyInducingElementHandle extends VariableElementHandle
}
/**
- * Instances of the class `TopLevelVariableElementHandle` implement a handle to a
- * `TopLevelVariableElement`.
+ * A handle to a [TopLevelVariableElement].
*/
class TopLevelVariableElementHandle extends PropertyInducingElementHandle
implements TopLevelVariableElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- TopLevelVariableElementHandle(TopLevelVariableElement element)
- : super(element);
+ TopLevelVariableElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE;
+
+ @override
+ VariableDeclaration computeNode() => super.computeNode();
}
/**
- * Instances of the class `TypeParameterElementHandle` implement a handle to a
- * [TypeParameterElement].
+ * A handle to a [TypeParameterElement].
*/
class TypeParameterElementHandle extends ElementHandle
implements TypeParameterElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- TypeParameterElementHandle(TypeParameterElement element) : super(element);
+ TypeParameterElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
TypeParameterElement get actualElement =>
@@ -1077,17 +1072,18 @@ class TypeParameterElementHandle extends ElementHandle
}
/**
- * The abstract class `VariableElementHandle` implements the behavior common to objects that
- * implement a handle to an `VariableElement`.
+ * A handle to an [VariableElement].
*/
abstract class VariableElementHandle extends ElementHandle
implements VariableElement {
/**
- * Initialize a newly created element handle to represent the given element.
- *
- * @param element the element being represented
+ * Initialize a newly created element handle to represent the element at the
+ * given [_location]. The [_resynthesizer] will be used to resynthesize the
+ * element when needed.
*/
- VariableElementHandle(VariableElement element) : super(element);
+ VariableElementHandle(
+ ElementResynthesizer resynthesizer, ElementLocation location)
+ : super(resynthesizer, location);
@override
VariableElement get actualElement => super.actualElement as VariableElement;
@@ -1107,10 +1103,12 @@ abstract class VariableElementHandle extends ElementHandle
@override
bool get isFinal => actualElement.isFinal;
+ @deprecated
@override
bool get isPotentiallyMutatedInClosure =>
actualElement.isPotentiallyMutatedInClosure;
+ @deprecated
@override
bool get isPotentiallyMutatedInScope =>
actualElement.isPotentiallyMutatedInScope;
@@ -1120,13 +1118,7 @@ abstract class VariableElementHandle extends ElementHandle
@override
DartType get type => actualElement.type;
-}
-/**
- * TODO(scheglov) invalid implementation
- */
-class WeakReference<T> {
- final T value;
- WeakReference(this.value);
- T get() => value;
+ @override
+ DartObject computeConstantValue() => actualElement.computeConstantValue();
}
« no previous file with comments | « packages/analyzer/lib/src/dart/element/element.dart ('k') | packages/analyzer/lib/src/dart/element/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698