use *Token naming for token members

This commit is contained in:
Tobe O 2019-08-07 22:45:42 -04:00
parent 6490324a09
commit 018de5b546
7 changed files with 60 additions and 50 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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<InputValueContext> 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<FileSpan>(lBracket.span, (o, v) => o.expand(v.span));
return out.expand(rBracket.span);
var out =
values.fold<FileSpan>(lBracketToken.span, (o, v) => o.expand(v.span));
return out.expand(rBracketToken.span);
}
@override

View file

@ -7,21 +7,21 @@ class BooleanValueContext extends InputValueContext<bool> {
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<String, dynamic> variables) => booleanValue;

View file

@ -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);
}

View file

@ -3,6 +3,9 @@ import 'input_value.dart';
/// Use [ConstantContext] instead. This class remains solely for backwards compatibility.
@deprecated
abstract class ValueContext<T> extends InputValueContext<T> {
/// Return a constant value.
T get value;
@override
T computeValue(Map<String, dynamic> variables) => value;
}

View file

@ -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;