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

Side by Side Diff: lib/src/utils.dart

Issue 1645343002: Builds / serves multiple HTML files. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments Created 4 years, 10 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
« no previous file with comments | « lib/src/server/server.dart ('k') | test/codegen/expect/collection/equality.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as path; 9 import 'package:path/path.dart' as path;
10 import 'package:analyzer/src/generated/ast.dart' 10 import 'package:analyzer/src/generated/ast.dart'
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 String computeHashFromFile(String filepath) { 307 String computeHashFromFile(String filepath) {
308 var bytes = new File(filepath).readAsBytesSync(); 308 var bytes = new File(filepath).readAsBytesSync();
309 return CryptoUtils.bytesToHex((new MD5()..add(bytes)).close()); 309 return CryptoUtils.bytesToHex((new MD5()..add(bytes)).close());
310 } 310 }
311 311
312 String resourceOutputPath(Uri resourceUri, Uri entryUri, String runtimeDir) { 312 String resourceOutputPath(Uri resourceUri, Uri entryUri, String runtimeDir) {
313 if (resourceUri.scheme == 'package') return resourceUri.path; 313 if (resourceUri.scheme == 'package') return resourceUri.path;
314 314
315 if (resourceUri.scheme != 'file') return null; 315 if (resourceUri.scheme != 'file') return null;
316 316
317 var entryDir = path.dirname(entryUri.path); 317 var entryPath = entryUri.path;
318 // The entry uri is either a directory or a dart/html file. If the latter,
319 // trim the file.
320 var entryDir = entryPath.endsWith('.dart') || entryPath.endsWith('.html')
321 ? path.dirname(entryPath)
322 : entryPath;
318 var filepath = path.normalize(path.join(entryDir, resourceUri.path)); 323 var filepath = path.normalize(path.join(entryDir, resourceUri.path));
319 if (path.isWithin(runtimeDir, filepath)) { 324 if (path.isWithin(runtimeDir, filepath)) {
320 filepath = path.relative(filepath, from: runtimeDir); 325 filepath = path.relative(filepath, from: runtimeDir);
321 return path.join('dev_compiler', 'runtime', filepath); 326 return path.join('dev_compiler', 'runtime', filepath);
322 } 327 }
323 328
324 return path.relative(resourceUri.path, from: entryDir); 329 return path.relative(resourceUri.path, from: entryDir);
325 } 330 }
326 331
327 /// Given an annotated [node] and a [test] function, returns the first matching 332 /// Given an annotated [node] and a [test] function, returns the first matching
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 if (reached.add(e)) { 470 if (reached.add(e)) {
466 var destinations = _adjacencyList[e]; 471 var destinations = _adjacencyList[e];
467 if (destinations != null) destinations.forEach(visit); 472 if (destinations != null) destinations.forEach(visit);
468 } 473 }
469 } 474 }
470 roots.forEach(visit); 475 roots.forEach(visit);
471 476
472 return reached; 477 return reached;
473 } 478 }
474 } 479 }
OLDNEW
« no previous file with comments | « lib/src/server/server.dart ('k') | test/codegen/expect/collection/equality.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698