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

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

Issue 2353433002: Use configurations and declared variables to select import/export URIs during prelinking. (Closed)
Patch Set: Cache selected URI. Created 4 years, 3 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d465b405556fad6a281fb6302d3840935c2c43ba..bca9a6e75f68d5df21d482a92cc4b6c2e75bcb5b 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -4003,6 +4003,11 @@ class ExportElementImpl extends UriReferencedElementImpl
List<NamespaceCombinator> _combinators;
/**
+ * The URI that was selected based on the [context] declared variables.
+ */
+ String _selectedUri;
+
+ /**
* Initialize a newly created export element at the given [offset].
*/
ExportElementImpl(int offset)
@@ -4035,8 +4040,7 @@ class ExportElementImpl extends UriReferencedElementImpl
LibraryElement get exportedLibrary {
if (_unlinkedExportNonPublic != null && _exportedLibrary == null) {
LibraryElementImpl library = enclosingElement as LibraryElementImpl;
- _exportedLibrary = library.resynthesizerContext
- .buildExportedLibrary(_unlinkedExportPublic.uri);
+ _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri);
}
return _exportedLibrary;
}
@@ -4078,7 +4082,8 @@ class ExportElementImpl extends UriReferencedElementImpl
@override
String get uri {
if (_unlinkedExportPublic != null) {
- return _unlinkedExportPublic.uri;
+ return _selectedUri ??= _selectUri(
+ _unlinkedExportPublic.uri, _unlinkedExportPublic.configurations);
}
return super.uri;
}
@@ -4867,6 +4872,11 @@ 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.
*/
@@ -5006,7 +5016,8 @@ class ImportElementImpl extends UriReferencedElementImpl
if (_unlinkedImport.isImplicit) {
return null;
}
- return _unlinkedImport.uri;
+ return _selectedUri ??=
+ _selectUri(_unlinkedImport.uri, _unlinkedImport.configurations);
}
return super.uri;
}
@@ -8202,6 +8213,17 @@ abstract class UriReferencedElementImpl extends ElementImpl
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;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698