OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 * Datatypes holding information extracted by the analyzer and used by later | 6 * Datatypes holding information extracted by the analyzer and used by later |
7 * phases of the compiler. | 7 * phases of the compiler. |
8 */ | 8 */ |
9 library web_ui.src.info; | 9 library web_ui.src.info; |
10 | 10 |
11 import 'dart:collection' show SplayTreeMap, LinkedHashMap; | 11 import 'dart:collection' show SplayTreeMap, LinkedHashMap; |
12 | 12 |
13 import 'package:analyzer_experimental/src/generated/ast.dart'; | 13 import 'package:analyzer_experimental/src/generated/ast.dart'; |
14 import 'package:csslib/parser.dart' as css; | |
15 import 'package:csslib/visitor.dart'; | 14 import 'package:csslib/visitor.dart'; |
16 import 'package:html5lib/dom.dart'; | 15 import 'package:html5lib/dom.dart'; |
17 import 'package:source_maps/span.dart' show Span; | 16 import 'package:source_maps/span.dart' show Span; |
18 | 17 |
19 import 'dart_parser.dart' show DartCodeInfo; | 18 import 'dart_parser.dart' show DartCodeInfo; |
20 import 'files.dart'; | |
21 import 'messages.dart'; | 19 import 'messages.dart'; |
22 import 'summary.dart'; | 20 import 'summary.dart'; |
23 import 'utils.dart'; | 21 import 'utils.dart'; |
24 | 22 |
25 /** | 23 /** |
26 * Information for any library-like input. We consider each HTML file a library, | 24 * Information for any library-like input. We consider each HTML file a library, |
27 * and each component declaration a library as well. Hence we use this as a base | 25 * and each component declaration a library as well. Hence we use this as a base |
28 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components | 26 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components |
29 * can have .dart code provided by the user for top-level user scripts and | 27 * can have .dart code provided by the user for top-level user scripts and |
30 * component-level behavior code. This code can either be inlined in the HTML | 28 * component-level behavior code. This code can either be inlined in the HTML |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 259 } |
262 } | 260 } |
263 | 261 |
264 String toString() => '#<ComponentInfo $tagName ' | 262 String toString() => '#<ComponentInfo $tagName ' |
265 '${inlinedCode != null ? "inline" : "from ${dartCodeUrl.resolvedPath}"}>'; | 263 '${inlinedCode != null ? "inline" : "from ${dartCodeUrl.resolvedPath}"}>'; |
266 } | 264 } |
267 | 265 |
268 /** Base tree visitor for the Analyzer infos. */ | 266 /** Base tree visitor for the Analyzer infos. */ |
269 class InfoVisitor { | 267 class InfoVisitor { |
270 visit(info) { | 268 visit(info) { |
271 if (info == null) return; | 269 if (info == null) return null; |
272 if (info is TemplateInfo) { | 270 if (info is TemplateInfo) { |
273 return visitTemplateInfo(info); | 271 return visitTemplateInfo(info); |
274 } else if (info is ElementInfo) { | 272 } else if (info is ElementInfo) { |
275 return visitElementInfo(info); | 273 return visitElementInfo(info); |
276 } else if (info is TextInfo) { | 274 } else if (info is TextInfo) { |
277 return visitTextInfo(info); | 275 return visitTextInfo(info); |
278 } else if (info is ComponentInfo) { | 276 } else if (info is ComponentInfo) { |
279 return visitComponentInfo(info); | 277 return visitComponentInfo(info); |
280 } else if (info is FileInfo) { | 278 } else if (info is FileInfo) { |
281 return visitFileInfo(info); | 279 return visitFileInfo(info); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return new UrlInfo(url, target, span); | 671 return new UrlInfo(url, target, span); |
674 } | 672 } |
675 | 673 |
676 bool operator ==(UrlInfo other) => | 674 bool operator ==(UrlInfo other) => |
677 url == other.url && resolvedPath == other.resolvedPath; | 675 url == other.url && resolvedPath == other.resolvedPath; |
678 | 676 |
679 int get hashCode => resolvedPath.hashCode; | 677 int get hashCode => resolvedPath.hashCode; |
680 | 678 |
681 String toString() => "#<UrlInfo url: $url, resolvedPath: $resolvedPath>"; | 679 String toString() => "#<UrlInfo url: $url, resolvedPath: $resolvedPath>"; |
682 } | 680 } |
OLD | NEW |