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

Side by Side Diff: pkg/compiler/lib/src/io/code_output.dart

Issue 1196433002: Create and test source mapping for invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js.code_output; 5 library dart2js.code_output;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'source_information.dart'; 9 import 'source_information.dart';
10 10
11 /// Listener interface for [CodeOutput] activity.
11 abstract class CodeOutputListener { 12 abstract class CodeOutputListener {
13 /// Called when [text] is added to the output.
12 void onText(String text); 14 void onText(String text);
15
16 /// Called when the output is closed with a final length of [length].
13 void onDone(int length); 17 void onDone(int length);
14 } 18 }
15 19
16 abstract class CodeOutput { 20 /// Interface for a mapping of target offsets to source locations.
21 abstract class SourceLocations {
22 /// Adds a [sourceLocation] at the specified [targetOffset].
23 void addSourceLocation(int targetOffset, SourceLocation sourcePosition);
24
25 /// Applies [f] to every target offset and associated source location.
26 void forEachSourceLocation(void f(int targetOffset,
27 SourceLocation sourceLocation));
28 }
29
30 abstract class CodeOutput implements SourceLocations {
17 /// Write [text] to this output. 31 /// Write [text] to this output.
18 /// 32 ///
19 /// If the output is closed, a [StateError] is thrown. 33 /// If the output is closed, a [StateError] is thrown.
20 void add(String text); 34 void add(String text);
21 35
22 /// Adds the content of [buffer] to the output and adds its markers to 36 /// Adds the content of [buffer] to the output and adds its markers to
23 /// [markers]. 37 /// [markers].
24 /// 38 ///
25 /// If the output is closed, a [StateError] is thrown. 39 /// If the output is closed, a [StateError] is thrown.
26 void addBuffer(CodeBuffer buffer); 40 void addBuffer(CodeBuffer buffer);
27 41
28 /// Returns the number of characters currently write to this output. 42 /// Returns the number of characters currently write to this output.
29 int get length; 43 int get length;
30 44
31 /// Returns `true` if this output has been closed. 45 /// Returns `true` if this output has been closed.
32 bool get isClosed; 46 bool get isClosed;
33 47
34 /// Closes the output. Further writes will cause a [StateError]. 48 /// Closes the output. Further writes will cause a [StateError].
35 void close(); 49 void close();
36
37 /// Adds a [sourceLocation] at the specified [targetOffset] in the buffer.
38 void addSourceLocation(int targetOffset, SourceLocation sourcePosition);
39
40 /// Applies [f] to every marker in this output.
41 void forEachSourceLocation(void f(int targetOffset,
42 SourceLocation sourceLocation));
43 } 50 }
44 51
45 abstract class AbstractCodeOutput extends CodeOutput { 52 abstract class AbstractCodeOutput extends CodeOutput {
46 Map<int, List<SourceLocation>> markers = <int, List<SourceLocation>>{}; 53 Map<int, List<SourceLocation>> markers = <int, List<SourceLocation>>{};
47 bool isClosed = false; 54 bool isClosed = false;
48 55
49 void _addInternal(String text); 56 void _addInternal(String text);
50 57
51 @override 58 @override
52 void add(String text) { 59 void add(String text) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 141 }
135 142
136 void close() { 143 void close() {
137 output.close(); 144 output.close();
138 super.close(); 145 super.close();
139 if (_listeners != null) { 146 if (_listeners != null) {
140 _listeners.forEach((listener) => listener.onDone(length)); 147 _listeners.forEach((listener) => listener.onDone(length));
141 } 148 }
142 } 149 }
143 } 150 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/io/line_column_provider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698