2017-07-05 22:44:13 +00:00
|
|
|
import 'package:source_span/source_span.dart';
|
2017-01-22 23:15:53 +00:00
|
|
|
import 'definition.dart';
|
|
|
|
import 'node.dart';
|
|
|
|
|
2019-08-08 02:48:26 +00:00
|
|
|
/// A GraphQL document.
|
2017-01-22 23:15:53 +00:00
|
|
|
class DocumentContext extends Node {
|
2019-08-08 02:48:26 +00:00
|
|
|
/// The top-level definitions in the document.
|
2017-01-22 23:15:53 +00:00
|
|
|
final List<DefinitionContext> definitions = [];
|
|
|
|
|
|
|
|
@override
|
2017-07-05 22:44:13 +00:00
|
|
|
FileSpan get span {
|
2017-01-22 23:15:53 +00:00
|
|
|
if (definitions.isEmpty) return null;
|
2017-07-04 17:32:52 +00:00
|
|
|
return definitions
|
2017-07-05 22:44:13 +00:00
|
|
|
.map<FileSpan>((d) => d.span)
|
|
|
|
.reduce((a, b) => a.expand(b));
|
2017-01-22 23:15:53 +00:00
|
|
|
}
|
|
|
|
}
|