| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 library kernel.canonical_name; | 4 library kernel.canonical_name; |
| 5 | 5 |
| 6 import 'ast.dart'; | 6 import 'ast.dart'; |
| 7 | 7 |
| 8 /// A string sequence that identifies a library, class, or member. | 8 /// A string sequence that identifies a library, class, or member. |
| 9 /// | 9 /// |
| 10 /// Canonical names are organized in a prefix tree. Each node knows its | 10 /// Canonical names are organized in a prefix tree. Each node knows its |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 CanonicalName getChildFromMember(Member member) { | 102 CanonicalName getChildFromMember(Member member) { |
| 103 return getChild(getMemberQualifier(member)) | 103 return getChild(getMemberQualifier(member)) |
| 104 .getChildFromQualifiedName(member.name); | 104 .getChildFromQualifiedName(member.name); |
| 105 } | 105 } |
| 106 | 106 |
| 107 CanonicalName getChildFromTypedef(Typedef typedef_) { | 107 CanonicalName getChildFromTypedef(Typedef typedef_) { |
| 108 return getChild('@typedefs').getChild(typedef_.name); | 108 return getChild('@typedefs').getChild(typedef_.name); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void removeChild(String name) { |
| 112 _children?.remove(name); |
| 113 } |
| 114 |
| 111 void bindTo(Reference target) { | 115 void bindTo(Reference target) { |
| 112 if (reference == target) return; | 116 if (reference == target) return; |
| 113 if (reference != null) { | 117 if (reference != null) { |
| 114 throw '$this is already bound'; | 118 throw '$this is already bound'; |
| 115 } | 119 } |
| 116 if (target.canonicalName != null) { | 120 if (target.canonicalName != null) { |
| 117 throw 'Cannot bind $this to ${target.node}, target is already bound to ' | 121 throw 'Cannot bind $this to ${target.node}, target is already bound to ' |
| 118 '${target.canonicalName}'; | 122 '${target.canonicalName}'; |
| 119 } | 123 } |
| 120 target.canonicalName = this; | 124 target.canonicalName = this; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 150 } | 154 } |
| 151 if (member is Field) { | 155 if (member is Field) { |
| 152 return '@fields'; | 156 return '@fields'; |
| 153 } | 157 } |
| 154 if (member is Constructor) { | 158 if (member is Constructor) { |
| 155 return '@constructors'; | 159 return '@constructors'; |
| 156 } | 160 } |
| 157 throw 'Unexpected member: $member'; | 161 throw 'Unexpected member: $member'; |
| 158 } | 162 } |
| 159 } | 163 } |
| OLD | NEW |