| 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 |
| 11 #import('dart:coreimpl'); | 11 #import('dart:coreimpl'); |
| 12 #import('dart:io'); | 12 #import('dart:io'); |
| 13 | 13 |
| 14 // TODO(rnystrom): Use "package:" URL (#4968). | 14 // TODO(rnystrom): Use "package:" URL (#4968). |
| 15 #import('../../pkg/dartdoc/lib/dartdoc.dart'); | 15 #import('../../pkg/dartdoc/lib/dartdoc.dart'); |
| 16 #import('../../pkg/dartdoc/lib/mirrors.dart'); | 16 #import('../../pkg/dartdoc/lib/mirrors.dart'); |
| 17 #import('../../pkg/dartdoc/lib/mirrors_util.dart'); | 17 #import('../../pkg/dartdoc/lib/mirrors_util.dart'); |
| 18 | 18 |
| 19 // TODO(amouravski): There is currently magic that looks at dart:* libraries |
| 20 // rather than the declared library names. This changed due to recent syntax |
| 21 // changes. We should only need to look at the library 'html'. |
| 19 const HTML_LIBRARY_NAME = 'dart:html'; | 22 const HTML_LIBRARY_NAME = 'dart:html'; |
| 23 const HTML_DECLARED_NAME = 'html'; |
| 20 | 24 |
| 21 /** | 25 /** |
| 22 * A class for computing a many-to-many mapping between the types and | 26 * A class for computing a many-to-many mapping between the types and |
| 23 * members in `dart:html` and the MDN DOM types. This mapping is | 27 * members in `dart:html` and the MDN DOM types. This mapping is |
| 24 * based on two indicators: | 28 * based on two indicators: |
| 25 * | 29 * |
| 26 * 1. Auto-detected wrappers. Most `dart:html` types correspond | 30 * 1. Auto-detected wrappers. Most `dart:html` types correspond |
| 27 * straightforwardly to a single `@domName` type, and | 31 * straightforwardly to a single `@domName` type, and |
| 28 * have the same name. In addition, most `dart:html` methods | 32 * have the same name. In addition, most `dart:html` methods |
| 29 * just call a single `@domName` method. This class | 33 * just call a single `@domName` method. This class |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 89 } |
| 86 } | 90 } |
| 87 | 91 |
| 88 /** | 92 /** |
| 89 * Computes the `@domName` to `dart:html` mapping, and | 93 * Computes the `@domName` to `dart:html` mapping, and |
| 90 * places it in [htmlToDom] and [htmlTypesToDom]. Before this is run, dart2js | 94 * places it in [htmlToDom] and [htmlTypesToDom]. Before this is run, dart2js |
| 91 * should be initialized (via [parseOptions] and [initializeWorld]) and | 95 * should be initialized (via [parseOptions] and [initializeWorld]) and |
| 92 * [HtmlDiff.initialize] should be called. | 96 * [HtmlDiff.initialize] should be called. |
| 93 */ | 97 */ |
| 94 void run() { | 98 void run() { |
| 95 LibraryMirror htmlLib = _mirrors.libraries[HTML_LIBRARY_NAME]; | 99 LibraryMirror htmlLib = _mirrors.libraries[HTML_DECLARED_NAME]; |
| 96 if (htmlLib === null) { | 100 if (htmlLib === null) { |
| 97 warn('Could not find $HTML_LIBRARY_NAME'); | 101 warn('Could not find $HTML_LIBRARY_NAME'); |
| 98 return; | 102 return; |
| 99 } | 103 } |
| 100 for (InterfaceMirror htmlType in htmlLib.types.getValues()) { | 104 for (InterfaceMirror htmlType in htmlLib.types.getValues()) { |
| 101 final domTypes = htmlToDomTypes(htmlType); | 105 final domTypes = htmlToDomTypes(htmlType); |
| 102 if (domTypes.isEmpty()) continue; | 106 if (domTypes.isEmpty()) continue; |
| 103 | 107 |
| 104 htmlTypesToDom.putIfAbsent(htmlType.qualifiedName, | 108 htmlTypesToDom.putIfAbsent(htmlType.qualifiedName, |
| 105 () => new Set()).addAll(domTypes); | 109 () => new Set()).addAll(domTypes); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 Map<String, String> _getTags(String comment) { | 229 Map<String, String> _getTags(String comment) { |
| 226 if (comment == null) return const <String, String>{}; | 230 if (comment == null) return const <String, String>{}; |
| 227 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); | 231 final re = const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"); |
| 228 final tags = <String, String>{}; | 232 final tags = <String, String>{}; |
| 229 for (var m in re.allMatches(comment.trim())) { | 233 for (var m in re.allMatches(comment.trim())) { |
| 230 tags[m[1]] = m[2]; | 234 tags[m[1]] = m[2]; |
| 231 } | 235 } |
| 232 return tags; | 236 return tags; |
| 233 } | 237 } |
| 234 } | 238 } |
| OLD | NEW |