| Index: pkg/analyzer/lib/src/dart/element/element.dart
|
| diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
|
| index 7c635fe8be939d5243ef53c69f0a8b88ca8ecf06..cf4d49346a521c67f48c3003cc3d1039a87b7412 100644
|
| --- a/pkg/analyzer/lib/src/dart/element/element.dart
|
| +++ b/pkg/analyzer/lib/src/dart/element/element.dart
|
| @@ -476,6 +476,14 @@ class ClassElementImpl extends AbstractClassElementImpl
|
| super(name, offset);
|
|
|
| /**
|
| + * Initialize using the given kernel.
|
| + */
|
| + ClassElementImpl.forKernel(
|
| + CompilationUnitElementImpl enclosingUnit, this._kernel)
|
| + : _unlinkedClass = null,
|
| + super.forSerialized(enclosingUnit);
|
| +
|
| + /**
|
| * Initialize a newly created class element to have the given [name].
|
| */
|
| ClassElementImpl.forNode(Identifier name)
|
| @@ -492,14 +500,6 @@ class ClassElementImpl extends AbstractClassElementImpl
|
| super.forSerialized(enclosingUnit);
|
|
|
| /**
|
| - * Initialize using the given kernel.
|
| - */
|
| - ClassElementImpl.forKernel(
|
| - CompilationUnitElementImpl enclosingUnit, this._kernel)
|
| - : _unlinkedClass = null,
|
| - super.forSerialized(enclosingUnit);
|
| -
|
| - /**
|
| * Set whether this class is abstract.
|
| */
|
| void set abstract(bool isAbstract) {
|
| @@ -1397,15 +1397,13 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
| super(name, -1);
|
|
|
| /**
|
| - * Initialize using the given serialized information.
|
| + * Initialize using the given kernel information.
|
| */
|
| - CompilationUnitElementImpl.forSerialized(
|
| - LibraryElementImpl enclosingLibrary,
|
| - this.resynthesizerContext,
|
| - this._unlinkedUnit,
|
| - this._unlinkedPart,
|
| - String name)
|
| - : _kernelContext = null,
|
| + CompilationUnitElementImpl.forKernel(
|
| + LibraryElementImpl enclosingLibrary, this._kernelContext, String name)
|
| + : resynthesizerContext = null,
|
| + _unlinkedUnit = null,
|
| + _unlinkedPart = null,
|
| super.forSerialized(null) {
|
| _enclosingElement = enclosingLibrary;
|
| _name = name;
|
| @@ -1413,13 +1411,15 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
| }
|
|
|
| /**
|
| - * Initialize using the given kernel information.
|
| + * Initialize using the given serialized information.
|
| */
|
| - CompilationUnitElementImpl.forKernel(
|
| - LibraryElementImpl enclosingLibrary, this._kernelContext, String name)
|
| - : resynthesizerContext = null,
|
| - _unlinkedUnit = null,
|
| - _unlinkedPart = null,
|
| + CompilationUnitElementImpl.forSerialized(
|
| + LibraryElementImpl enclosingLibrary,
|
| + this.resynthesizerContext,
|
| + this._unlinkedUnit,
|
| + this._unlinkedPart,
|
| + String name)
|
| + : _kernelContext = null,
|
| super.forSerialized(null) {
|
| _enclosingElement = enclosingLibrary;
|
| _name = name;
|
| @@ -2018,6 +2018,15 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
| super(name, offset);
|
|
|
| /**
|
| + * Initialize using the given serialized information.
|
| + */
|
| + ConstructorElementImpl.forKernel(
|
| + ClassElementImpl enclosingClass, this._kernel)
|
| + : super.forKernel(enclosingClass, _kernel) {
|
| + isSynthetic = _kernel.isSyntheticDefault;
|
| + }
|
| +
|
| + /**
|
| * Initialize a newly created constructor element to have the given [name].
|
| */
|
| ConstructorElementImpl.forNode(Identifier name)
|
| @@ -2033,15 +2042,6 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
| super.forSerialized(serializedExecutable, enclosingClass);
|
|
|
| /**
|
| - * Initialize using the given serialized information.
|
| - */
|
| - ConstructorElementImpl.forKernel(
|
| - ClassElementImpl enclosingClass, this._kernel)
|
| - : super.forSerialized(null, enclosingClass) {
|
| - isSynthetic = _kernel.isSyntheticDefault;
|
| - }
|
| -
|
| - /**
|
| * Return the constant initializers for this element, which will be empty if
|
| * there are no initializers, or `null` if there was an error in the source.
|
| */
|
| @@ -2078,6 +2078,9 @@ class ConstructorElementImpl extends ExecutableElementImpl
|
|
|
| @override
|
| bool get isConst {
|
| + if (_kernel != null) {
|
| + return _kernel.isConst;
|
| + }
|
| if (serializedExecutable != null) {
|
| return serializedExecutable.isConst;
|
| }
|
| @@ -3662,6 +3665,13 @@ abstract class ExecutableElementImpl extends ElementImpl
|
| super(name, offset);
|
|
|
| /**
|
| + * Initialize using the given kernel.
|
| + */
|
| + ExecutableElementImpl.forKernel(ElementImpl enclosingElement, this._kernel)
|
| + : serializedExecutable = null,
|
| + super.forSerialized(enclosingElement);
|
| +
|
| + /**
|
| * Initialize a newly created executable element to have the given [name].
|
| */
|
| ExecutableElementImpl.forNode(Identifier name)
|
| @@ -3678,13 +3688,6 @@ abstract class ExecutableElementImpl extends ElementImpl
|
| super.forSerialized(enclosingElement);
|
|
|
| /**
|
| - * Initialize using the given kernel.
|
| - */
|
| - ExecutableElementImpl.forKernel(ElementImpl enclosingElement, this._kernel)
|
| - : serializedExecutable = null,
|
| - super.forSerialized(enclosingElement);
|
| -
|
| - /**
|
| * Set whether this executable element's body is asynchronous.
|
| */
|
| void set asynchronous(bool isAsynchronous) {
|
| @@ -3715,6 +3718,9 @@ abstract class ExecutableElementImpl extends ElementImpl
|
|
|
| @override
|
| String get displayName {
|
| + if (_kernel != null) {
|
| + return _kernel.name.name;
|
| + }
|
| if (serializedExecutable != null) {
|
| return serializedExecutable.name;
|
| }
|
| @@ -3801,6 +3807,9 @@ abstract class ExecutableElementImpl extends ElementImpl
|
|
|
| @override
|
| bool get isExternal {
|
| + if (_kernel != null) {
|
| + return _kernel.isExternal;
|
| + }
|
| if (serializedExecutable != null) {
|
| return serializedExecutable.isExternal;
|
| }
|
| @@ -5550,6 +5559,13 @@ class ImportElementImpl extends UriReferencedElementImpl
|
| }
|
|
|
| /**
|
| + * The kernel context in which a library is resynthesized.
|
| + */
|
| +abstract class KernelLibraryResynthesizerContext {
|
| + kernel.Library get library;
|
| +}
|
| +
|
| +/**
|
| * A concrete implementation of a [LabelElement].
|
| */
|
| class LabelElementImpl extends ElementImpl implements LabelElement {
|
| @@ -5710,6 +5726,27 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
|
| super(name, offset);
|
|
|
| /**
|
| + * Initialize using the given kernel information.
|
| + */
|
| + LibraryElementImpl.forKernel(this.context, this._kernelContext)
|
| + : resynthesizerContext = null,
|
| + _unlinkedDefiningUnit = null,
|
| + nameLength = _kernelContext.library.name?.length ?? 0,
|
| + super.forSerialized(null) {
|
| + _name = _kernelContext.library.name ?? '';
|
| + _nameOffset = _kernelContext.library.fileOffset;
|
| + setResolutionCapability(
|
| + LibraryResolutionCapability.resolvedTypeNames, true);
|
| + setResolutionCapability(
|
| + LibraryResolutionCapability.constantExpressions, true);
|
| +
|
| + definingCompilationUnit = new CompilationUnitElementImpl.forKernel(
|
| + this, _kernelContext, '<no-name>');
|
| +
|
| + // TODO(scheglov) how to support parts?
|
| + }
|
| +
|
| + /**
|
| * Initialize a newly created library element in the given [context] to have
|
| * the given [name].
|
| */
|
| @@ -5735,27 +5772,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
|
| LibraryResolutionCapability.constantExpressions, true);
|
| }
|
|
|
| - /**
|
| - * Initialize using the given kernel information.
|
| - */
|
| - LibraryElementImpl.forKernel(this.context, this._kernelContext)
|
| - : resynthesizerContext = null,
|
| - _unlinkedDefiningUnit = null,
|
| - nameLength = _kernelContext.library.name?.length ?? 0,
|
| - super.forSerialized(null) {
|
| - _name = _kernelContext.library.name ?? '';
|
| - _nameOffset = _kernelContext.library.fileOffset;
|
| - setResolutionCapability(
|
| - LibraryResolutionCapability.resolvedTypeNames, true);
|
| - setResolutionCapability(
|
| - LibraryResolutionCapability.constantExpressions, true);
|
| -
|
| - definingCompilationUnit = new CompilationUnitElementImpl.forKernel(
|
| - this, _kernelContext, '<no-name>');
|
| -
|
| - // TODO(scheglov) how to support parts?
|
| - }
|
| -
|
| @override
|
| int get codeLength {
|
| CompilationUnitElement unit = _definingCompilationUnit;
|
| @@ -8991,10 +9007,3 @@ abstract class VariableElementImpl extends ElementImpl
|
| _initializer?.accept(visitor);
|
| }
|
| }
|
| -
|
| -/**
|
| - * The kernel context in which a library is resynthesized.
|
| - */
|
| -abstract class KernelLibraryResynthesizerContext {
|
| - kernel.Library get library;
|
| -}
|
|
|