OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Tracks the shape of the import/export graph and dependencies between files. | 5 /// Tracks the shape of the import/export graph and dependencies between files. |
6 library dev_compiler.src.dependency_graph; | 6 library dev_compiler.src.dependency_graph; |
7 | 7 |
8 import 'dart:collection' show HashSet; | 8 import 'dart:collection' show HashSet; |
9 | 9 |
10 import 'package:analyzer/analyzer.dart' show parseDirectives; | 10 import 'package:analyzer/analyzer.dart' show parseDirectives; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 /// A node representing an entry HTML source file. | 149 /// A node representing an entry HTML source file. |
150 class HtmlSourceNode extends SourceNode { | 150 class HtmlSourceNode extends SourceNode { |
151 /// Resources included by default on any application. | 151 /// Resources included by default on any application. |
152 final runtimeDeps; | 152 final runtimeDeps; |
153 | 153 |
154 /// Libraries referred to via script tags. | 154 /// Libraries referred to via script tags. |
155 Set<DartSourceNode> scripts = new Set<DartSourceNode>(); | 155 Set<DartSourceNode> scripts = new Set<DartSourceNode>(); |
156 | 156 |
157 /// Link-rel stylesheets and images. | 157 /// Link-rel stylesheets, images, and other specified files. |
158 Set<ResourceSourceNode> resources = new Set<ResourceSourceNode>(); | 158 Set<SourceNode> resources = new Set<SourceNode>(); |
159 | 159 |
160 @override | 160 @override |
161 Iterable<SourceNode> get allDeps => | 161 Iterable<SourceNode> get allDeps => |
162 [scripts, resources, runtimeDeps].expand((e) => e); | 162 [scripts, resources, runtimeDeps].expand((e) => e); |
163 | 163 |
164 @override | 164 @override |
165 Iterable<SourceNode> get depsWithoutParts => allDeps; | 165 Iterable<SourceNode> get depsWithoutParts => allDeps; |
166 | 166 |
167 /// Parsed document, updated whenever [update] is invoked. | 167 /// Parsed document, updated whenever [update] is invoked. |
168 Document document; | 168 Document document; |
(...skipping 23 matching lines...) Expand all Loading... |
192 _reportError(graph, 'Script file $src not found', script); | 192 _reportError(graph, 'Script file $src not found', script); |
193 } | 193 } |
194 if (node != null) newScripts.add(node); | 194 if (node != null) newScripts.add(node); |
195 } | 195 } |
196 | 196 |
197 if (!_same(newScripts, scripts)) { | 197 if (!_same(newScripts, scripts)) { |
198 structureChanged = true; | 198 structureChanged = true; |
199 scripts = newScripts; | 199 scripts = newScripts; |
200 } | 200 } |
201 | 201 |
202 var newResources = new Set<ResourceSourceNode>(); | 202 var newResources = new Set<SourceNode>(); |
203 for (var resource in graph.resources) { | 203 for (var resource in graph.resources) { |
204 newResources.add(graph.nodeFromUri(uri.resolve(resource))); | 204 newResources.add(graph.nodeFromUri(uri.resolve(resource))); |
205 } | 205 } |
206 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { | 206 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { |
207 newResources | 207 newResources |
208 .add(graph.nodeFromUri(uri.resolve(tag.attributes['href']))); | 208 .add(graph.nodeFromUri(uri.resolve(tag.attributes['href']))); |
209 } | 209 } |
210 for (var tag in document.querySelectorAll('img')) { | 210 for (var tag in document.querySelectorAll('img')) { |
211 newResources.add(graph.nodeFromUri(uri.resolve(tag.attributes['src']))); | 211 newResources.add(graph.nodeFromUri(uri.resolve(tag.attributes['src']))); |
212 } | 212 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 'dart._interceptors', | 516 'dart._interceptors', |
517 'dart._native_typed_data', | 517 'dart._native_typed_data', |
518 */ | 518 */ |
519 ]; | 519 ]; |
520 | 520 |
521 /// Runtime files added to applications when running in server mode. | 521 /// Runtime files added to applications when running in server mode. |
522 final runtimeFilesForServerMode = new List<String>.from(defaultRuntimeFiles) | 522 final runtimeFilesForServerMode = new List<String>.from(defaultRuntimeFiles) |
523 ..addAll(const ['messages_widget.js', 'messages.css']); | 523 ..addAll(const ['messages_widget.js', 'messages.css']); |
524 | 524 |
525 final _log = new Logger('dev_compiler.dependency_graph'); | 525 final _log = new Logger('dev_compiler.dependency_graph'); |
OLD | NEW |