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

Side by Side Diff: compiler/java/com/google/dart/runner/DartRunner.java

Issue 8287001: Add a command-line option for generating source maps. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 package com.google.dart.runner; 5 package com.google.dart.runner;
6 6
7 import com.google.common.base.Joiner; 7 import com.google.common.base.Joiner;
8 import com.google.common.collect.Lists; 8 import com.google.common.collect.Lists;
9 import com.google.common.io.CharStreams; 9 import com.google.common.io.CharStreams;
10 import com.google.common.io.Files; 10 import com.google.common.io.Files;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 DartCompilerListener listener) thr ows RunnerError { 366 DartCompilerListener listener) thr ows RunnerError {
367 try { 367 try {
368 final RunnerDartArtifactProvider provider = new RunnerDartArtifactProvider (); 368 final RunnerDartArtifactProvider provider = new RunnerDartArtifactProvider ();
369 String errmsg = DartCompiler.compileLib(app, imports, config, provider, li stener); 369 String errmsg = DartCompiler.compileLib(app, imports, config, provider, li stener);
370 if (errmsg != null) { 370 if (errmsg != null) {
371 throw new RunnerError(errmsg); 371 throw new RunnerError(errmsg);
372 } 372 }
373 Backend backend = config.getBackends().get(0); 373 Backend backend = config.getBackends().get(0);
374 374
375 SourceMapping mapping = null; 375 SourceMapping mapping = null;
376 Reader mr = provider.getArtifactReader(app, "", backend.getSourceMapExtens ion()); 376 if (config.getCompilerOptions().generateSourceMaps()) {
377 if (mr != null) { 377 Reader mr = provider.getArtifactReader(app, "", backend.getSourceMapExte nsion());
378 String mapContents = CharStreams.toString(mr); 378 if (mr != null) {
379 try { 379 String mapContents = CharStreams.toString(mr);
380 mapping = SourceMapConsumerFactory.parse(mapContents, new SourceMapSup plier() { 380 try {
381 mapping = SourceMapConsumerFactory.parse(mapContents, new SourceMapS upplier() {
381 382
382 @Override 383 @Override
383 public String getSourceMap(String url) { 384 public String getSourceMap(String url) {
384 String contents = provider.getGeneratedFileContents(url); 385 String contents = provider.getGeneratedFileContents(url);
385 if (contents == null || contents.isEmpty()) { 386 if (contents == null || contents.isEmpty()) {
386 return null; 387 return null;
388 }
389 return contents;
387 } 390 }
388 return contents;
389 }
390 391
391 }); 392 });
392 } catch (SourceMapParseException e) { 393 } catch (SourceMapParseException e) {
393 throw new AssertionError(e); 394 throw new AssertionError(e);
395 }
396 mr.close();
394 } 397 }
395 mr.close();
396 } 398 }
397 399
398 Reader r = provider.getArtifactReader(app, "", backend.getAppExtension()); 400 Reader r = provider.getArtifactReader(app, "", backend.getAppExtension());
399 String js = CharStreams.toString(r); 401 String js = CharStreams.toString(r);
400 r.close(); 402 r.close();
401 return new CompilationResult(js, mapping); 403 return new CompilationResult(js, mapping);
402 } catch (IOException e) { 404 } catch (IOException e) {
403 // This can't happen; it's just a StringWriter. 405 // This can't happen; it's just a StringWriter.
404 throw new AssertionError(e); 406 throw new AssertionError(e);
405 } 407 }
406 } 408 }
407 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698