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

Side by Side Diff: client/html/scripts/html_diff.dart

Issue 8947005: Refactor dartdoc into a class. Use method overriding to extend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | client/html/scripts/html_doc.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 /** A map from `dart:html` members to corresponding `dart:dom` members. */ 77 /** A map from `dart:html` members to corresponding `dart:dom` members. */
78 final Map<Member, Set<Member>> htmlToDom; 78 final Map<Member, Set<Member>> htmlToDom;
79 79
80 /** A map from `dart:dom` types to corresponding `dart:html` types. */ 80 /** A map from `dart:dom` types to corresponding `dart:html` types. */
81 final Map<Type, Set<Type>> domTypesToHtml; 81 final Map<Type, Set<Type>> domTypesToHtml;
82 82
83 /** A map from `dart:html` types to corresponding `dart:dom` types. */ 83 /** A map from `dart:html` types to corresponding `dart:dom` types. */
84 final Map<Type, Set<Type>> htmlTypesToDom; 84 final Map<Type, Set<Type>> htmlTypesToDom;
85 85
86 final CommentMap comments;
87
86 /** 88 /**
87 * Perform static initialization of [world]. This should be run before 89 * Perform static initialization of [world]. This should be run before
88 * calling [HtmlDiff.run]. 90 * calling [HtmlDiff.run].
89 */ 91 */
90 static void initialize() { 92 static void initialize() {
91 world.processDartScript('dart:htmlimpl'); 93 world.processDartScript('dart:htmlimpl');
92 world.resolveAll(); 94 world.resolveAll();
93 } 95 }
94 96
95 HtmlDiff() : 97 HtmlDiff() :
96 domToHtml = new Map<Member, Set<Member>>(), 98 domToHtml = new Map<Member, Set<Member>>(),
97 htmlToDom = new Map<Member, Set<Member>>(), 99 htmlToDom = new Map<Member, Set<Member>>(),
98 domTypesToHtml = new Map<Type, Set<Type>>(), 100 domTypesToHtml = new Map<Type, Set<Type>>(),
99 htmlTypesToDom = new Map<Type, Set<Type>>(); 101 htmlTypesToDom = new Map<Type, Set<Type>>(),
102 comments = new CommentMap();
100 103
101 /** 104 /**
102 * Computes the `dart:dom` to `dart:html` mapping, and places it in 105 * Computes the `dart:dom` to `dart:html` mapping, and places it in
103 * [domToHtml], [htmlToDom], [domTypesToHtml], and [htmlTypesToDom]. Before 106 * [domToHtml], [htmlToDom], [domTypesToHtml], and [htmlTypesToDom]. Before
104 * this is run, Frog should be initialized (via [parseOptions] and 107 * this is run, Frog should be initialized (via [parseOptions] and
105 * [initializeWorld]) and [HtmlDiff.initialize] should be called. 108 * [initializeWorld]) and [HtmlDiff.initialize] should be called.
106 */ 109 */
107 void run() { 110 void run() {
108 final htmlLib = world.libraries['dart:htmlimpl']; 111 final htmlLib = world.libraries['dart:htmlimpl'];
109 for (var implType in htmlLib.types.getValues()) { 112 for (var implType in htmlLib.types.getValues()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return htmlType.getMember(implMember.name); 212 return htmlType.getMember(implMember.name);
210 } 213 }
211 } 214 }
212 215
213 /** 216 /**
214 * Returns the `dart:dom` [Type]s that correspond to [htmlType] from 217 * Returns the `dart:dom` [Type]s that correspond to [htmlType] from
215 * `dart:htmlimpl`. This can be the empty list if no correspondence is found. 218 * `dart:htmlimpl`. This can be the empty list if no correspondence is found.
216 */ 219 */
217 List<Type> htmlToDomTypes(Type htmlType) { 220 List<Type> htmlToDomTypes(Type htmlType) {
218 if (htmlType.name == null) return []; 221 if (htmlType.name == null) return [];
219 final tags = _getTags(findComment(htmlType.span)); 222 final tags = _getTags(comments.find(htmlType.span));
220 223
221 if (tags.containsKey('domName')) { 224 if (tags.containsKey('domName')) {
222 var domNames = map(tags['domName'].split(','), (s) => s.trim()); 225 var domNames = map(tags['domName'].split(','), (s) => s.trim());
223 if (domNames.length == 1 && domNames[0] == 'none') return []; 226 if (domNames.length == 1 && domNames[0] == 'none') return [];
224 return map(domNames, (domName) { 227 return map(domNames, (domName) {
225 // DOMWindow is Chrome-specific, so we don't use it in our annotations. 228 // DOMWindow is Chrome-specific, so we don't use it in our annotations.
226 if (domName == 'Window') domName = 'DOMWindow'; 229 if (domName == 'Window') domName = 'DOMWindow';
227 final domType = world.dom.types[domName]; 230 final domType = world.dom.types[domName];
228 if (domType == null) print('Warning: no dart:dom type named $domName'); 231 if (domType == null) print('Warning: no dart:dom type named $domName');
229 return domType; 232 return domType;
(...skipping 16 matching lines...) Expand all
246 } 249 }
247 250
248 /** 251 /**
249 * Returns the `dart:dom` [Member]s that correspond to [htmlMember] from 252 * Returns the `dart:dom` [Member]s that correspond to [htmlMember] from
250 * `dart:htmlimpl`. This can be the empty set if no correspondence is found. 253 * `dart:htmlimpl`. This can be the empty set if no correspondence is found.
251 * [domTypes] are the `dart:dom` [Type]s that correspond to [implMember]'s 254 * [domTypes] are the `dart:dom` [Type]s that correspond to [implMember]'s
252 * defining [Type]. 255 * defining [Type].
253 */ 256 */
254 Set<Member> htmlToDomMembers(Member htmlMember, List<Type> domTypes) { 257 Set<Member> htmlToDomMembers(Member htmlMember, List<Type> domTypes) {
255 if (htmlMember.isPrivate || htmlMember is! MethodMember) return new Set(); 258 if (htmlMember.isPrivate || htmlMember is! MethodMember) return new Set();
256 final tags = _getTags(findComment(htmlMember.span)); 259 final tags = _getTags(comments.find(htmlMember.span));
257 if (tags.containsKey('domName')) { 260 if (tags.containsKey('domName')) {
258 final domNames = map(tags['domName'].split(','), (s) => s.trim()); 261 final domNames = map(tags['domName'].split(','), (s) => s.trim());
259 if (domNames.length == 1 && domNames[0] == 'none') return new Set(); 262 if (domNames.length == 1 && domNames[0] == 'none') return new Set();
260 final members = new Set(); 263 final members = new Set();
261 domNames.forEach((name) { 264 domNames.forEach((name) {
262 var nameMembers = _membersFromName(name, domTypes); 265 var nameMembers = _membersFromName(name, domTypes);
263 if (nameMembers.isEmpty()) { 266 if (nameMembers.isEmpty()) {
264 if (name.contains('.')) { 267 if (name.contains('.')) {
265 print('Warning: no member $name'); 268 print('Warning: no member $name');
266 } else { 269 } else {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 Map<String, String> _getTags(String comment) { 425 Map<String, String> _getTags(String comment) {
423 if (comment == null) return const <String>{}; 426 if (comment == null) return const <String>{};
424 final re = new RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); 427 final re = new RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)");
425 final tags = <String>{}; 428 final tags = <String>{};
426 for (var m in re.allMatches(comment.trim())) { 429 for (var m in re.allMatches(comment.trim())) {
427 tags[m[1]] = m[2]; 430 tags[m[1]] = m[2];
428 } 431 }
429 return tags; 432 return tags;
430 } 433 }
431 } 434 }
OLDNEW
« no previous file with comments | « no previous file | client/html/scripts/html_doc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698