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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 int nl = line.indexOf('\n'); | 498 int nl = line.indexOf('\n'); |
499 if (nl != -1) { | 499 if (nl != -1) { |
500 line = line.substring(0, nl); | 500 line = line.substring(0, nl); |
501 } | 501 } |
502 return line; | 502 return line; |
503 } | 503 } |
504 | 504 |
505 /// Called when [node] defines a step of the given [kind] at the given | 505 /// Called when [node] defines a step of the given [kind] at the given |
506 /// [offset] when the generated JavaScript code. | 506 /// [offset] when the generated JavaScript code. |
507 void onStep(js.Node node, Offset offset, StepKind kind) { | 507 void onStep(js.Node node, Offset offset, StepKind kind) { |
508 register('$kind', node); | 508 register(kind, node); |
509 } | 509 } |
510 | 510 |
511 void register(String kind, js.Node node, {bool expectInfo: true}) { | 511 void register(StepKind kind, js.Node node, {bool expectInfo: true}) { |
512 | 512 |
513 String dartCodeFromSourceLocation(SourceLocation sourceLocation) { | 513 String dartCodeFromSourceLocation(SourceLocation sourceLocation) { |
514 SourceFile sourceFile = | 514 SourceFile sourceFile = |
515 sourceFileManager.getSourceFile(sourceLocation.sourceUri); | 515 sourceFileManager.getSourceFile(sourceLocation.sourceUri); |
516 if (sourceFile == null) { | 516 if (sourceFile == null) { |
517 return sourceLocation.shortText; | 517 return sourceLocation.shortText; |
518 } | 518 } |
519 return sourceFile.getLineText(sourceLocation.line) | 519 return sourceFile.getLineText(sourceLocation.line) |
520 .substring(sourceLocation.column).trim(); | 520 .substring(sourceLocation.column).trim(); |
521 } | 521 } |
(...skipping 26 matching lines...) Expand all Loading... |
548 for (SourceLocation location in locations) { | 548 for (SourceLocation location in locations) { |
549 addLocation(location, jsCode); | 549 addLocation(location, jsCode); |
550 } | 550 } |
551 }); | 551 }); |
552 } | 552 } |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 /// A JavaScript code point and its mapped dart source location. | 556 /// A JavaScript code point and its mapped dart source location. |
557 class CodePoint { | 557 class CodePoint { |
558 final String kind; | 558 final StepKind kind; |
559 final String jsCode; | 559 final String jsCode; |
560 final SourceLocation sourceLocation; | 560 final SourceLocation sourceLocation; |
561 final String dartCode; | 561 final String dartCode; |
562 final bool isMissing; | 562 final bool isMissing; |
563 | 563 |
564 CodePoint( | 564 CodePoint( |
565 this.kind, | 565 this.kind, |
566 this.jsCode, | 566 this.jsCode, |
567 this.sourceLocation, | 567 this.sourceLocation, |
568 this.dartCode, | 568 this.dartCode, |
(...skipping 18 matching lines...) Expand all Loading... |
587 absoluteUri = base.resolveUri(uri); | 587 absoluteUri = base.resolveUri(uri); |
588 } else { | 588 } else { |
589 absoluteUri = base.resolve(uri); | 589 absoluteUri = base.resolve(uri); |
590 } | 590 } |
591 return sourceFiles.putIfAbsent(absoluteUri, () { | 591 return sourceFiles.putIfAbsent(absoluteUri, () { |
592 String text = new File.fromUri(absoluteUri).readAsStringSync(); | 592 String text = new File.fromUri(absoluteUri).readAsStringSync(); |
593 return new StringSourceFile.fromUri(absoluteUri, text); | 593 return new StringSourceFile.fromUri(absoluteUri, text); |
594 }); | 594 }); |
595 } | 595 } |
596 } | 596 } |
OLD | NEW |