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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 var extension = path.extension(uriString); | 69 var extension = path.extension(uriString); |
70 if (extension == '.html') { | 70 if (extension == '.html') { |
71 return new HtmlSourceNode(this, uri, source); | 71 return new HtmlSourceNode(this, uri, source); |
72 } else if (extension == '.dart' || uriString.startsWith('dart:')) { | 72 } else if (extension == '.dart' || uriString.startsWith('dart:')) { |
73 return new DartSourceNode(this, uri, source); | 73 return new DartSourceNode(this, uri, source); |
74 } else { | 74 } else { |
75 return new ResourceSourceNode(this, uri, source); | 75 return new ResourceSourceNode(this, uri, source); |
76 } | 76 } |
77 }); | 77 }); |
78 } | 78 } |
| 79 |
| 80 List<String> get resources => _options.resources; |
79 } | 81 } |
80 | 82 |
81 /// A node in the import graph representing a source file. | 83 /// A node in the import graph representing a source file. |
82 abstract class SourceNode { | 84 abstract class SourceNode { |
83 final SourceGraph graph; | 85 final SourceGraph graph; |
84 | 86 |
85 /// Resolved URI for this node. | 87 /// Resolved URI for this node. |
86 final Uri uri; | 88 final Uri uri; |
87 | 89 |
88 /// Resolved source from the analyzer. We let the analyzer internally track | 90 /// Resolved source from the analyzer. We let the analyzer internally track |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 193 } |
192 if (node != null) newScripts.add(node); | 194 if (node != null) newScripts.add(node); |
193 } | 195 } |
194 | 196 |
195 if (!_same(newScripts, scripts)) { | 197 if (!_same(newScripts, scripts)) { |
196 structureChanged = true; | 198 structureChanged = true; |
197 scripts = newScripts; | 199 scripts = newScripts; |
198 } | 200 } |
199 | 201 |
200 var newResources = new Set<ResourceSourceNode>(); | 202 var newResources = new Set<ResourceSourceNode>(); |
| 203 for (var resource in graph.resources) { |
| 204 newResources.add(graph.nodeFromUri(uri.resolve(resource))); |
| 205 } |
201 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { | 206 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { |
202 newResources | 207 newResources |
203 .add(graph.nodeFromUri(uri.resolve(tag.attributes['href']))); | 208 .add(graph.nodeFromUri(uri.resolve(tag.attributes['href']))); |
204 } | 209 } |
205 for (var tag in document.querySelectorAll('img')) { | 210 for (var tag in document.querySelectorAll('img')) { |
206 newResources.add(graph.nodeFromUri(uri.resolve(tag.attributes['src']))); | 211 newResources.add(graph.nodeFromUri(uri.resolve(tag.attributes['src']))); |
207 } | 212 } |
208 if (!_same(newResources, resources)) { | 213 if (!_same(newResources, resources)) { |
209 structureChanged = true; | 214 structureChanged = true; |
210 resources = newResources; | 215 resources = newResources; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 'dart._interceptors', | 516 'dart._interceptors', |
512 'dart._native_typed_data', | 517 'dart._native_typed_data', |
513 */ | 518 */ |
514 ]; | 519 ]; |
515 | 520 |
516 /// Runtime files added to applications when running in server mode. | 521 /// Runtime files added to applications when running in server mode. |
517 final runtimeFilesForServerMode = new List<String>.from(defaultRuntimeFiles) | 522 final runtimeFilesForServerMode = new List<String>.from(defaultRuntimeFiles) |
518 ..addAll(const ['messages_widget.js', 'messages.css']); | 523 ..addAll(const ['messages_widget.js', 'messages.css']); |
519 | 524 |
520 final _log = new Logger('dev_compiler.dependency_graph'); | 525 final _log = new Logger('dev_compiler.dependency_graph'); |
OLD | NEW |