Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 166 |
| 167 bool fatal = (kind.ordinal & FATAL) != 0; | 167 bool fatal = (kind.ordinal & FATAL) != 0; |
| 168 bool isInfo = (kind.ordinal & INFO) != 0; | 168 bool isInfo = (kind.ordinal & INFO) != 0; |
| 169 if (isInfo && uri == null && kind != api.Diagnostic.INFO) { | 169 if (isInfo && uri == null && kind != api.Diagnostic.INFO) { |
| 170 info(message, kind); | 170 info(message, kind); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 | 173 |
| 174 message = prefixMessage(message, kind); | 174 message = prefixMessage(message, kind); |
| 175 | 175 |
| 176 // [previousKind]/[lastKind] records the previous non-INFO kind we saw. | 176 // [lastKind] records the previous non-INFO kind we saw. |
| 177 // This is used to suppress info about a warning when warnings are | 177 // This is used to suppress info about a warning when warnings are |
| 178 // suppressed, and similar for hints. | 178 // suppressed, and similar for hints. |
| 179 var previousKind = lastKind; | 179 if (kind != api.Diagnostic.INFO) { |
|
karlklose
2015/06/11 10:56:16
Indentation.
herhut
2015/06/11 12:48:55
Will do in follow-up CL...
| |
| 180 if (kind != api.Diagnostic.INFO) { | |
| 181 lastKind = kind; | 180 lastKind = kind; |
| 182 } | 181 } |
| 183 var color; | 182 var color; |
| 184 if (kind == api.Diagnostic.ERROR) { | 183 if (kind == api.Diagnostic.ERROR) { |
| 185 color = colors.red; | 184 color = colors.red; |
| 186 } else if (kind == api.Diagnostic.WARNING) { | 185 } else if (kind == api.Diagnostic.WARNING) { |
| 187 if (!showWarnings) return; | 186 if (!showWarnings) return; |
| 188 color = colors.magenta; | 187 color = colors.magenta; |
| 189 } else if (kind == api.Diagnostic.HINT) { | 188 } else if (kind == api.Diagnostic.HINT) { |
| 190 if (!showHints) return; | 189 if (!showHints) return; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 if (outPath.endsWith('.js')) { | 246 if (outPath.endsWith('.js')) { |
| 248 outPath = outPath.substring(0, outPath.length - 3); | 247 outPath = outPath.substring(0, outPath.length - 3); |
| 249 return out.resolve('$outPath.$extension'); | 248 return out.resolve('$outPath.$extension'); |
| 250 } else { | 249 } else { |
| 251 return out.resolve(extension); | 250 return out.resolve(extension); |
| 252 } | 251 } |
| 253 } | 252 } |
| 254 | 253 |
| 255 EventSink<String> call(String name, String extension) { | 254 EventSink<String> call(String name, String extension) { |
| 256 Uri uri; | 255 Uri uri; |
| 257 String sourceMapFileName; | |
| 258 bool isPrimaryOutput = false; | 256 bool isPrimaryOutput = false; |
| 259 // TODO (johnniwinther, sigurdm): Make a better interface for | 257 // TODO (johnniwinther, sigurdm): Make a better interface for |
| 260 // output-providers. | 258 // output-providers. |
| 261 if (extension == "deferred_map") { | 259 if (extension == "deferred_map") { |
| 262 uri = out.resolve(name); | 260 uri = out.resolve(name); |
| 263 } else if (name == '') { | 261 } else if (name == '') { |
| 264 if (extension == 'js' || extension == 'dart') { | 262 if (extension == 'js' || extension == 'dart') { |
| 265 isPrimaryOutput = true; | 263 isPrimaryOutput = true; |
| 266 uri = out; | 264 uri = out; |
| 267 sourceMapFileName = | |
| 268 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | |
| 269 } else if (extension == 'precompiled.js') { | 265 } else if (extension == 'precompiled.js') { |
| 270 uri = computePrecompiledUri(out); | 266 uri = computePrecompiledUri(out); |
| 271 onInfo("File ($uri) is compatible with header" | 267 onInfo("File ($uri) is compatible with header" |
| 272 " \"Content-Security-Policy: script-src 'self'\""); | 268 " \"Content-Security-Policy: script-src 'self'\""); |
| 273 } else if (extension == 'js.map' || extension == 'dart.map') { | 269 } else if (extension == 'js.map' || extension == 'dart.map') { |
| 274 uri = sourceMapOut; | 270 uri = sourceMapOut; |
| 275 } else if (extension == "info.json") { | 271 } else if (extension == "info.json") { |
| 276 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); | 272 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); |
| 277 uri = out.resolve('$outName.$extension'); | 273 uri = out.resolve('$outName.$extension'); |
| 278 } else { | 274 } else { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 var onAdd, onClose; | 321 var onAdd, onClose; |
| 326 | 322 |
| 327 EventSinkWrapper(this.onAdd, this.onClose); | 323 EventSinkWrapper(this.onAdd, this.onClose); |
| 328 | 324 |
| 329 void add(String data) => onAdd(data); | 325 void add(String data) => onAdd(data); |
| 330 | 326 |
| 331 void addError(error, [StackTrace stackTrace]) => throw error; | 327 void addError(error, [StackTrace stackTrace]) => throw error; |
| 332 | 328 |
| 333 void close() => onClose(); | 329 void close() => onClose(); |
| 334 } | 330 } |
| OLD | NEW |