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

Side by Side Diff: utils/apidoc/html_diff.dart

Issue 10779010: Parameters with function types supported + Added features in mirrors implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + mdn bug fixed. Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 28 matching lines...) Expand all
39 * (e.g. `createElement`). Unqualified member names are assumed to 39 * (e.g. `createElement`). Unqualified member names are assumed to
40 * refer to members of one of the corresponding `dart:dom_deprecated` 40 * refer to members of one of the corresponding `dart:dom_deprecated`
41 * types. 41 * types.
42 */ 42 */
43 class HtmlDiff { 43 class HtmlDiff {
44 /** A map from `dart:dom_deprecated` members to corresponding 44 /** A map from `dart:dom_deprecated` members to corresponding
45 * `dart:html` members. */ 45 * `dart:html` members. */
46 final Map<MemberMirror, Set<MemberMirror>> domToHtml; 46 final Map<MemberMirror, Set<MemberMirror>> domToHtml;
47 47
48 /** A map from `dart:html` members to corresponding 48 /** A map from `dart:html` members to corresponding
49 * `dart:dom_deprecated` members. */ 49 * `dart:dom_deprecated` members.
50 final Map<MemberMirror, Set<MemberMirror>> htmlToDom; 50 * TODO(johnniwinther): We use qualified names as keys, since mirrors
51 * (currently) are not equal between different mirror systems.
52 */
53 final Map<String, Set<MemberMirror>> htmlToDom;
51 54
52 /** A map from `dart:dom_deprecated` types to corresponding 55 /** A map from `dart:dom_deprecated` types to corresponding
53 * `dart:html` types. 56 * `dart:html` types.
54 * TODO(johnniwinther): We use qualified names as keys, since mirrors 57 * TODO(johnniwinther): We use qualified names as keys, since mirrors
55 * (currently) are not equal between different mirror systems. 58 * (currently) are not equal between different mirror systems.
56 */ 59 */
57 final Map<String, Set<InterfaceMirror>> domTypesToHtml; 60 final Map<String, Set<InterfaceMirror>> domTypesToHtml;
58 61
59 /** A map from `dart:html` types to corresponding 62 /** A map from `dart:html` types to corresponding
60 * `dart:dom_deprecated` types. 63 * `dart:dom_deprecated` types.
(...skipping 20 matching lines...) Expand all
81 const <String>['dart:dom_deprecated', 'dart:html'], libDir); 84 const <String>['dart:dom_deprecated', 'dart:html'], libDir);
82 _mirrors = _compilation.mirrors(); 85 _mirrors = _compilation.mirrors();
83 86
84 // Find 'dart:dom_deprecated' by its library tag 'dom'. 87 // Find 'dart:dom_deprecated' by its library tag 'dom'.
85 dom = findMirror(_mirrors.libraries(), 'dom'); 88 dom = findMirror(_mirrors.libraries(), 'dom');
86 } 89 }
87 90
88 HtmlDiff([bool printWarnings = false]) : 91 HtmlDiff([bool printWarnings = false]) :
89 _printWarnings = printWarnings, 92 _printWarnings = printWarnings,
90 domToHtml = new Map<MemberMirror, Set<MemberMirror>>(), 93 domToHtml = new Map<MemberMirror, Set<MemberMirror>>(),
91 htmlToDom = new Map<MemberMirror, Set<MemberMirror>>(), 94 htmlToDom = new Map<String, Set<MemberMirror>>(),
92 domTypesToHtml = new Map<String, Set<InterfaceMirror>>(), 95 domTypesToHtml = new Map<String, Set<InterfaceMirror>>(),
93 htmlTypesToDom = new Map<String, Set<InterfaceMirror>>(), 96 htmlTypesToDom = new Map<String, Set<InterfaceMirror>>(),
94 comments = new CommentMap(); 97 comments = new CommentMap();
95 98
96 void warn(String s) { 99 void warn(String s) {
97 if (_printWarnings) { 100 if (_printWarnings) {
98 print('Warning: $s'); 101 print('Warning: $s');
99 } 102 }
100 } 103 }
101 104
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 */ 138 */
136 void _addMemberDiff(MemberMirror htmlMember, List<TypeMirror> domTypes) { 139 void _addMemberDiff(MemberMirror htmlMember, List<TypeMirror> domTypes) {
137 var domMembers = htmlToDomMembers(htmlMember, domTypes); 140 var domMembers = htmlToDomMembers(htmlMember, domTypes);
138 if (htmlMember == null && !domMembers.isEmpty()) { 141 if (htmlMember == null && !domMembers.isEmpty()) {
139 warn('dart:html member ' 142 warn('dart:html member '
140 '${htmlMember.surroundingDeclaration().simpleName()}.' 143 '${htmlMember.surroundingDeclaration().simpleName()}.'
141 '${htmlMember.simpleName()} has no corresponding dart:html member.'); 144 '${htmlMember.simpleName()} has no corresponding dart:html member.');
142 } 145 }
143 146
144 if (htmlMember == null) return; 147 if (htmlMember == null) return;
145 if (!domMembers.isEmpty()) htmlToDom[htmlMember] = domMembers; 148 if (!domMembers.isEmpty()) {
149 htmlToDom[htmlMember.qualifiedName()] = domMembers;
150 }
146 domMembers.forEach((m) => 151 domMembers.forEach((m) =>
147 domToHtml.putIfAbsent(m, () => new Set()).add(htmlMember)); 152 domToHtml.putIfAbsent(m, () => new Set()).add(htmlMember));
148 } 153 }
149 154
150 /** 155 /**
151 * Returns the `dart:dom_deprecated` [Type]s that correspond to 156 * Returns the `dart:dom_deprecated` [Type]s that correspond to
152 * [htmlType] from `dart:html`. This can be the empty list if no 157 * [htmlType] from `dart:html`. This can be the empty list if no
153 * correspondence is found. 158 * correspondence is found.
154 */ 159 */
155 List<InterfaceMirror> htmlToDomTypes(InterfaceMirror htmlType) { 160 List<InterfaceMirror> htmlToDomTypes(InterfaceMirror htmlType) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 Map<String, String> _getTags(String comment) { 273 Map<String, String> _getTags(String comment) {
269 if (comment == null) return const <String>{}; 274 if (comment == null) return const <String>{};
270 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); 275 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)");
271 final tags = <String>{}; 276 final tags = <String>{};
272 for (var m in re.allMatches(comment.trim())) { 277 for (var m in re.allMatches(comment.trim())) {
273 tags[m[1]] = m[2]; 278 tags[m[1]] = m[2];
274 } 279 }
275 return tags; 280 return tags;
276 } 281 }
277 } 282 }
OLDNEW
« lib/dartdoc/mirrors/dart2js_mirror.dart ('K') | « utils/apidoc/apidoc.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698