Skip to content

Commit 38de0d8

Browse files
authored
Remove output unit field from code-span, it is redundant with output unit in the enclosing entity (#64)
1 parent a99b40b commit 38de0d8

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

lib/binary_codec.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class BinaryPrinter implements InfoVisitor<void> {
128128
}
129129

130130
_visitCodeSpan(CodeSpan code) {
131-
_writeOutputOrNull(code.outputUnit);
132131
sink.writeIntOrNull(code.start);
133132
sink.writeIntOrNull(code.end);
134133
sink.writeStringOrNull(code.text);
@@ -372,7 +371,6 @@ class BinaryReader {
372371

373372
CodeSpan _readCodeSpan() {
374373
return new CodeSpan()
375-
..outputUnit = _readOutputOrNull()
376374
..start = source.readIntOrNull()
377375
..end = source.readIntOrNull()
378376
..text = source.readStringOrNull();

lib/info.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,21 @@ class ClassInfo extends BasicInfo {
237237
T accept<T>(InfoVisitor<T> visitor) => visitor.visitClass(this);
238238
}
239239

240-
/// Details about generated code spans.
240+
/// A code span of generated code. A [CodeSpan] object is associated with a
241+
/// single [BasicInfo]. The offsets in the span corresponds to offsets on the
242+
/// file of [BasicInfo.outputUnit].
241243
class CodeSpan {
242-
/// File where the code was generated.
243-
OutputUnitInfo outputUnit;
244-
245244
/// Start offset in the generated file.
246245
int start;
247246

248247
/// end offset in the generated file.
249248
int end;
250249

251-
/// The actual code.
250+
/// The actual code (optional, blank when using a compact representation of
251+
/// the encoding).
252252
String text;
253253

254-
CodeSpan({this.outputUnit, this.start, this.end, this.text});
254+
CodeSpan({this.start, this.end, this.text});
255255
}
256256

257257
/// Information about a constant value.

lib/json_info_codec.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,13 @@ class JsonToAllInfoConverter extends Converter<Map<String, dynamic>, AllInfo> {
310310
List<CodeSpan> parseCode(dynamic json) {
311311
// backwards compatibility with format 5.1:
312312
if (json is String) {
313-
return [
314-
new CodeSpan(outputUnit: null, start: null, end: null, text: json)
315-
];
313+
return [new CodeSpan(start: null, end: null, text: json)];
316314
}
317315

318316
if (json is List) {
319317
return json.map((dynamic value) {
320318
Map<String, dynamic> jsonCode = value;
321319
return new CodeSpan(
322-
outputUnit: parseId(jsonCode['outputUnit']),
323320
start: jsonCode['start'],
324321
end: jsonCode['end'],
325322
text: jsonCode['text']);
@@ -570,9 +567,6 @@ class AllInfoToJsonConverter extends Converter<AllInfo, Map>
570567
List<Object> _serializeCode(List<CodeSpan> code) {
571568
return code
572569
.map<Object>((c) => {
573-
'outputUnit': c.outputUnit != null
574-
? idFor(c.outputUnit).serializedId
575-
: null,
576570
'start': c.start,
577571
'end': c.end,
578572
'text': c.text,

0 commit comments

Comments
 (0)