From 018de5b5464f12fadd237c154a7d86d17fd8c037 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 7 Aug 2019 22:45:42 -0400 Subject: [PATCH] use *Token naming for token members --- .../lib/src/language/ast/alias.dart | 23 ++++++------- .../lib/src/language/ast/argument.dart | 10 +++--- .../lib/src/language/ast/array_value.dart | 17 +++++----- .../lib/src/language/ast/boolean_value.dart | 14 ++++---- .../lib/src/language/ast/default_value.dart | 10 +++--- .../src/language/ast/deprecated_value.dart | 3 ++ .../lib/src/language/ast/directive.dart | 33 +++++++++++-------- 7 files changed, 60 insertions(+), 50 deletions(-) diff --git a/graphql_parser/lib/src/language/ast/alias.dart b/graphql_parser/lib/src/language/ast/alias.dart index 137be2bd..1c986bd2 100644 --- a/graphql_parser/lib/src/language/ast/alias.dart +++ b/graphql_parser/lib/src/language/ast/alias.dart @@ -5,28 +5,29 @@ import 'node.dart'; /// An alternate name for a field within a [SelectionSet]. class AliasContext extends Node { /// The source tokens. - final Token name1, colon, name2; + final Token nameToken1, colonToken, nameToken2; - AliasContext(this.name1, this.colon, this.name2); + AliasContext(this.nameToken1, this.colonToken, this.nameToken2); - /// Use [name1] instead. + /// Use [nameToken1] instead. @deprecated - Token get NAME1 => name1; + Token get NAME1 => nameToken1; - /// Use [colon] instead. + /// Use [colonToken] instead. @deprecated - Token get COLON => colon; + Token get COLON => colonToken; - /// Use [name2] instead. + /// Use [nameToken2] instead. @deprecated - Token get NAME2 => name2; + Token get NAME2 => nameToken2; /// The aliased name of the value. - String get alias => name1.text; + String get alias => nameToken1.text; /// The actual name of the value. - String get name => name2.text; + String get name => nameToken2.text; @override - FileSpan get span => name1.span.expand(colon.span).expand(name2.span); + FileSpan get span => + nameToken1.span.expand(colonToken.span).expand(nameToken2.span); } diff --git a/graphql_parser/lib/src/language/ast/argument.dart b/graphql_parser/lib/src/language/ast/argument.dart index f1150bd4..8b3e8294 100644 --- a/graphql_parser/lib/src/language/ast/argument.dart +++ b/graphql_parser/lib/src/language/ast/argument.dart @@ -6,12 +6,12 @@ import 'input_value.dart'; /// An argument passed to a [FieldContext]. class ArgumentContext extends Node { /// The source tokens. - final Token nameToken, colon; + final Token nameToken, colonToken; /// The value of the argument. final InputValueContext value; - ArgumentContext(this.nameToken, this.colon, this.value); + ArgumentContext(this.nameToken, this.colonToken, this.value); /// Use [value] instead. @deprecated @@ -21,13 +21,13 @@ class ArgumentContext extends Node { @deprecated Token get NAME => nameToken; - /// Use [colon] instead. + /// Use [colonToken] instead. @deprecated - Token get COLON => colon; + Token get COLON => colonToken; /// The name of the argument, as a [String]. String get name => nameToken.text; @override - FileSpan get span => nameToken.span.expand(colon.span).expand(value.span); + FileSpan get span => nameToken.span.expand(colonToken.span).expand(value.span); } diff --git a/graphql_parser/lib/src/language/ast/array_value.dart b/graphql_parser/lib/src/language/ast/array_value.dart index 4e7204f3..51afb3df 100644 --- a/graphql_parser/lib/src/language/ast/array_value.dart +++ b/graphql_parser/lib/src/language/ast/array_value.dart @@ -5,25 +5,26 @@ import 'input_value.dart'; /// A GraphQL list value literal. class ListValueContext extends InputValueContext { /// The source tokens. - final Token lBracket, rBracket; + final Token lBracketToken, rBracketToken; /// The child values. final List values = []; - ListValueContext(this.lBracket, this.rBracket); + ListValueContext(this.lBracketToken, this.rBracketToken); - /// Use [lBracket] instead. + /// Use [lBracketToken] instead. @deprecated - Token get LBRACKET => lBracket; + Token get LBRACKET => lBracketToken; - /// Use [rBracket] instead. + /// Use [rBracketToken] instead. @deprecated - Token get RBRACKET => rBracket; + Token get RBRACKET => rBracketToken; @override FileSpan get span { - var out = values.fold(lBracket.span, (o, v) => o.expand(v.span)); - return out.expand(rBracket.span); + var out = + values.fold(lBracketToken.span, (o, v) => o.expand(v.span)); + return out.expand(rBracketToken.span); } @override diff --git a/graphql_parser/lib/src/language/ast/boolean_value.dart b/graphql_parser/lib/src/language/ast/boolean_value.dart index 423f0cde..0b8cfe8f 100644 --- a/graphql_parser/lib/src/language/ast/boolean_value.dart +++ b/graphql_parser/lib/src/language/ast/boolean_value.dart @@ -7,21 +7,21 @@ class BooleanValueContext extends InputValueContext { bool _valueCache; /// The source token. - final Token boolean; + final Token booleanToken; - BooleanValueContext(this.boolean) { - assert(boolean?.text == 'true' || boolean?.text == 'false'); + BooleanValueContext(this.booleanToken) { + assert(booleanToken?.text == 'true' || booleanToken?.text == 'false'); } /// The [bool] value of this literal. - bool get booleanValue => _valueCache ??= boolean.text == 'true'; + bool get booleanValue => _valueCache ??= booleanToken.text == 'true'; - /// Use [boolean] instead. + /// Use [booleanToken] instead. @deprecated - Token get BOOLEAN => boolean; + Token get BOOLEAN => booleanToken; @override - FileSpan get span => boolean.span; + FileSpan get span => booleanToken.span; @override bool computeValue(Map variables) => booleanValue; diff --git a/graphql_parser/lib/src/language/ast/default_value.dart b/graphql_parser/lib/src/language/ast/default_value.dart index 8da3414a..d3b805b5 100644 --- a/graphql_parser/lib/src/language/ast/default_value.dart +++ b/graphql_parser/lib/src/language/ast/default_value.dart @@ -6,17 +6,17 @@ import 'node.dart'; /// The default value to be passed to an [ArgumentContext]. class DefaultValueContext extends Node { /// The source token. - final Token equals; + final Token equalsToken; /// The default value for the argument. final InputValueContext value; - DefaultValueContext(this.equals, this.value); + DefaultValueContext(this.equalsToken, this.value); - /// Use [equals] instead. + /// Use [equalsToken] instead. @deprecated - Token get EQUALS => equals; + Token get EQUALS => equalsToken; @override - FileSpan get span => equals.span.expand(value.span); + FileSpan get span => equalsToken.span.expand(value.span); } diff --git a/graphql_parser/lib/src/language/ast/deprecated_value.dart b/graphql_parser/lib/src/language/ast/deprecated_value.dart index 2f71709c..5dfca6ef 100644 --- a/graphql_parser/lib/src/language/ast/deprecated_value.dart +++ b/graphql_parser/lib/src/language/ast/deprecated_value.dart @@ -3,6 +3,9 @@ import 'input_value.dart'; /// Use [ConstantContext] instead. This class remains solely for backwards compatibility. @deprecated abstract class ValueContext extends InputValueContext { + /// Return a constant value. T get value; + + @override T computeValue(Map variables) => value; } diff --git a/graphql_parser/lib/src/language/ast/directive.dart b/graphql_parser/lib/src/language/ast/directive.dart index 0115fd40..c641aed6 100644 --- a/graphql_parser/lib/src/language/ast/directive.dart +++ b/graphql_parser/lib/src/language/ast/directive.dart @@ -7,15 +7,17 @@ import 'node.dart'; /// A GraphQL directive, which may or may not have runtime semantics. class DirectiveContext extends Node { /// The source tokens. - final Token arroba, name, colon, lParen, rParen; + final Token arrobaToken, nameToken, colonToken, lParenToken, rParenToken; + /// 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, - this.argument, this.value) { - assert(name != null); + DirectiveContext(this.arrobaToken, this.nameToken, this.colonToken, + this.lParenToken, this.rParenToken, this.argument, this.value) { + assert(nameToken != null); } /// Use [value] instead. @@ -23,28 +25,31 @@ class DirectiveContext extends Node { InputValueContext get valueOrVariable => value; @deprecated - Token get ARROBA => arroba; + Token get ARROBA => arrobaToken; @deprecated - Token get NAME => name; + Token get NAME => nameToken; @deprecated - Token get COLON => colon; + Token get COLON => colonToken; @deprecated - Token get LPAREN => lParen; + Token get LPAREN => lParenToken; @deprecated - Token get RPAREN => rParen; + Token get RPAREN => rParenToken; @override FileSpan get span { - var out = arroba.span.expand(name.span); + var out = arrobaToken.span.expand(nameToken.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 (colonToken != null) { + out = out.expand(colonToken.span).expand(value.span); + } else if (lParenToken != null) { + out = out + .expand(lParenToken.span) + .expand(argument.span) + .expand(rParenToken.span); } return out;