Remove output unit field from code-span, it is redundant with output unit in the enclosing entity (#64)
diff --git a/lib/binary_codec.dart b/lib/binary_codec.dart
index b739114..949cb29 100644
--- a/lib/binary_codec.dart
+++ b/lib/binary_codec.dart
@@ -128,7 +128,6 @@
}
_visitCodeSpan(CodeSpan code) {
- _writeOutputOrNull(code.outputUnit);
sink.writeIntOrNull(code.start);
sink.writeIntOrNull(code.end);
sink.writeStringOrNull(code.text);
@@ -372,7 +371,6 @@
CodeSpan _readCodeSpan() {
return new CodeSpan()
- ..outputUnit = _readOutputOrNull()
..start = source.readIntOrNull()
..end = source.readIntOrNull()
..text = source.readStringOrNull();
diff --git a/lib/info.dart b/lib/info.dart
index bdc030e..b41bb5c 100644
--- a/lib/info.dart
+++ b/lib/info.dart
@@ -237,21 +237,21 @@
T accept<T>(InfoVisitor<T> visitor) => visitor.visitClass(this);
}
-/// Details about generated code spans.
+/// A code span of generated code. A [CodeSpan] object is associated with a
+/// single [BasicInfo]. The offsets in the span corresponds to offsets on the
+/// file of [BasicInfo.outputUnit].
class CodeSpan {
- /// File where the code was generated.
- OutputUnitInfo outputUnit;
-
/// Start offset in the generated file.
int start;
/// end offset in the generated file.
int end;
- /// The actual code.
+ /// The actual code (optional, blank when using a compact representation of
+ /// the encoding).
String text;
- CodeSpan({this.outputUnit, this.start, this.end, this.text});
+ CodeSpan({this.start, this.end, this.text});
}
/// Information about a constant value.
diff --git a/lib/json_info_codec.dart b/lib/json_info_codec.dart
index c5fcb6d..161e177 100644
--- a/lib/json_info_codec.dart
+++ b/lib/json_info_codec.dart
@@ -310,16 +310,13 @@
List<CodeSpan> parseCode(dynamic json) {
// backwards compatibility with format 5.1:
if (json is String) {
- return [
- new CodeSpan(outputUnit: null, start: null, end: null, text: json)
- ];
+ return [new CodeSpan(start: null, end: null, text: json)];
}
if (json is List) {
return json.map((dynamic value) {
Map<String, dynamic> jsonCode = value;
return new CodeSpan(
- outputUnit: parseId(jsonCode['outputUnit']),
start: jsonCode['start'],
end: jsonCode['end'],
text: jsonCode['text']);
@@ -570,9 +567,6 @@
List<Object> _serializeCode(List<CodeSpan> code) {
return code
.map<Object>((c) => {
- 'outputUnit': c.outputUnit != null
- ? idFor(c.outputUnit).serializedId
- : null,
'start': c.start,
'end': c.end,
'text': c.text,