platform/graphql_parser/lib/src/language/ast/directive.dart

34 lines
840 B
Dart
Raw Normal View History

2019-08-08 01:46:38 +00:00
import 'package:source_span/source_span.dart';
2017-01-22 23:15:53 +00:00
import '../token.dart';
import 'argument.dart';
2019-08-08 01:46:38 +00:00
import 'input_value.dart';
2017-01-22 23:15:53 +00:00
import 'node.dart';
class DirectiveContext extends Node {
final Token ARROBA, NAME, COLON, LPAREN, RPAREN;
final ArgumentContext argument;
2019-08-08 01:46:38 +00:00
final InputValueContext value;
2017-01-22 23:15:53 +00:00
DirectiveContext(this.ARROBA, this.NAME, this.COLON, this.LPAREN, this.RPAREN,
2019-08-08 01:46:38 +00:00
this.argument, this.value) {
2017-01-22 23:15:53 +00:00
assert(NAME != null);
}
2019-08-08 01:46:38 +00:00
/// Use [value] instead.
@deprecated
InputValueContext get valueOrVariable => value;
2017-01-22 23:15:53 +00:00
@override
2017-07-05 22:44:13 +00:00
FileSpan get span {
var out = ARROBA.span.expand(NAME.span);
2017-01-22 23:15:53 +00:00
2017-07-05 22:44:13 +00:00
if (COLON != null) {
2019-08-08 01:46:38 +00:00
out = out.expand(COLON.span).expand(value.span);
2017-07-05 22:44:13 +00:00
} else if (LPAREN != null) {
out = out.expand(LPAREN.span).expand(argument.span).expand(RPAREN.span);
}
2017-01-22 23:15:53 +00:00
2017-07-05 22:44:13 +00:00
return out;
2017-01-22 23:15:53 +00:00
}
}