platform/lib/src/language/ast/document.dart

21 lines
509 B
Dart
Raw Normal View History

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;
return new SourceSpan(
definitions.first.start, definitions.last.end, toSource());
}
@override
String toSource() {
if (definitions.isEmpty) return '(empty document)';
return definitions.map((d) => d.toSource()).join();
}
}