pedantic: frag def
This commit is contained in:
parent
5182ff0bf2
commit
6490324a09
1 changed files with 28 additions and 7 deletions
|
@ -5,22 +5,43 @@ import 'package:source_span/source_span.dart';
|
|||
import 'selection_set.dart';
|
||||
import 'type_condition.dart';
|
||||
|
||||
/// A GraphQL query fragment definition.
|
||||
class FragmentDefinitionContext extends ExecutableDefinitionContext {
|
||||
final Token FRAGMENT, NAME, ON;
|
||||
/// The source tokens.
|
||||
final Token fragmentToken, nameToken, onToken;
|
||||
|
||||
/// The type to which this fragment applies.
|
||||
final TypeConditionContext typeCondition;
|
||||
|
||||
/// Any directives on the fragment.
|
||||
final List<DirectiveContext> directives = [];
|
||||
|
||||
/// The selections to apply when the [typeCondition] is met.
|
||||
final SelectionSetContext selectionSet;
|
||||
|
||||
String get name => NAME.text;
|
||||
/// The [String] value of the [nameToken].
|
||||
String get name => nameToken.text;
|
||||
|
||||
FragmentDefinitionContext(
|
||||
this.FRAGMENT, this.NAME, this.ON, this.typeCondition, this.selectionSet);
|
||||
FragmentDefinitionContext(this.fragmentToken, this.nameToken, this.onToken,
|
||||
this.typeCondition, this.selectionSet);
|
||||
|
||||
/// Use [fragmentToken] instead.
|
||||
@deprecated
|
||||
Token get FRAGMENT => fragmentToken;
|
||||
|
||||
/// Use [nameToken] instead.
|
||||
@deprecated
|
||||
Token get NAME => nameToken;
|
||||
|
||||
/// Use [onToken] instead.
|
||||
@deprecated
|
||||
Token get ON => onToken;
|
||||
|
||||
@override
|
||||
FileSpan get span {
|
||||
var out = FRAGMENT.span
|
||||
.expand(NAME.span)
|
||||
.expand(ON.span)
|
||||
var out = fragmentToken.span
|
||||
.expand(nameToken.span)
|
||||
.expand(onToken.span)
|
||||
.expand(typeCondition.span);
|
||||
out = directives.fold<FileSpan>(out, (o, d) => o.expand(d.span));
|
||||
return out.expand(selectionSet.span);
|
||||
|
|
Loading…
Reference in a new issue