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

Side by Side Diff: lib/dwc.dart

Issue 11450020: (Fix #215) better error printing in editor & extension, adds mapping for editor (Closed) Base URL: git@github.com:dart-lang/dart-web-components.git@master
Patch Set: Created 8 years 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) 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 /** The entry point to the compiler. Used to implement `bin/dwc.dart`. */ 5 /** The entry point to the compiler. Used to implement `bin/dwc.dart`. */
6 library dwc; 6 library dwc;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:logging/logging.dart' show Level; 9 import 'package:logging/logging.dart' show Level;
10 import 'src/compiler.dart'; 10 import 'src/compiler.dart';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 messages = new Messages(options: options); 65 messages = new Messages(options: options);
66 66
67 return asyncTime('Total time spent on ${options.inputFile}', () { 67 return asyncTime('Total time spent on ${options.inputFile}', () {
68 var currentDir = new Directory.current().path; 68 var currentDir = new Directory.current().path;
69 var compiler = new Compiler(fileSystem, options, currentDir); 69 var compiler = new Compiler(fileSystem, options, currentDir);
70 var res; 70 var res;
71 return compiler.run() 71 return compiler.run()
72 .transform((_) => (res = new CompilerResult._(messages, compiler.output))) 72 .transform((_) => (res = new CompilerResult._(messages, compiler.output)))
73 .chain((_) => symlinkPubPackages(res, options)) 73 .chain((_) => symlinkPubPackages(res, options))
74 .chain((_) => emitFiles(compiler.output, options.clean)) 74 .chain((_) => emitFiles(compiler.output, options.clean))
75 .transform((_) => res); 75 .transform((_) {
76 _printMessages(messages, options);
Jennifer Messerly 2012/12/06 04:00:08 Messages should be printed as we emit them, not al
Siggi Cherem (dart-lang) 2012/12/06 18:46:42 I don't necessarily agree, but I think I might be
77 return res;
78 });
76 }, printTime: true, useColors: options.useColors); 79 }, printTime: true, useColors: options.useColors);
77 } 80 }
78 81
79 Future emitFiles(List<OutputFile> outputs, bool clean) { 82 Future emitFiles(List<OutputFile> outputs, bool clean) {
80 outputs.forEach((f) => writeFile(f.path, f.contents, clean)); 83 outputs.forEach((f) => writeFile(f.path, f.contents, clean));
81 return fileSystem.flush(); 84 return fileSystem.flush();
82 } 85 }
83 86
84 void writeFile(fs.Path path, String contents, bool clean) { 87 void writeFile(fs.Path path, String contents, bool clean) {
85 if (clean) { 88 if (clean) {
86 File fileOut = new File.fromPath(_convert(path)); 89 File fileOut = new File.fromPath(_convert(path));
87 if (fileOut.existsSync()) { 90 if (fileOut.existsSync()) {
88 fileOut.deleteSync(); 91 fileOut.deleteSync();
89 } 92 }
90 } else { 93 } else {
91 _createIfNeeded(_convert(path.directoryPath)); 94 _createIfNeeded(_convert(path.directoryPath));
92 fileSystem.writeString(path, contents); 95 fileSystem.writeString(path, contents);
93 } 96 }
94 } 97 }
95 98
96 void _createIfNeeded(Path outdir) { 99 void _createIfNeeded(Path outdir) {
97 if (outdir.isEmpty) return; 100 if (outdir.isEmpty) return;
98 var outDirectory = new Directory.fromPath(outdir); 101 var outDirectory = new Directory.fromPath(outdir);
99 if (!outDirectory.existsSync()) { 102 if (!outDirectory.existsSync()) {
100 _createIfNeeded(outdir.directoryPath); 103 _createIfNeeded(outdir.directoryPath);
101 outDirectory.createSync(); 104 outDirectory.createSync();
102 } 105 }
103 } 106 }
104 107
108 void _printMessages(Messages messages, CompilerOptions options) {
109 for (var message in messages.messages) {
Jennifer Messerly 2012/12/06 04:00:08 verbose messages are always printed now?
Siggi Cherem (dart-lang) 2012/12/06 18:46:42 Fixed.
110 if (options.jsonFormat) {
111 print(message.toJson());
112 } else {
113 print(message);
114 }
115 }
116 }
117
105 /** 118 /**
106 * Creates a symlink to the pub packages directory in the output location. The 119 * Creates a symlink to the pub packages directory in the output location. The
107 * returned future completes when the symlink was created (or immediately if it 120 * returned future completes when the symlink was created (or immediately if it
108 * already exists). 121 * already exists).
109 */ 122 */
110 Future symlinkPubPackages(CompilerResult result, CompilerOptions options) { 123 Future symlinkPubPackages(CompilerResult result, CompilerOptions options) {
111 if (options.outputDir == null || result.bootstrapFile == null) { 124 if (options.outputDir == null || result.bootstrapFile == null) {
112 // We don't need to copy the packages directory if the output was generated 125 // We don't need to copy the packages directory if the output was generated
113 // in-place where the input lives or if the compiler was called without an 126 // in-place where the input lives or if the compiler was called without an
114 // entry-point file. 127 // entry-point file.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 null); 188 null);
176 } 189 }
177 return null; 190 return null;
178 }); 191 });
179 } 192 }
180 193
181 194
182 // TODO(sigmund): this conversion from dart:io paths to internal paths should 195 // TODO(sigmund): this conversion from dart:io paths to internal paths should
183 // go away when dartbug.com/5818 is fixed. 196 // go away when dartbug.com/5818 is fixed.
184 Path _convert(fs.Path path) => new Path(path.toString()); 197 Path _convert(fs.Path path) => new Path(path.toString());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698