OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library compiler; | 5 library compiler; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show SplayTreeMap; | 8 import 'dart:collection' show SplayTreeMap; |
9 import 'dart:json' as json; | 9 import 'dart:convert'; |
10 | 10 |
11 import 'package:analyzer_experimental/src/generated/ast.dart' show Directive, Ur
iBasedDirective; | 11 import 'package:analyzer_experimental/src/generated/ast.dart' show Directive, Ur
iBasedDirective; |
12 import 'package:csslib/visitor.dart' show StyleSheet, treeToDebugString; | 12 import 'package:csslib/visitor.dart' show StyleSheet, treeToDebugString; |
13 import 'package:html5lib/dom.dart'; | 13 import 'package:html5lib/dom.dart'; |
14 import 'package:html5lib/parser.dart'; | 14 import 'package:html5lib/parser.dart'; |
15 import 'package:observe/transform.dart' show transformObservables; | 15 import 'package:observe/transform.dart' show transformObservables; |
16 import 'package:source_maps/span.dart' show Span; | 16 import 'package:source_maps/span.dart' show Span; |
17 import 'package:source_maps/refactor.dart' show TextEditTransaction; | 17 import 'package:source_maps/refactor.dart' show TextEditTransaction; |
18 import 'package:source_maps/printer.dart'; | 18 import 'package:source_maps/printer.dart'; |
19 | 19 |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 if (printer == null) return; | 739 if (printer == null) return; |
740 | 740 |
741 var libPath = _pathMapper.outputLibraryPath(lib); | 741 var libPath = _pathMapper.outputLibraryPath(lib); |
742 var dir = path.dirname(libPath); | 742 var dir = path.dirname(libPath); |
743 var filename = path.basename(libPath); | 743 var filename = path.basename(libPath); |
744 printer.add('\n//# sourceMappingURL=$filename.map'); | 744 printer.add('\n//# sourceMappingURL=$filename.map'); |
745 printer.build(libPath); | 745 printer.build(libPath); |
746 var sourcePath = dartCodeUrl != null ? dartCodeUrl.resolvedPath : null; | 746 var sourcePath = dartCodeUrl != null ? dartCodeUrl.resolvedPath : null; |
747 output.add(new OutputFile(libPath, printer.text, source: sourcePath)); | 747 output.add(new OutputFile(libPath, printer.text, source: sourcePath)); |
748 // Fix-up the paths in the source map file | 748 // Fix-up the paths in the source map file |
749 var sourceMap = json.parse(printer.map); | 749 var sourceMap = JSON.decode(printer.map); |
750 var urls = sourceMap['sources']; | 750 var urls = sourceMap['sources']; |
751 for (int i = 0; i < urls.length; i++) { | 751 for (int i = 0; i < urls.length; i++) { |
752 urls[i] = path.relative(urls[i], from: dir); | 752 urls[i] = path.relative(urls[i], from: dir); |
753 } | 753 } |
754 output.add(new OutputFile(path.join(dir, '$filename.map'), | 754 output.add(new OutputFile(path.join(dir, '$filename.map'), |
755 json.stringify(sourceMap))); | 755 JSON.encode(sourceMap))); |
756 } | 756 } |
757 | 757 |
758 _time(String logMessage, String filePath, callback(), | 758 _time(String logMessage, String filePath, callback(), |
759 {bool printTime: false}) { | 759 {bool printTime: false}) { |
760 var message = new StringBuffer(); | 760 var message = new StringBuffer(); |
761 message.write(logMessage); | 761 message.write(logMessage); |
762 var filename = path.basename(filePath); | 762 var filename = path.basename(filePath); |
763 for (int i = (60 - logMessage.length - filename.length); i > 0 ; i--) { | 763 for (int i = (60 - logMessage.length - filename.length); i > 0 ; i--) { |
764 message.write(' '); | 764 message.write(' '); |
765 } | 765 } |
766 message.write(filename); | 766 message.write(filename); |
767 return time(message.toString(), callback, | 767 return time(message.toString(), callback, |
768 printTime: options.verbose || printTime); | 768 printTime: options.verbose || printTime); |
769 } | 769 } |
770 } | 770 } |
OLD | NEW |