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 polymer.src.info; | 9 library polymer.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 that is global. Roughly corresponds to `window` and `document`. | 24 * Information that is global. Roughly corresponds to `window` and `document`. |
27 */ | 25 */ |
28 class GlobalInfo { | 26 class GlobalInfo { |
29 /** | 27 /** |
30 * Pseudo-element names exposed in a component via a pseudo attribute. | 28 * Pseudo-element names exposed in a component via a pseudo attribute. |
31 * The name is only available from CSS (not Dart code) so they're mangled. | 29 * The name is only available from CSS (not Dart code) so they're mangled. |
32 * The same pseudo-element in different components maps to the same | 30 * The same pseudo-element in different components maps to the same |
33 * mangled name (as the pseudo-element is scoped inside of the component). | 31 * mangled name (as the pseudo-element is scoped inside of the component). |
34 */ | 32 */ |
35 final Map<String, String> pseudoElements = <String, String>{}; | 33 final Map<String, String> pseudoElements = <String, String>{}; |
36 | 34 |
37 /** All components declared in the application. */ | 35 /** All components declared in the application. */ |
38 final Map<String, ComponentInfo> components = new SplayTreeMap(); | 36 final Map<String, ComponentInfo> components = new SplayTreeMap(); |
39 } | 37 } |
40 | 38 |
41 /** | 39 /** |
42 * Information for any library-like input. We consider each HTML file a library, | 40 * Information for any library-like input. We consider each HTML file a library, |
43 * and each component declaration a library as well. Hence we use this as a base | 41 * and each component declaration a library as well. Hence we use this as a base |
44 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components | 42 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components |
45 * can have .dart code provided by the user for top-level user scripts and | 43 * can have .dart code provided by the user for top-level user scripts and |
46 * component-level behavior code. This code can either be inlined in the HTML | 44 * component-level behavior code. This code can either be inlined in the HTML |
47 * file or included in a script tag with the "src" attribute. | 45 * file or included in a script tag with the "src" attribute. |
48 */ | 46 */ |
49 abstract class LibraryInfo extends Hashable implements LibrarySummary { | 47 abstract class LibraryInfo implements LibrarySummary { |
50 | 48 |
51 /** Whether there is any code associated with the page/component. */ | 49 /** Whether there is any code associated with the page/component. */ |
52 bool get codeAttached => inlinedCode != null || externalFile != null; | 50 bool get codeAttached => inlinedCode != null || externalFile != null; |
53 | 51 |
54 /** | 52 /** |
55 * The actual inlined code. Use [userCode] if you want the code from this file | 53 * The actual inlined code. Use [userCode] if you want the code from this file |
56 * or from an external file. | 54 * or from an external file. |
57 */ | 55 */ |
58 DartCodeInfo inlinedCode; | 56 DartCodeInfo inlinedCode; |
59 | 57 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 */ | 184 */ |
187 ComponentSummary extendsComponent; | 185 ComponentSummary extendsComponent; |
188 | 186 |
189 /** The Dart class containing the component's behavior. */ | 187 /** The Dart class containing the component's behavior. */ |
190 String className; | 188 String className; |
191 | 189 |
192 /** The Dart class declaration. */ | 190 /** The Dart class declaration. */ |
193 ClassDeclaration get classDeclaration => _classDeclaration; | 191 ClassDeclaration get classDeclaration => _classDeclaration; |
194 ClassDeclaration _classDeclaration; | 192 ClassDeclaration _classDeclaration; |
195 | 193 |
196 // TODO(terry): Remove once we stop mangling CSS selectors. | |
197 /** CSS selectors scoped. */ | |
198 bool scoped = false; | |
199 | |
200 /** The declaring `<element>` tag. */ | 194 /** The declaring `<element>` tag. */ |
201 final Node element; | 195 final Node element; |
202 | 196 |
203 /** File where this component was defined. */ | 197 /** File where this component was defined. */ |
204 UrlInfo get dartCodeUrl => externalFile != null | 198 UrlInfo get dartCodeUrl => externalFile != null |
205 ? externalFile : declaringFile.inputUrl; | 199 ? externalFile : declaringFile.inputUrl; |
206 | 200 |
207 /** | 201 /** |
208 * True if [tagName] was defined by more than one component. If this happened | 202 * True if [tagName] was defined by more than one component. If this happened |
209 * we will skip over the component. | 203 * we will skip over the component. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 return new UrlInfo(url, target, span); | 321 return new UrlInfo(url, target, span); |
328 } | 322 } |
329 | 323 |
330 bool operator ==(UrlInfo other) => | 324 bool operator ==(UrlInfo other) => |
331 url == other.url && resolvedPath == other.resolvedPath; | 325 url == other.url && resolvedPath == other.resolvedPath; |
332 | 326 |
333 int get hashCode => resolvedPath.hashCode; | 327 int get hashCode => resolvedPath.hashCode; |
334 | 328 |
335 String toString() => "#<UrlInfo url: $url, resolvedPath: $resolvedPath>"; | 329 String toString() => "#<UrlInfo url: $url, resolvedPath: $resolvedPath>"; |
336 } | 330 } |
OLD | NEW |