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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return name.isPrivate | 97 return name.isPrivate |
98 ? getChildFromUri(name.library.importUri).getChild(name.name) | 98 ? getChildFromUri(name.library.importUri).getChild(name.name) |
99 : getChild(name.name); | 99 : getChild(name.name); |
100 } | 100 } |
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_) { |
| 108 return getChild('@typedefs').getChild(typedef_.name); |
| 109 } |
| 110 |
107 void bindTo(Reference target) { | 111 void bindTo(Reference target) { |
108 if (reference == target) return; | 112 if (reference == target) return; |
109 if (reference != null) { | 113 if (reference != null) { |
110 throw '$this is already bound'; | 114 throw '$this is already bound'; |
111 } | 115 } |
112 if (target.canonicalName != null) { | 116 if (target.canonicalName != null) { |
113 throw 'Cannot bind $this to ${target.node}, target is already bound to ' | 117 throw 'Cannot bind $this to ${target.node}, target is already bound to ' |
114 '${target.canonicalName}'; | 118 '${target.canonicalName}'; |
115 } | 119 } |
116 target.canonicalName = this; | 120 target.canonicalName = this; |
(...skipping 29 matching lines...) Expand all Loading... |
146 } | 150 } |
147 if (member is Field) { | 151 if (member is Field) { |
148 return '@fields'; | 152 return '@fields'; |
149 } | 153 } |
150 if (member is Constructor) { | 154 if (member is Constructor) { |
151 return '@constructors'; | 155 return '@constructors'; |
152 } | 156 } |
153 throw 'Unexpected member: $member'; | 157 throw 'Unexpected member: $member'; |
154 } | 158 } |
155 } | 159 } |
OLD | NEW |