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

Unified Diff: pkg/kernel/lib/canonical_name.dart

Issue 2995773002: When using SDK outline, transplant its names into the name root. (Closed)
Patch Set: Created 3 years, 4 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/kernel/lib/canonical_name.dart
diff --git a/pkg/kernel/lib/canonical_name.dart b/pkg/kernel/lib/canonical_name.dart
index a56c482c23264d8f147c4f5d1f8c2d08833843f3..375453e4c423cb5ac0f42cfb492bf068187d8900 100644
--- a/pkg/kernel/lib/canonical_name.dart
+++ b/pkg/kernel/lib/canonical_name.dart
@@ -57,7 +57,7 @@ import 'ast.dart';
/// The "qualified name" allows a member to have a name that is private to
/// a library other than the one containing that member.
class CanonicalName {
- final CanonicalName parent;
+ CanonicalName _parent;
final String name;
Map<String, CanonicalName> _children;
@@ -68,16 +68,16 @@ class CanonicalName {
/// Temporary index used during serialization.
int index = -1;
- CanonicalName._(this.parent, this.name) {
+ CanonicalName._(this._parent, this.name) {
assert(name != null);
}
- CanonicalName.root()
- : parent = null,
- name = '';
+ CanonicalName.root() : name = '';
bool get isRoot => parent == null;
+ CanonicalName get parent => _parent;
+
Iterable<CanonicalName> get children =>
_children?.values ?? const <CanonicalName>[];
@@ -112,6 +112,13 @@ class CanonicalName {
_children?.remove(name);
}
+ /// Transplant the given [child] into this name.
+ void transplantChild(CanonicalName child) {
+ var map = _children ??= <String, CanonicalName>{};
+ map[child.name] = child;
+ child._parent = this;
+ }
+
void bindTo(Reference target) {
if (reference == target) return;
if (reference != null) {

Powered by Google App Engine
This is Rietveld 408576698