OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 sourcemap.helper; | 5 library sourcemap.helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:compiler/compiler_new.dart'; | 9 import 'package:compiler/compiler_new.dart'; |
10 import 'package:compiler/src/apiimpl.dart' as api; | 10 import 'package:compiler/src/apiimpl.dart' as api; |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 496 } |
497 | 497 |
498 void register(StepKind kind, js.Node node, {bool expectInfo: true}) { | 498 void register(StepKind kind, js.Node node, {bool expectInfo: true}) { |
499 String dartCodeFromSourceLocation(SourceLocation sourceLocation) { | 499 String dartCodeFromSourceLocation(SourceLocation sourceLocation) { |
500 SourceFile sourceFile = | 500 SourceFile sourceFile = |
501 sourceFileManager.getSourceFile(sourceLocation.sourceUri); | 501 sourceFileManager.getSourceFile(sourceLocation.sourceUri); |
502 if (sourceFile == null) { | 502 if (sourceFile == null) { |
503 return sourceLocation.shortText; | 503 return sourceLocation.shortText; |
504 } | 504 } |
505 return sourceFile.kernelSource | 505 return sourceFile.kernelSource |
506 .getTextLine(sourceLocation.line + 1) | 506 .getTextLine(sourceLocation.line) |
507 .substring(sourceLocation.column) | 507 .substring(sourceLocation.column - 1) |
508 .trim(); | 508 .trim(); |
509 } | 509 } |
510 | 510 |
511 void addLocation(SourceLocation sourceLocation, String jsCode) { | 511 void addLocation(SourceLocation sourceLocation, String jsCode) { |
512 if (sourceLocation == null) { | 512 if (sourceLocation == null) { |
513 if (expectInfo) { | 513 if (expectInfo) { |
514 SourceInformation sourceInformation = node.sourceInformation; | 514 SourceInformation sourceInformation = node.sourceInformation; |
515 SourceLocation sourceLocation; | 515 SourceLocation sourceLocation; |
516 String dartCode; | 516 String dartCode; |
517 if (sourceInformation != null) { | 517 if (sourceInformation != null) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 absoluteUri = base.resolveUri(uri); | 571 absoluteUri = base.resolveUri(uri); |
572 } else { | 572 } else { |
573 absoluteUri = base.resolve(uri); | 573 absoluteUri = base.resolve(uri); |
574 } | 574 } |
575 return sourceFiles.putIfAbsent(absoluteUri, () { | 575 return sourceFiles.putIfAbsent(absoluteUri, () { |
576 String text = new File.fromUri(absoluteUri).readAsStringSync(); | 576 String text = new File.fromUri(absoluteUri).readAsStringSync(); |
577 return new StringSourceFile.fromUri(absoluteUri, text); | 577 return new StringSourceFile.fromUri(absoluteUri, text); |
578 }); | 578 }); |
579 } | 579 } |
580 } | 580 } |
OLD | NEW |