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