2017-01-22 23:15:53 +00:00
|
|
|
import 'definition.dart';
|
|
|
|
import 'node.dart';
|
|
|
|
import 'package:source_span/src/span.dart';
|
|
|
|
|
|
|
|
class DocumentContext extends Node {
|
|
|
|
final List<DefinitionContext> definitions = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
SourceSpan get span {
|
|
|
|
if (definitions.isEmpty) return null;
|
2017-07-04 17:32:52 +00:00
|
|
|
return definitions
|
|
|
|
.map<SourceSpan>((d) => d.span)
|
|
|
|
.reduce((a, b) => a.union(b));
|
2017-01-22 23:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toSource() {
|
|
|
|
if (definitions.isEmpty) return '(empty document)';
|
|
|
|
return definitions.map((d) => d.toSource()).join();
|
|
|
|
}
|
|
|
|
}
|