| 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 js.source_mapping; | 5 library js.source_mapping; |
| 6 | 6 |
| 7 import '../io/code_output.dart' show BufferedCodeOutput, SourceLocations; | 7 import '../io/code_output.dart' show BufferedCodeOutput, SourceLocations; |
| 8 import '../io/source_information.dart' | 8 import '../io/source_information.dart' |
| 9 show SourceLocation, SourceInformation, SourceInformationStrategy; | 9 show SourceLocation, SourceInformation, SourceInformationStrategy; |
| 10 import 'js.dart'; | 10 import 'js.dart'; |
| 11 | 11 |
| 12 /// [SourceInformationStrategy] that can associate source information with | 12 /// [SourceInformationStrategy] that can associate source information with |
| 13 /// JavaScript output. | 13 /// JavaScript output. |
| 14 class JavaScriptSourceInformationStrategy extends SourceInformationStrategy { | 14 class JavaScriptSourceInformationStrategy extends SourceInformationStrategy { |
| 15 const JavaScriptSourceInformationStrategy(); | 15 const JavaScriptSourceInformationStrategy(); |
| 16 | 16 |
| 17 /// Creates a processor that can associate source information on [Node] with | 17 /// Creates a processor that can associate source information on [Node] with |
| 18 /// code offsets in the [sourceMapper]. | 18 /// code offsets in the [sourceMapper]. |
| 19 SourceInformationProcessor createProcessor(SourceMapper sourceMapper) { | 19 SourceInformationProcessor createProcessor(SourceMapper sourceMapper) { |
| 20 return const SourceInformationProcessor(); | 20 return const SourceInformationProcessor(); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 /// An observer of code positions of printed JavaScript [Node]s. | 24 /// An observer of code positions of printed JavaScript [Node]s. |
| 25 class CodePositionListener { | 25 class CodePositionListener { |
| 26 const CodePositionListener(); | 26 const CodePositionListener(); |
| 27 | 27 |
| 28 /// Called to associate [node] with the provided start position. |
| 29 /// |
| 30 /// The nodes are seen in pre-traversal order. |
| 31 void onStartPosition(Node node, int startPosition) {} |
| 32 |
| 28 /// Called to associate [node] with the provided start, end and closing | 33 /// Called to associate [node] with the provided start, end and closing |
| 29 /// positions. | 34 /// positions. |
| 35 /// |
| 36 /// The nodes are seen in post-traversal order. |
| 30 void onPositions( | 37 void onPositions( |
| 31 Node node, int startPosition, int endPosition, int closingPosition) {} | 38 Node node, int startPosition, int endPosition, int closingPosition) {} |
| 32 } | 39 } |
| 33 | 40 |
| 34 /// An interface for mapping code offsets with [SourceLocation]s for JavaScript | 41 /// An interface for mapping code offsets with [SourceLocation]s for JavaScript |
| 35 /// [Node]s. | 42 /// [Node]s. |
| 36 abstract class SourceMapper { | 43 abstract class SourceMapper { |
| 37 /// Associate [codeOffset] with [sourceLocation] for [node]. | 44 /// Associate [codeOffset] with [sourceLocation] for [node]. |
| 38 void register(Node node, int codeOffset, SourceLocation sourceLocation); | 45 void register(Node node, int codeOffset, SourceLocation sourceLocation); |
| 39 } | 46 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 | 60 |
| 54 /// A processor that associates [SourceInformation] with code position of | 61 /// A processor that associates [SourceInformation] with code position of |
| 55 /// JavaScript [Node]s. | 62 /// JavaScript [Node]s. |
| 56 class SourceInformationProcessor extends CodePositionListener { | 63 class SourceInformationProcessor extends CodePositionListener { |
| 57 const SourceInformationProcessor(); | 64 const SourceInformationProcessor(); |
| 58 | 65 |
| 59 /// Process the source information and code positions for the [node] and all | 66 /// Process the source information and code positions for the [node] and all |
| 60 /// its children. | 67 /// its children. |
| 61 void process(Node node, BufferedCodeOutput code) {} | 68 void process(Node node, BufferedCodeOutput code) {} |
| 62 } | 69 } |
| OLD | NEW |