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

30 lines
852 B
Dart
Raw Normal View History

2017-01-22 23:15:53 +00:00
import '../token.dart';
import 'definition.dart';
import 'directive.dart';
import 'package:source_span/src/span.dart';
import 'selection_set.dart';
import 'type_condition.dart';
class FragmentDefinitionContext extends DefinitionContext {
final Token FRAGMENT, NAME, ON;
final TypeConditionContext typeCondition;
final List<DirectiveContext> directives = [];
final SelectionSetContext selectionSet;
String get name => NAME.text;
FragmentDefinitionContext(
this.FRAGMENT, this.NAME, this.ON, this.typeCondition, this.selectionSet);
@override
SourceSpan get span =>
new SourceSpan(FRAGMENT.span?.start, selectionSet.end, toSource());
@override
String toSource() =>
'fragment ${NAME.text} on ' +
typeCondition.toSource() +
directives.map((d) => d.toSource()).join() +
selectionSet.toSource();
}