fragment_spread: pedantic

This commit is contained in:
Tobe O 2019-08-07 22:51:09 -04:00
parent 517d3ee316
commit a749205c1a

View file

@ -3,17 +3,30 @@ import 'directive.dart';
import 'node.dart';
import 'package:source_span/source_span.dart';
/// A GraphQL fragment spread.
class FragmentSpreadContext extends Node {
final Token ELLIPSIS, NAME;
/// The source tokens.
final Token ellipsisToken, nameToken;
/// Any directives affixed to this fragment spread.
final List<DirectiveContext> directives = [];
FragmentSpreadContext(this.ELLIPSIS, this.NAME);
FragmentSpreadContext(this.ellipsisToken, this.nameToken);
String get name => NAME.text;
/// The [String] value of the [nameToken].
String get name => nameToken.text;
/// Use [ellipsisToken] instead.
@deprecated
Token get ELLIPSIS => ellipsisToken;
/// Use [nameToken] instead.
@deprecated
Token get NAME => nameToken;
@override
FileSpan get span {
var out = ELLIPSIS.span.expand(NAME.span);
var out = ellipsisToken.span.expand(nameToken.span);
if (directives.isEmpty) return out;
return directives.fold<FileSpan>(out, (o, d) => o.expand(d.span));
}