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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2982993003: Remove UriReferencedElement with its uri/uriOffset/uriEnd properties. (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: 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 8dff6d78e307d87c97785835869f04fb717063c0..7eee2c6d17705f13ca2dfcb111bbce2bf980cfef 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1371,7 +1371,7 @@ class ClassElementImpl extends AbstractClassElementImpl
/**
* A concrete implementation of a [CompilationUnitElement].
*/
-class CompilationUnitElementImpl extends UriReferencedElementImpl
+class CompilationUnitElementImpl extends ElementImpl
implements CompilationUnitElement {
/**
* The context in which this unit is resynthesized, or `null` if the
@@ -3347,6 +3347,17 @@ 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++) {
@@ -4171,8 +4182,7 @@ abstract class ExecutableElementImpl extends ElementImpl
/**
* A concrete implementation of an [ExportElement].
*/
-class ExportElementImpl extends UriReferencedElementImpl
- implements ExportElement {
+class ExportElementImpl extends ElementImpl implements ExportElement {
/**
* The unlinked representation of the export in the summary.
*/
@@ -4231,8 +4241,11 @@ class ExportElementImpl extends UriReferencedElementImpl
@override
LibraryElement get exportedLibrary {
if (_unlinkedExportNonPublic != null && _exportedLibrary == null) {
+ _selectedUri ??= _selectUri(
+ _unlinkedExportPublic.uri, _unlinkedExportPublic.configurations);
LibraryElementImpl library = enclosingElement as LibraryElementImpl;
- _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri);
+ _exportedLibrary =
+ library.resynthesizerContext.buildExportedLibrary(_selectedUri);
}
return _exportedLibrary;
}
@@ -4273,49 +4286,6 @@ class ExportElementImpl extends UriReferencedElementImpl
}
@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
@@ -5489,8 +5459,7 @@ class HideElementCombinatorImpl implements HideElementCombinator {
/**
* A concrete implementation of an [ImportElement].
*/
-class ImportElementImpl extends UriReferencedElementImpl
- implements ImportElement {
+class ImportElementImpl extends ElementImpl implements ImportElement {
/**
* The unlinked representation of the import in the summary.
*/
@@ -5525,11 +5494,6 @@ class ImportElementImpl extends UriReferencedElementImpl
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.
*/
@@ -5665,58 +5629,6 @@ class ImportElementImpl extends UriReferencedElementImpl
}
@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
@@ -9165,89 +9077,6 @@ 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

Powered by Google App Engine
This is Rietveld 408576698