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

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

Issue 2992053002: Resynthesize combinators for import/export directives from Kernel. (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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.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 b4059812a9e3ae697a622fb654871910ef1cf940..d2ae9f65aef818b9c48dd8aece069bf3f8993304 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -4351,9 +4351,15 @@ class ExportElementImpl extends UriReferencedElementImpl
@override
List<NamespaceCombinator> get combinators {
- if (_unlinkedExportPublic != null && _combinators == null) {
- _combinators = ImportElementImpl
- ._buildCombinators(_unlinkedExportPublic.combinators);
+ if (_combinators == null) {
+ if (_kernel != null) {
+ _combinators =
+ ImportElementImpl._buildCombinatorsForKernel(_kernel.combinators);
+ }
+ if (_unlinkedExportPublic != null) {
+ _combinators = ImportElementImpl
+ ._buildCombinators(_unlinkedExportPublic.combinators);
+ }
}
return _combinators ?? const <NamespaceCombinator>[];
}
@@ -5600,20 +5606,37 @@ class HideElementCombinatorImpl implements HideElementCombinator {
final UnlinkedCombinator _unlinkedCombinator;
/**
+ * The kernel for the element.
+ */
+ final kernel.Combinator _kernel;
+
+ /**
* The names that are not to be made visible in the importing library even if
* they are defined in the imported library.
*/
List<String> _hiddenNames;
- HideElementCombinatorImpl() : _unlinkedCombinator = null;
+ HideElementCombinatorImpl()
+ : _unlinkedCombinator = null,
+ _kernel = null;
/**
* Initialize using the given serialized information.
*/
- HideElementCombinatorImpl.forSerialized(this._unlinkedCombinator);
+ HideElementCombinatorImpl.forSerialized(this._unlinkedCombinator)
+ : _kernel = null;
+
+ /**
+ * Initialize using the given kernel.
+ */
+ HideElementCombinatorImpl.forKernel(this._kernel)
+ : _unlinkedCombinator = null;
@override
List<String> get hiddenNames {
+ if (_kernel != null) {
+ _hiddenNames ??= _kernel.names;
+ }
if (_unlinkedCombinator != null) {
_hiddenNames ??= _unlinkedCombinator.hides.toList(growable: false);
}
@@ -5716,8 +5739,13 @@ class ImportElementImpl extends UriReferencedElementImpl
@override
List<NamespaceCombinator> get combinators {
- if (_unlinkedImport != null && _combinators == null) {
- _combinators = _buildCombinators(_unlinkedImport.combinators);
+ if (_combinators == null) {
+ if (_kernel != null) {
+ _combinators = _buildCombinatorsForKernel(_kernel.combinators);
+ }
+ if (_unlinkedImport != null) {
+ _combinators = _buildCombinators(_unlinkedImport.combinators);
+ }
}
return _combinators ?? const <NamespaceCombinator>[];
}
@@ -5929,6 +5957,24 @@ class ImportElementImpl extends UriReferencedElementImpl
return const <NamespaceCombinator>[];
}
}
+
+ static List<NamespaceCombinator> _buildCombinatorsForKernel(
+ List<kernel.Combinator> unlinkedCombinators) {
+ int length = unlinkedCombinators.length;
+ if (length != 0) {
+ List<NamespaceCombinator> combinators =
+ new List<NamespaceCombinator>(length);
+ for (int i = 0; i < length; i++) {
+ kernel.Combinator unlinkedCombinator = unlinkedCombinators[i];
+ combinators[i] = unlinkedCombinator.isShow
+ ? new ShowElementCombinatorImpl.forKernel(unlinkedCombinator)
+ : new HideElementCombinatorImpl.forKernel(unlinkedCombinator);
+ }
+ return combinators;
+ } else {
+ return const <NamespaceCombinator>[];
+ }
+ }
}
/**
@@ -8968,6 +9014,11 @@ class ShowElementCombinatorImpl implements ShowElementCombinator {
final UnlinkedCombinator _unlinkedCombinator;
/**
+ * The kernel for the element.
+ */
+ final kernel.Combinator _kernel;
+
+ /**
* The names that are to be made visible in the importing library if they are
* defined in the imported library.
*/
@@ -8984,12 +9035,21 @@ class ShowElementCombinatorImpl implements ShowElementCombinator {
*/
int _offset = 0;
- ShowElementCombinatorImpl() : _unlinkedCombinator = null;
+ ShowElementCombinatorImpl()
+ : _unlinkedCombinator = null,
+ _kernel = null;
/**
* Initialize using the given serialized information.
*/
- ShowElementCombinatorImpl.forSerialized(this._unlinkedCombinator);
+ ShowElementCombinatorImpl.forSerialized(this._unlinkedCombinator)
+ : _kernel = null;
+
+ /**
+ * Initialize using the given kernel.
+ */
+ ShowElementCombinatorImpl.forKernel(this._kernel)
+ : _unlinkedCombinator = null;
@override
int get end {
@@ -9019,6 +9079,9 @@ class ShowElementCombinatorImpl implements ShowElementCombinator {
@override
List<String> get shownNames {
+ if (_kernel != null) {
+ _shownNames ??= _kernel.names;
+ }
if (_unlinkedCombinator != null) {
_shownNames ??= _unlinkedCombinator.shows.toList(growable: false);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698