| 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 c99e635a5dfb90e9a53d002bf92e94b0821a9e1c..0e58ac100e97fd9f05cb792f64c45976489f44c9 100644
|
| --- a/pkg/analyzer/lib/src/dart/element/element.dart
|
| +++ b/pkg/analyzer/lib/src/dart/element/element.dart
|
| @@ -1419,7 +1419,7 @@ class ClassElementImpl extends AbstractClassElementImpl
|
| /**
|
| * A concrete implementation of a [CompilationUnitElement].
|
| */
|
| -class CompilationUnitElementImpl extends ElementImpl
|
| +class CompilationUnitElementImpl extends UriReferencedElementImpl
|
| implements CompilationUnitElement {
|
| /**
|
| * The context in which this unit is resynthesized, or `null` if the
|
| @@ -3417,17 +3417,6 @@ abstract class ElementImpl implements Element {
|
| }
|
| }
|
|
|
| - String _selectUri(
|
| - String defaultUri, List<UnlinkedConfiguration> configurations) {
|
| - for (UnlinkedConfiguration configuration in configurations) {
|
| - if (context.declaredVariables.get(configuration.name) ==
|
| - configuration.value) {
|
| - return configuration.uri;
|
| - }
|
| - }
|
| - return defaultUri;
|
| - }
|
| -
|
| static int findElementIndexUsingIdentical(List items, Object item) {
|
| int length = items.length;
|
| for (int i = 0; i < length; i++) {
|
| @@ -4252,7 +4241,8 @@ abstract class ExecutableElementImpl extends ElementImpl
|
| /**
|
| * A concrete implementation of an [ExportElement].
|
| */
|
| -class ExportElementImpl extends ElementImpl implements ExportElement {
|
| +class ExportElementImpl extends UriReferencedElementImpl
|
| + implements ExportElement {
|
| /**
|
| * The unlinked representation of the export in the summary.
|
| */
|
| @@ -4311,11 +4301,8 @@ class ExportElementImpl extends ElementImpl implements ExportElement {
|
| @override
|
| LibraryElement get exportedLibrary {
|
| if (_unlinkedExportNonPublic != null && _exportedLibrary == null) {
|
| - _selectedUri ??= _selectUri(
|
| - _unlinkedExportPublic.uri, _unlinkedExportPublic.configurations);
|
| LibraryElementImpl library = enclosingElement as LibraryElementImpl;
|
| - _exportedLibrary =
|
| - library.resynthesizerContext.buildExportedLibrary(_selectedUri);
|
| + _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri);
|
| }
|
| return _exportedLibrary;
|
| }
|
| @@ -4356,6 +4343,49 @@ class ExportElementImpl extends ElementImpl implements ExportElement {
|
| }
|
|
|
| @override
|
| + String get uri {
|
| + if (_unlinkedExportPublic != null) {
|
| + return _selectedUri ??= _selectUri(
|
| + _unlinkedExportPublic.uri, _unlinkedExportPublic.configurations);
|
| + }
|
| + return super.uri;
|
| + }
|
| +
|
| + @override
|
| + void set uri(String uri) {
|
| + _assertNotResynthesized(_unlinkedExportPublic);
|
| + super.uri = uri;
|
| + }
|
| +
|
| + @override
|
| + int get uriEnd {
|
| + if (_unlinkedExportNonPublic != null) {
|
| + return _unlinkedExportNonPublic.uriEnd;
|
| + }
|
| + return super.uriEnd;
|
| + }
|
| +
|
| + @override
|
| + void set uriEnd(int uriEnd) {
|
| + _assertNotResynthesized(_unlinkedExportNonPublic);
|
| + super.uriEnd = uriEnd;
|
| + }
|
| +
|
| + @override
|
| + int get uriOffset {
|
| + if (_unlinkedExportNonPublic != null) {
|
| + return _unlinkedExportNonPublic.uriOffset;
|
| + }
|
| + return super.uriOffset;
|
| + }
|
| +
|
| + @override
|
| + void set uriOffset(int uriOffset) {
|
| + _assertNotResynthesized(_unlinkedExportNonPublic);
|
| + super.uriOffset = uriOffset;
|
| + }
|
| +
|
| + @override
|
| T accept<T>(ElementVisitor<T> visitor) => visitor.visitExportElement(this);
|
|
|
| @override
|
| @@ -5539,7 +5569,8 @@ class HideElementCombinatorImpl implements HideElementCombinator {
|
| /**
|
| * A concrete implementation of an [ImportElement].
|
| */
|
| -class ImportElementImpl extends ElementImpl implements ImportElement {
|
| +class ImportElementImpl extends UriReferencedElementImpl
|
| + implements ImportElement {
|
| /**
|
| * The unlinked representation of the import in the summary.
|
| */
|
| @@ -5579,6 +5610,11 @@ class ImportElementImpl extends ElementImpl implements ImportElement {
|
| PrefixElement _prefix;
|
|
|
| /**
|
| + * The URI that was selected based on the [context] declared variables.
|
| + */
|
| + String _selectedUri;
|
| +
|
| + /**
|
| * Initialize a newly created import element at the given [offset].
|
| * The offset may be `-1` if the import is synthetic.
|
| */
|
| @@ -5732,6 +5768,58 @@ class ImportElementImpl extends ElementImpl implements ImportElement {
|
| }
|
|
|
| @override
|
| + String get uri {
|
| + if (_unlinkedImport != null) {
|
| + if (_unlinkedImport.isImplicit) {
|
| + return null;
|
| + }
|
| + return _selectedUri ??=
|
| + _selectUri(_unlinkedImport.uri, _unlinkedImport.configurations);
|
| + }
|
| + return super.uri;
|
| + }
|
| +
|
| + @override
|
| + void set uri(String uri) {
|
| + _assertNotResynthesized(_unlinkedImport);
|
| + super.uri = uri;
|
| + }
|
| +
|
| + @override
|
| + int get uriEnd {
|
| + if (_unlinkedImport != null) {
|
| + if (_unlinkedImport.isImplicit) {
|
| + return -1;
|
| + }
|
| + return _unlinkedImport.uriEnd;
|
| + }
|
| + return super.uriEnd;
|
| + }
|
| +
|
| + @override
|
| + void set uriEnd(int uriEnd) {
|
| + _assertNotResynthesized(_unlinkedImport);
|
| + super.uriEnd = uriEnd;
|
| + }
|
| +
|
| + @override
|
| + int get uriOffset {
|
| + if (_unlinkedImport != null) {
|
| + if (_unlinkedImport.isImplicit) {
|
| + return -1;
|
| + }
|
| + return _unlinkedImport.uriOffset;
|
| + }
|
| + return super.uriOffset;
|
| + }
|
| +
|
| + @override
|
| + void set uriOffset(int uriOffset) {
|
| + _assertNotResynthesized(_unlinkedImport);
|
| + super.uriOffset = uriOffset;
|
| + }
|
| +
|
| + @override
|
| T accept<T>(ElementVisitor<T> visitor) => visitor.visitImportElement(this);
|
|
|
| @override
|
| @@ -9219,6 +9307,89 @@ class UnitExplicitTopLevelVariables {
|
| }
|
|
|
| /**
|
| + * A concrete implementation of a [UriReferencedElement].
|
| + */
|
| +abstract class UriReferencedElementImpl extends ElementImpl
|
| + implements UriReferencedElement {
|
| + /**
|
| + * The offset of the URI in the file, or `-1` if this node is synthetic.
|
| + */
|
| + int _uriOffset = -1;
|
| +
|
| + /**
|
| + * The offset of the character immediately following the last character of
|
| + * this node's URI, or `-1` if this node is synthetic.
|
| + */
|
| + int _uriEnd = -1;
|
| +
|
| + /**
|
| + * The URI that is specified by this directive.
|
| + */
|
| + String _uri;
|
| +
|
| + /**
|
| + * Initialize a newly created import element to have the given [name] and
|
| + * [offset]. The offset may be `-1` if the element is synthetic.
|
| + */
|
| + UriReferencedElementImpl(String name, int offset) : super(name, offset);
|
| +
|
| + /**
|
| + * Initialize using the given serialized information.
|
| + */
|
| + UriReferencedElementImpl.forSerialized(ElementImpl enclosingElement)
|
| + : super.forSerialized(enclosingElement);
|
| +
|
| + /**
|
| + * Return the URI that is specified by this directive.
|
| + */
|
| + String get uri => _uri;
|
| +
|
| + /**
|
| + * Set the URI that is specified by this directive to be the given [uri].
|
| + */
|
| + void set uri(String uri) {
|
| + _uri = uri;
|
| + }
|
| +
|
| + /**
|
| + * Return the offset of the character immediately following the last character
|
| + * of this node's URI, or `-1` if this node is synthetic.
|
| + */
|
| + int get uriEnd => _uriEnd;
|
| +
|
| + /**
|
| + * Set the offset of the character immediately following the last character of
|
| + * this node's URI to the given [offset].
|
| + */
|
| + void set uriEnd(int offset) {
|
| + _uriEnd = offset;
|
| + }
|
| +
|
| + /**
|
| + * Return the offset of the URI in the file, or `-1` if this node is synthetic.
|
| + */
|
| + int get uriOffset => _uriOffset;
|
| +
|
| + /**
|
| + * Set the offset of the URI in the file to the given [offset].
|
| + */
|
| + void set uriOffset(int offset) {
|
| + _uriOffset = offset;
|
| + }
|
| +
|
| + String _selectUri(
|
| + String defaultUri, List<UnlinkedConfiguration> configurations) {
|
| + for (UnlinkedConfiguration configuration in configurations) {
|
| + if (context.declaredVariables.get(configuration.name) ==
|
| + configuration.value) {
|
| + return configuration.uri;
|
| + }
|
| + }
|
| + return defaultUri;
|
| + }
|
| +}
|
| +
|
| +/**
|
| * A concrete implementation of a [VariableElement].
|
| */
|
| abstract class VariableElementImpl extends ElementImpl
|
|
|