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 * 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 info; | 9 library info; |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 * Information for any library-like input. We consider each HTML file a library, | 154 * Information for any library-like input. We consider each HTML file a library, |
155 * and each component declaration a library as well. Hence we use this as a base | 155 * and each component declaration a library as well. Hence we use this as a base |
156 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components | 156 * class for both [FileInfo] and [ComponentInfo]. Both HTML files and components |
157 * can have .dart code provided by the user for top-level user scripts and | 157 * can have .dart code provided by the user for top-level user scripts and |
158 * component-level behavior code. This code can either be inlined in the HTML | 158 * component-level behavior code. This code can either be inlined in the HTML |
159 * file or included in a script tag with the "src" attribute. | 159 * file or included in a script tag with the "src" attribute. |
160 */ | 160 */ |
161 abstract class LibraryInfo { | 161 abstract class LibraryInfo { |
162 | 162 |
163 /** Whether there is any code associated with the page/component. */ | 163 /** Whether there is any code associated with the page/component. */ |
164 bool get codeAttached => inlinedCode != null || externalFile != null; | 164 bool get codeAttached => userCode != null || externalFile != null; |
165 | 165 |
166 /** | 166 /** |
167 * The actual code, either inlined or from an external file, or `null` if none | 167 * The actual code, either inlined or from an external file, or `null` if none |
168 * was defined. | 168 * was defined. |
169 */ | 169 */ |
170 DartCodeInfo userCode; | 170 DartCodeInfo userCode; |
171 | 171 |
172 /** The inlined code, if any. */ | |
173 String inlinedCode; | |
174 | |
175 /** The name of the file sourced in a script tag, if any. */ | 172 /** The name of the file sourced in a script tag, if any. */ |
176 Path externalFile; | 173 Path externalFile; |
177 | 174 |
178 /** Info asscociated with [externalFile], if any. */ | 175 /** Info asscociated with [externalFile], if any. */ |
179 FileInfo externalCode; | 176 FileInfo externalCode; |
180 | 177 |
| 178 /** |
| 179 * The inverse of [externalCode]. If this .dart file was imported via a script |
| 180 * tag, this refers to the HTML file that imported it. |
| 181 */ |
| 182 FileInfo htmlFile; |
| 183 |
181 /** File where the top-level code was defined. */ | 184 /** File where the top-level code was defined. */ |
182 Path get inputPath; | 185 Path get inputPath; |
183 | 186 |
184 /** | 187 /** |
185 * Name of the file that will hold any generated Dart code for this library | 188 * Name of the file that will hold any generated Dart code for this library |
186 * unit. | 189 * unit. |
187 */ | 190 */ |
188 String _getOutputFilename(NameMangler mangle); | 191 String _getOutputFilename(NameMangler mangle); |
189 | 192 |
| 193 /** This is used in transforming Dart code to track modified files. */ |
| 194 bool modified = false; |
| 195 |
| 196 /** |
| 197 * This is used in transforming Dart code to compute files that reference |
| 198 * [modified] files. |
| 199 */ |
| 200 List<FileInfo> referencedBy = []; |
| 201 |
190 /** | 202 /** |
191 * Components used within this library unit. For [FileInfo] these are | 203 * Components used within this library unit. For [FileInfo] these are |
192 * components used directly in the page. For [ComponentInfo] these are | 204 * components used directly in the page. For [ComponentInfo] these are |
193 * components used within their shadowed template. | 205 * components used within their shadowed template. |
194 */ | 206 */ |
195 final Map<ComponentInfo, bool> usedComponents = | 207 final Map<ComponentInfo, bool> usedComponents = |
196 new LinkedHashMap<ComponentInfo, bool>(); | 208 new LinkedHashMap<ComponentInfo, bool>(); |
197 } | 209 } |
198 | 210 |
199 /** Information extracted at the file-level. */ | 211 /** Information extracted at the file-level. */ |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 /** Library qualified identifier, if any. */ | 641 /** Library qualified identifier, if any. */ |
630 final String libraryName; | 642 final String libraryName; |
631 | 643 |
632 /** Library which the code is part-of, if any. */ | 644 /** Library which the code is part-of, if any. */ |
633 final String partOf; | 645 final String partOf; |
634 | 646 |
635 /** Declared imports, exports, and parts. */ | 647 /** Declared imports, exports, and parts. */ |
636 final List<DartDirectiveInfo> directives; | 648 final List<DartDirectiveInfo> directives; |
637 | 649 |
638 /** The rest of the code. */ | 650 /** The rest of the code. */ |
639 final String code; | 651 String code; |
640 | 652 |
641 DartCodeInfo(this.libraryName, this.partOf, this.directives, this.code); | 653 DartCodeInfo(this.libraryName, this.partOf, this.directives, this.code); |
642 } | 654 } |
643 | 655 |
644 /** Information about a single import/export/part directive. */ | 656 /** Information about a single import/export/part directive. */ |
645 class DartDirectiveInfo { | 657 class DartDirectiveInfo { |
646 /** Directive's label: import, export, or part. */ | 658 /** Directive's label: import, export, or part. */ |
647 String label; | 659 String label; |
648 | 660 |
649 /** Referenced uri being imported, exported, or included by a part. */ | 661 /** Referenced uri being imported, exported, or included by a part. */ |
650 String uri; | 662 String uri; |
651 | 663 |
652 /** Prefix used for imports, if any. */ | 664 /** Prefix used for imports, if any. */ |
653 String prefix; | 665 String prefix; |
654 | 666 |
655 /** Hidden identifiers. */ | 667 /** Hidden identifiers. */ |
656 List<String> hide; | 668 List<String> hide; |
657 | 669 |
658 /** Shown identifiers. */ | 670 /** Shown identifiers. */ |
659 List<String> show; | 671 List<String> show; |
660 | 672 |
| 673 /** True if this directive should refer to a generated file. */ |
| 674 bool generated = false; |
| 675 |
661 DartDirectiveInfo(this.label, this.uri, [this.prefix, this.hide, this.show]); | 676 DartDirectiveInfo(this.label, this.uri, [this.prefix, this.hide, this.show]); |
662 } | 677 } |
663 | 678 |
664 | 679 |
665 /** | 680 /** |
666 * Find ElementInfo that associated with a particular DOM node. | 681 * Find ElementInfo that associated with a particular DOM node. |
667 * Used by [ElementInfo.query]. | 682 * Used by [ElementInfo.query]. |
668 */ | 683 */ |
669 class _QueryInfo extends InfoVisitor { | 684 class _QueryInfo extends InfoVisitor { |
670 final String _tagName; | 685 final String _tagName; |
671 | 686 |
672 _QueryInfo(this._tagName); | 687 _QueryInfo(this._tagName); |
673 | 688 |
674 visitElementInfo(ElementInfo info) { | 689 visitElementInfo(ElementInfo info) { |
675 if (info.node.tagName == _tagName) { | 690 if (info.node.tagName == _tagName) { |
676 return info; | 691 return info; |
677 } | 692 } |
678 | 693 |
679 return super.visitElementInfo(info); | 694 return super.visitElementInfo(info); |
680 } | 695 } |
681 | 696 |
682 visitChildren(ElementInfo info) { | 697 visitChildren(ElementInfo info) { |
683 for (var child in info.children) { | 698 for (var child in info.children) { |
684 var result = visit(child); | 699 var result = visit(child); |
685 if (result != null) return result; | 700 if (result != null) return result; |
686 } | 701 } |
687 return null; | 702 return null; |
688 } | 703 } |
689 } | 704 } |
OLD | NEW |