use *Token naming for token members
This commit is contained in:
parent
6490324a09
commit
018de5b546
7 changed files with 60 additions and 50 deletions
|
@ -5,28 +5,29 @@ import 'node.dart';
|
||||||
/// An alternate name for a field within a [SelectionSet].
|
/// An alternate name for a field within a [SelectionSet].
|
||||||
class AliasContext extends Node {
|
class AliasContext extends Node {
|
||||||
/// The source tokens.
|
/// 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
|
@deprecated
|
||||||
Token get NAME1 => name1;
|
Token get NAME1 => nameToken1;
|
||||||
|
|
||||||
/// Use [colon] instead.
|
/// Use [colonToken] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get COLON => colon;
|
Token get COLON => colonToken;
|
||||||
|
|
||||||
/// Use [name2] instead.
|
/// Use [nameToken2] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get NAME2 => name2;
|
Token get NAME2 => nameToken2;
|
||||||
|
|
||||||
/// The aliased name of the value.
|
/// The aliased name of the value.
|
||||||
String get alias => name1.text;
|
String get alias => nameToken1.text;
|
||||||
|
|
||||||
/// The actual name of the value.
|
/// The actual name of the value.
|
||||||
String get name => name2.text;
|
String get name => nameToken2.text;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span => name1.span.expand(colon.span).expand(name2.span);
|
FileSpan get span =>
|
||||||
|
nameToken1.span.expand(colonToken.span).expand(nameToken2.span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@ import 'input_value.dart';
|
||||||
/// An argument passed to a [FieldContext].
|
/// An argument passed to a [FieldContext].
|
||||||
class ArgumentContext extends Node {
|
class ArgumentContext extends Node {
|
||||||
/// The source tokens.
|
/// The source tokens.
|
||||||
final Token nameToken, colon;
|
final Token nameToken, colonToken;
|
||||||
|
|
||||||
/// The value of the argument.
|
/// The value of the argument.
|
||||||
final InputValueContext value;
|
final InputValueContext value;
|
||||||
|
|
||||||
ArgumentContext(this.nameToken, this.colon, this.value);
|
ArgumentContext(this.nameToken, this.colonToken, this.value);
|
||||||
|
|
||||||
/// Use [value] instead.
|
/// Use [value] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
|
@ -21,13 +21,13 @@ class ArgumentContext extends Node {
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get NAME => nameToken;
|
Token get NAME => nameToken;
|
||||||
|
|
||||||
/// Use [colon] instead.
|
/// Use [colonToken] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get COLON => colon;
|
Token get COLON => colonToken;
|
||||||
|
|
||||||
/// The name of the argument, as a [String].
|
/// The name of the argument, as a [String].
|
||||||
String get name => nameToken.text;
|
String get name => nameToken.text;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span => nameToken.span.expand(colon.span).expand(value.span);
|
FileSpan get span => nameToken.span.expand(colonToken.span).expand(value.span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,26 @@ import 'input_value.dart';
|
||||||
/// A GraphQL list value literal.
|
/// A GraphQL list value literal.
|
||||||
class ListValueContext extends InputValueContext {
|
class ListValueContext extends InputValueContext {
|
||||||
/// The source tokens.
|
/// The source tokens.
|
||||||
final Token lBracket, rBracket;
|
final Token lBracketToken, rBracketToken;
|
||||||
|
|
||||||
/// The child values.
|
/// The child values.
|
||||||
final List<InputValueContext> values = [];
|
final List<InputValueContext> values = [];
|
||||||
|
|
||||||
ListValueContext(this.lBracket, this.rBracket);
|
ListValueContext(this.lBracketToken, this.rBracketToken);
|
||||||
|
|
||||||
/// Use [lBracket] instead.
|
/// Use [lBracketToken] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get LBRACKET => lBracket;
|
Token get LBRACKET => lBracketToken;
|
||||||
|
|
||||||
/// Use [rBracket] instead.
|
/// Use [rBracketToken] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get RBRACKET => rBracket;
|
Token get RBRACKET => rBracketToken;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span {
|
FileSpan get span {
|
||||||
var out = values.fold<FileSpan>(lBracket.span, (o, v) => o.expand(v.span));
|
var out =
|
||||||
return out.expand(rBracket.span);
|
values.fold<FileSpan>(lBracketToken.span, (o, v) => o.expand(v.span));
|
||||||
|
return out.expand(rBracketToken.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -7,21 +7,21 @@ class BooleanValueContext extends InputValueContext<bool> {
|
||||||
bool _valueCache;
|
bool _valueCache;
|
||||||
|
|
||||||
/// The source token.
|
/// The source token.
|
||||||
final Token boolean;
|
final Token booleanToken;
|
||||||
|
|
||||||
BooleanValueContext(this.boolean) {
|
BooleanValueContext(this.booleanToken) {
|
||||||
assert(boolean?.text == 'true' || boolean?.text == 'false');
|
assert(booleanToken?.text == 'true' || booleanToken?.text == 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The [bool] value of this literal.
|
/// 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
|
@deprecated
|
||||||
Token get BOOLEAN => boolean;
|
Token get BOOLEAN => booleanToken;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span => boolean.span;
|
FileSpan get span => booleanToken.span;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool computeValue(Map<String, dynamic> variables) => booleanValue;
|
bool computeValue(Map<String, dynamic> variables) => booleanValue;
|
||||||
|
|
|
@ -6,17 +6,17 @@ import 'node.dart';
|
||||||
/// The default value to be passed to an [ArgumentContext].
|
/// The default value to be passed to an [ArgumentContext].
|
||||||
class DefaultValueContext extends Node {
|
class DefaultValueContext extends Node {
|
||||||
/// The source token.
|
/// The source token.
|
||||||
final Token equals;
|
final Token equalsToken;
|
||||||
|
|
||||||
/// The default value for the argument.
|
/// The default value for the argument.
|
||||||
final InputValueContext value;
|
final InputValueContext value;
|
||||||
|
|
||||||
DefaultValueContext(this.equals, this.value);
|
DefaultValueContext(this.equalsToken, this.value);
|
||||||
|
|
||||||
/// Use [equals] instead.
|
/// Use [equalsToken] instead.
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get EQUALS => equals;
|
Token get EQUALS => equalsToken;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span => equals.span.expand(value.span);
|
FileSpan get span => equalsToken.span.expand(value.span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ import 'input_value.dart';
|
||||||
/// Use [ConstantContext] instead. This class remains solely for backwards compatibility.
|
/// Use [ConstantContext] instead. This class remains solely for backwards compatibility.
|
||||||
@deprecated
|
@deprecated
|
||||||
abstract class ValueContext<T> extends InputValueContext<T> {
|
abstract class ValueContext<T> extends InputValueContext<T> {
|
||||||
|
/// Return a constant value.
|
||||||
T get value;
|
T get value;
|
||||||
|
|
||||||
|
@override
|
||||||
T computeValue(Map<String, dynamic> variables) => value;
|
T computeValue(Map<String, dynamic> variables) => value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,17 @@ import 'node.dart';
|
||||||
/// A GraphQL directive, which may or may not have runtime semantics.
|
/// A GraphQL directive, which may or may not have runtime semantics.
|
||||||
class DirectiveContext extends Node {
|
class DirectiveContext extends Node {
|
||||||
/// The source tokens.
|
/// The source tokens.
|
||||||
final Token arroba, name, colon, lParen, rParen;
|
final Token arrobaToken, nameToken, colonToken, lParenToken, rParenToken;
|
||||||
|
|
||||||
/// The argument being passed as the directive.
|
/// The argument being passed as the directive.
|
||||||
final ArgumentContext argument;
|
final ArgumentContext argument;
|
||||||
|
|
||||||
/// The (optional) value being passed with the directive.
|
/// The (optional) value being passed with the directive.
|
||||||
final InputValueContext value;
|
final InputValueContext value;
|
||||||
|
|
||||||
DirectiveContext(this.arroba, this.name, this.colon, this.lParen, this.rParen,
|
DirectiveContext(this.arrobaToken, this.nameToken, this.colonToken,
|
||||||
this.argument, this.value) {
|
this.lParenToken, this.rParenToken, this.argument, this.value) {
|
||||||
assert(name != null);
|
assert(nameToken != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use [value] instead.
|
/// Use [value] instead.
|
||||||
|
@ -23,28 +25,31 @@ class DirectiveContext extends Node {
|
||||||
InputValueContext get valueOrVariable => value;
|
InputValueContext get valueOrVariable => value;
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get ARROBA => arroba;
|
Token get ARROBA => arrobaToken;
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get NAME => name;
|
Token get NAME => nameToken;
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get COLON => colon;
|
Token get COLON => colonToken;
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get LPAREN => lParen;
|
Token get LPAREN => lParenToken;
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
Token get RPAREN => rParen;
|
Token get RPAREN => rParenToken;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span {
|
FileSpan get span {
|
||||||
var out = arroba.span.expand(name.span);
|
var out = arrobaToken.span.expand(nameToken.span);
|
||||||
|
|
||||||
if (colon != null) {
|
if (colonToken != null) {
|
||||||
out = out.expand(colon.span).expand(value.span);
|
out = out.expand(colonToken.span).expand(value.span);
|
||||||
} else if (lParen != null) {
|
} else if (lParenToken != null) {
|
||||||
out = out.expand(lParen.span).expand(argument.span).expand(rParen.span);
|
out = out
|
||||||
|
.expand(lParenToken.span)
|
||||||
|
.expand(argument.span)
|
||||||
|
.expand(rParenToken.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
Loading…
Reference in a new issue