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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/compiler.dart

Issue 2811343002: Dev compiler debugger related tweaks. (Closed)
Patch Set: Dev compiler debugger related tweaks. Created 3 years, 8 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:collection' show HashSet, Queue; 5 import 'dart:collection' show HashSet, Queue;
6 import 'dart:convert' show JSON; 6 import 'dart:convert' show JSON;
7 import 'dart:io' show File; 7 import 'dart:io' show File;
8 8
9 import 'package:analyzer/analyzer.dart' 9 import 'package:analyzer/analyzer.dart'
10 show AnalysisError, CompilationUnit, ErrorSeverity; 10 show AnalysisError, CompilationUnit, ErrorSeverity;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 var tree = 492 var tree =
493 transformModuleFormat(format, moduleTree, singleOutFile: singleOutFile); 493 transformModuleFormat(format, moduleTree, singleOutFile: singleOutFile);
494 tree.accept( 494 tree.accept(
495 new JS.Printer(opts, printer, localNamer: new JS.TemporaryNamer(tree))); 495 new JS.Printer(opts, printer, localNamer: new JS.TemporaryNamer(tree)));
496 496
497 Map builtMap; 497 Map builtMap;
498 if (options.sourceMap && sourceMap != null) { 498 if (options.sourceMap && sourceMap != null) {
499 builtMap = 499 builtMap =
500 placeSourceMap(sourceMap.build(jsUrl), mapUrl, options.bazelMapping); 500 placeSourceMap(sourceMap.build(jsUrl), mapUrl, options.bazelMapping);
501 if (name == 'dart_sdk') {
502 builtMap = cleanupSdkSourcemap(builtMap);
503 }
504 if (options.sourceMapComment) { 501 if (options.sourceMapComment) {
505 var relativeMapUrl = path 502 var relativeMapUrl = path
506 .toUri( 503 .toUri(
507 path.relative(path.fromUri(mapUrl), from: path.dirname(jsUrl))) 504 path.relative(path.fromUri(mapUrl), from: path.dirname(jsUrl)))
508 .toString(); 505 .toString();
509 assert(path.dirname(jsUrl) == path.dirname(mapUrl)); 506 assert(path.dirname(jsUrl) == path.dirname(mapUrl));
510 printer.emit('\n//# sourceMappingURL='); 507 printer.emit('\n//# sourceMappingURL=');
511 printer.emit(relativeMapUrl); 508 printer.emit(relativeMapUrl);
512 printer.emit('\n'); 509 printer.emit('\n');
513 } 510 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 /// Adjusts the source paths in [sourceMap] to be relative to [sourceMapPath], 576 /// Adjusts the source paths in [sourceMap] to be relative to [sourceMapPath],
580 /// and returns the new map. 577 /// and returns the new map.
581 // TODO(jmesserly): find a new home for this. 578 // TODO(jmesserly): find a new home for this.
582 Map placeSourceMap( 579 Map placeSourceMap(
583 Map sourceMap, String sourceMapPath, Map<String, String> bazelMappings) { 580 Map sourceMap, String sourceMapPath, Map<String, String> bazelMappings) {
584 var dir = path.dirname(sourceMapPath); 581 var dir = path.dirname(sourceMapPath);
585 var map = new Map.from(sourceMap); 582 var map = new Map.from(sourceMap);
586 var list = new List.from(map['sources']); 583 var list = new List.from(map['sources']);
587 map['sources'] = list; 584 map['sources'] = list;
588 String transformUri(String uri) { 585 String transformUri(String uri) {
586 if (uri.startsWith('dart:')) return uri;
589 var match = bazelMappings[path.absolute(uri)]; 587 var match = bazelMappings[path.absolute(uri)];
590 if (match != null) return match; 588 if (match != null) return match;
591 589
592 // Fall back to a relative path. 590 // Fall back to a relative path.
593 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); 591 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString();
594 } 592 }
595 593
596 for (int i = 0; i < list.length; i++) { 594 for (int i = 0; i < list.length; i++) {
597 list[i] = transformUri(list[i]); 595 list[i] = transformUri(list[i]);
598 } 596 }
599 map['file'] = transformUri(map['file']); 597 map['file'] = transformUri(map['file']);
600 return map; 598 return map;
601 } 599 }
602
603 /// Cleanup the dart_sdk source map.
604 ///
605 /// Strip out files that should not be included in the sdk sourcemap as they
606 /// are implementation details that would just confuse users.
607 /// Normalize sdk urls to use "dart:" for more understandable stack traces.
608 Map cleanupSdkSourcemap(Map sourceMap) {
609 var map = new Map.from(sourceMap);
610 map['sources'] = map['sources']
611 .map((url) => url.contains('/_internal/') ? null : url)
612 .toList();
613 return map;
614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698