2017-01-22 23:15:53 +00:00
|
|
|
import '../token.dart';
|
|
|
|
import 'directive.dart';
|
|
|
|
import 'node.dart';
|
2017-07-05 22:44:13 +00:00
|
|
|
import 'package:source_span/source_span.dart';
|
2017-01-22 23:15:53 +00:00
|
|
|
import 'selection_set.dart';
|
|
|
|
import 'type_condition.dart';
|
|
|
|
|
2019-08-08 02:53:28 +00:00
|
|
|
/// An inline fragment, which typically appears in a [SelectionSetContext].
|
2017-01-22 23:15:53 +00:00
|
|
|
class InlineFragmentContext extends Node {
|
2019-08-08 02:53:28 +00:00
|
|
|
/// The source tokens.
|
|
|
|
final Token ellipsisToken, onToken;
|
|
|
|
|
|
|
|
/// The type which this fragment matches.
|
2017-01-22 23:15:53 +00:00
|
|
|
final TypeConditionContext typeCondition;
|
2019-08-08 02:53:28 +00:00
|
|
|
|
|
|
|
/// Any directives affixed to this inline fragment.
|
2017-01-22 23:15:53 +00:00
|
|
|
final List<DirectiveContext> directives = [];
|
2019-08-08 02:53:28 +00:00
|
|
|
|
|
|
|
/// The selections applied when the [typeCondition] is met.
|
2017-01-22 23:15:53 +00:00
|
|
|
final SelectionSetContext selectionSet;
|
|
|
|
|
|
|
|
InlineFragmentContext(
|
2019-08-08 02:53:28 +00:00
|
|
|
this.ellipsisToken, this.onToken, this.typeCondition, this.selectionSet);
|
|
|
|
|
|
|
|
/// Use [ellipsisToken] instead.
|
|
|
|
@deprecated
|
|
|
|
Token get ELLIPSIS => ellipsisToken;
|
|
|
|
|
|
|
|
/// Use [onToken] instead.
|
|
|
|
@deprecated
|
|
|
|
Token get ON => onToken;
|
2017-01-22 23:15:53 +00:00
|
|
|
|
|
|
|
@override
|
2017-07-05 22:44:13 +00:00
|
|
|
FileSpan get span {
|
2019-08-08 02:53:28 +00:00
|
|
|
var out =
|
|
|
|
ellipsisToken.span.expand(onToken.span).expand(typeCondition.span);
|
2017-07-05 22:44:13 +00:00
|
|
|
out = directives.fold<FileSpan>(out, (o, d) => o.expand(d.span));
|
|
|
|
return out.expand(selectionSet.span);
|
|
|
|
}
|
2017-01-22 23:15:53 +00:00
|
|
|
}
|