Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: lib/src/server/dependency_graph.dart

Issue 1245013002: some fixes for --strong warnings (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, HashMap; 8 import 'dart:collection' show HashSet, HashMap;
9 9
10 import 'package:analyzer/analyzer.dart' show parseDirectives; 10 import 'package:analyzer/analyzer.dart' show parseDirectives;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 var newScripts = new Set<DartSourceNode>(); 195 var newScripts = new Set<DartSourceNode>();
196 var tags = document.querySelectorAll('script[type="application/dart"]'); 196 var tags = document.querySelectorAll('script[type="application/dart"]');
197 for (var script in tags) { 197 for (var script in tags) {
198 var src = script.attributes['src']; 198 var src = script.attributes['src'];
199 if (src == null) { 199 if (src == null) {
200 _reportError(graph, 'inlined script tags not supported at this time ' 200 _reportError(graph, 'inlined script tags not supported at this time '
201 '(see https://github.com/dart-lang/dart-dev-compiler/issues/54).', 201 '(see https://github.com/dart-lang/dart-dev-compiler/issues/54).',
202 script); 202 script);
203 continue; 203 continue;
204 } 204 }
205 var node = graph.nodeFromUri(uri.resolve(src)); 205 DartSourceNode node = graph.nodeFromUri(uri.resolve(src));
206 if (node == null || !node.source.exists()) { 206 if (node == null || !node.source.exists()) {
207 _reportError(graph, 'Script file $src not found', script); 207 _reportError(graph, 'Script file $src not found', script);
208 } 208 }
209 if (node != null) newScripts.add(node); 209 if (node != null) newScripts.add(node);
210 } 210 }
211 211
212 if (!_same(newScripts, scripts)) { 212 if (!_same(newScripts, scripts)) {
213 structureChanged = true; 213 structureChanged = true;
214 scripts = newScripts; 214 scripts = newScripts;
215 } 215 }
216 216
217 // TODO(jmesserly): simplify the design here. Ideally we wouldn't need 217 // TODO(jmesserly): simplify the design here. Ideally we wouldn't need
218 // to track user-defined CSS, images, etc. Also we don't have a clear 218 // to track user-defined CSS, images, etc. Also we don't have a clear
219 // way to distinguish runtime injected resources, like messages.css, from 219 // way to distinguish runtime injected resources, like messages.css, from
220 // user-defined files. 220 // user-defined files.
221 htmlResourceNodes.clear(); 221 htmlResourceNodes.clear();
222 var newResources = new Set<SourceNode>(); 222 var newResources = new Set<SourceNode>();
223 for (var resource in graph.resources) { 223 for (var resource in graph.resources) {
224 newResources.add(graph.nodeFromUri(uri.resolve(resource))); 224 newResources.add(graph.nodeFromUri(uri.resolve(resource)));
225 } 225 }
226 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { 226 for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) {
227 var res = graph.nodeFromUri(uri.resolve(tag.attributes['href'])); 227 ResourceSourceNode res =
228 graph.nodeFromUri(uri.resolve(tag.attributes['href']));
Leaf 2015/07/22 22:29:15 Is there a rationale behind using the T v = e patt
Jennifer Messerly 2015/07/22 22:35:52 I have no idea ... the messages seemed inconsisten
228 htmlResourceNodes[tag] = res; 229 htmlResourceNodes[tag] = res;
229 newResources.add(res); 230 newResources.add(res);
230 } 231 }
231 for (var tag in document.querySelectorAll('img[src]')) { 232 for (var tag in document.querySelectorAll('img[src]')) {
232 var res = graph.nodeFromUri(uri.resolve(tag.attributes['src'])); 233 ResourceSourceNode res =
234 graph.nodeFromUri(uri.resolve(tag.attributes['src']));
233 htmlResourceNodes[tag] = res; 235 htmlResourceNodes[tag] = res;
234 newResources.add(res); 236 newResources.add(res);
235 } 237 }
236 if (!_same(newResources, resources)) { 238 if (!_same(newResources, resources)) {
237 structureChanged = true; 239 structureChanged = true;
238 resources = newResources; 240 resources = newResources;
239 } 241 }
240 } 242 }
241 } 243 }
242 244
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 311
310 var directiveUri = (d as UriBasedDirective).uri; 312 var directiveUri = (d as UriBasedDirective).uri;
311 313
312 // `dart:core` and other similar URLs only contain a name, but it is 314 // `dart:core` and other similar URLs only contain a name, but it is
313 // meant to be a folder when resolving relative paths from it. 315 // meant to be a folder when resolving relative paths from it.
314 var targetUri = uri.scheme == 'dart' && uri.pathSegments.length == 1 316 var targetUri = uri.scheme == 'dart' && uri.pathSegments.length == 1
315 ? Uri.parse('$uri/').resolve(directiveUri.stringValue) 317 ? Uri.parse('$uri/').resolve(directiveUri.stringValue)
316 : uri.resolve(directiveUri.stringValue); 318 : uri.resolve(directiveUri.stringValue);
317 var target = 319 var target =
318 ParseDartTask.resolveDirective(graph._context, _source, d, null); 320 ParseDartTask.resolveDirective(graph._context, _source, d, null);
319 var node = graph.nodes.putIfAbsent( 321 DartSourceNode node = graph.nodes.putIfAbsent(
320 targetUri, () => new DartSourceNode(graph, targetUri, target)); 322 targetUri, () => new DartSourceNode(graph, targetUri, target));
321 //var node = graph.nodeFromUri(targetUri); 323 //var node = graph.nodeFromUri(targetUri);
322 if (node._source == null || !node._source.exists()) { 324 if (node._source == null || !node._source.exists()) {
323 _reportError(graph, 'File $targetUri not found', d); 325 _reportError(graph, 'File $targetUri not found', d);
324 } 326 }
325 327
326 if (d is ImportDirective) { 328 if (d is ImportDirective) {
327 newImports.add(node); 329 newImports.add(node);
328 } else if (d is ExportDirective) { 330 } else if (d is ExportDirective) {
329 newExports.add(node); 331 newExports.add(node);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 var deps = includeParts ? node.allDeps : node.depsWithoutParts; 502 var deps = includeParts ? node.allDeps : node.depsWithoutParts;
501 deps.forEach(helper); 503 deps.forEach(helper);
502 action(node); 504 action(node);
503 } 505 }
504 helper(start); 506 helper(start);
505 } 507 }
506 508
507 bool _same(Set a, Set b) => a.length == b.length && a.containsAll(b); 509 bool _same(Set a, Set b) => a.length == b.length && a.containsAll(b);
508 510
509 final _log = new Logger('dev_compiler.dependency_graph'); 511 final _log = new Logger('dev_compiler.dependency_graph');
OLDNEW
« lib/src/codegen/js_codegen.dart ('K') | « lib/src/report.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698