From 5567b07a9bbb5700a7c7f1c2010fdeec06a5d11d Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 7 Aug 2019 22:37:31 -0400 Subject: [PATCH] pedantic: ast/directive.dart --- .../lib/src/language/ast/directive.dart | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/graphql_parser/lib/src/language/ast/directive.dart b/graphql_parser/lib/src/language/ast/directive.dart index d0899f57..0115fd40 100644 --- a/graphql_parser/lib/src/language/ast/directive.dart +++ b/graphql_parser/lib/src/language/ast/directive.dart @@ -4,28 +4,47 @@ import 'argument.dart'; import 'input_value.dart'; import 'node.dart'; +/// A GraphQL directive, which may or may not have runtime semantics. class DirectiveContext extends Node { - final Token ARROBA, NAME, COLON, LPAREN, RPAREN; + /// The source tokens. + final Token arroba, name, colon, lParen, rParen; + /// The argument being passed as the directive. final ArgumentContext argument; + /// The (optional) value being passed with the directive. final InputValueContext value; - DirectiveContext(this.ARROBA, this.NAME, this.COLON, this.LPAREN, this.RPAREN, + DirectiveContext(this.arroba, this.name, this.colon, this.lParen, this.rParen, this.argument, this.value) { - assert(NAME != null); + assert(name != null); } /// Use [value] instead. @deprecated InputValueContext get valueOrVariable => value; + @deprecated + Token get ARROBA => arroba; + + @deprecated + Token get NAME => name; + + @deprecated + Token get COLON => colon; + + @deprecated + Token get LPAREN => lParen; + + @deprecated + Token get RPAREN => rParen; + @override FileSpan get span { - var out = ARROBA.span.expand(NAME.span); + var out = arroba.span.expand(name.span); - if (COLON != null) { - out = out.expand(COLON.span).expand(value.span); - } else if (LPAREN != null) { - out = out.expand(LPAREN.span).expand(argument.span).expand(RPAREN.span); + if (colon != null) { + out = out.expand(colon.span).expand(value.span); + } else if (lParen != null) { + out = out.expand(lParen.span).expand(argument.span).expand(rParen.span); } return out;