pedantic: number_value
This commit is contained in:
parent
5ef551e8df
commit
a79f6c51c1
1 changed files with 11 additions and 4 deletions
|
@ -3,13 +3,16 @@ import 'package:source_span/source_span.dart';
|
||||||
import '../token.dart';
|
import '../token.dart';
|
||||||
import 'input_value.dart';
|
import 'input_value.dart';
|
||||||
|
|
||||||
|
/// A GraphQL number literal.
|
||||||
class NumberValueContext extends InputValueContext<num> {
|
class NumberValueContext extends InputValueContext<num> {
|
||||||
final Token NUMBER;
|
/// The source token.
|
||||||
|
final Token numberToken;
|
||||||
|
|
||||||
NumberValueContext(this.NUMBER);
|
NumberValueContext(this.numberToken);
|
||||||
|
|
||||||
|
/// The [num] value of the [numberToken].
|
||||||
num get numberValue {
|
num get numberValue {
|
||||||
var text = NUMBER.text;
|
var text = numberToken.text;
|
||||||
if (!text.contains('E') && !text.contains('e')) {
|
if (!text.contains('E') && !text.contains('e')) {
|
||||||
return num.parse(text);
|
return num.parse(text);
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,8 +23,12 @@ class NumberValueContext extends InputValueContext<num> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Use [numberToken] instead.
|
||||||
|
@deprecated
|
||||||
|
Token get NUMBER => numberToken;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FileSpan get span => NUMBER.span;
|
FileSpan get span => numberToken.span;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
num computeValue(Map<String, dynamic> variables) => numberValue;
|
num computeValue(Map<String, dynamic> variables) => numberValue;
|
||||||
|
|
Loading…
Reference in a new issue