OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 /** | 5 /** |
6 * A script to assist in documenting the difference between the dart:html API | 6 * A script to assist in documenting the difference between the dart:html API |
7 * and the old DOM API. | 7 * and the old DOM API. |
8 */ | 8 */ |
9 library html_diff; | 9 library html_diff; |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 * Returns the `@DomName` type values that correspond to | 149 * Returns the `@DomName` type values that correspond to |
150 * [htmlType] from `dart:html`. This can be the empty list if no | 150 * [htmlType] from `dart:html`. This can be the empty list if no |
151 * correspondence is found. | 151 * correspondence is found. |
152 */ | 152 */ |
153 List<String> htmlToDomTypes(ClassMirror htmlType) { | 153 List<String> htmlToDomTypes(ClassMirror htmlType) { |
154 if (htmlType.simpleName == null) return <String>[]; | 154 if (htmlType.simpleName == null) return <String>[]; |
155 | 155 |
156 final domNameMetadata = findMetadata(htmlType.metadata, 'DomName'); | 156 final domNameMetadata = findMetadata(htmlType.metadata, 'DomName'); |
157 if (domNameMetadata != null) { | 157 if (domNameMetadata != null) { |
158 var domNames = <String>[]; | 158 var domNames = <String>[]; |
159 var tags = deprecatedFutureValue(domNameMetadata.getField('name')); | 159 var names = deprecatedFutureValue(domNameMetadata.getField('name')); |
160 for (var s in tags.reflectee.split(',')) { | 160 for (var s in names.reflectee.split(',')) { |
161 domNames.add(s.trim()); | 161 domNames.add(s.trim()); |
162 } | 162 } |
163 | 163 |
164 if (domNames.length == 1 && domNames[0] == 'none') return <String>[]; | 164 if (domNames.length == 1 && domNames[0] == 'none') return <String>[]; |
165 return domNames; | 165 return domNames; |
166 } | 166 } |
167 return <String>[]; | 167 return <String>[]; |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
171 * Returns the `@DomName` member values that correspond to | 171 * Returns the `@DomName` member values that correspond to |
172 * [htmlMember] from `dart:html`. This can be the empty set if no | 172 * [htmlMember] from `dart:html`. This can be the empty set if no |
173 * correspondence is found. [domTypes] are the | 173 * correspondence is found. [domTypes] are the |
174 * `@DomName` type values that correspond to [htmlMember]'s | 174 * `@DomName` type values that correspond to [htmlMember]'s |
175 * defining type. | 175 * defining type. |
176 */ | 176 */ |
177 Set<String> htmlToDomMembers(MemberMirror htmlMember, List<String> domTypes) { | 177 Set<String> htmlToDomMembers(MemberMirror htmlMember, List<String> domTypes) { |
178 if (htmlMember.isPrivate) return new Set(); | 178 if (htmlMember.isPrivate) return new Set(); |
179 | 179 |
180 final domNameMetadata = findMetadata(htmlMember.metadata, 'DomName'); | 180 final domNameMetadata = findMetadata(htmlMember.metadata, 'DomName'); |
181 if (domNameMetadata != null) { | 181 if (domNameMetadata != null) { |
182 var domNames = <String>[]; | 182 var domNames = <String>[]; |
183 var tags = deprecatedFutureValue(domNameMetadata.getField('name')); | 183 var names = deprecatedFutureValue(domNameMetadata.getField('name')); |
184 for (var s in tags.reflectee.split(',')) { | 184 for (var s in names.reflectee.split(',')) { |
185 domNames.add(s.trim()); | 185 domNames.add(s.trim()); |
186 } | 186 } |
187 | 187 |
188 if (domNames.length == 1 && domNames[0] == 'none') return new Set(); | 188 if (domNames.length == 1 && domNames[0] == 'none') return new Set(); |
189 final members = new Set(); | 189 final members = new Set(); |
190 domNames.forEach((name) { | 190 domNames.forEach((name) { |
191 var nameMembers = _membersFromName(name, domTypes); | 191 var nameMembers = _membersFromName(name, domTypes); |
192 if (nameMembers.isEmpty) { | 192 if (nameMembers.isEmpty) { |
193 if (name.contains('.')) { | 193 if (name.contains('.')) { |
194 warn('no member $name'); | 194 warn('no member $name'); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 return members; | 228 return members; |
229 } | 229 } |
230 | 230 |
231 if (name.split('.').length != 2) { | 231 if (name.split('.').length != 2) { |
232 warn('invalid member name ${name}'); | 232 warn('invalid member name ${name}'); |
233 return new Set(); | 233 return new Set(); |
234 } | 234 } |
235 return new Set.from([name]); | 235 return new Set.from([name]); |
236 } | 236 } |
237 } | 237 } |
OLD | NEW |