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

30 lines
789 B
Dart
Raw Normal View History

2017-01-22 23:15:53 +00:00
import '../token.dart';
import 'argument.dart';
import 'node.dart';
import 'package:source_span/source_span.dart';
import 'value_or_variable.dart';
class DirectiveContext extends Node {
final Token ARROBA, NAME, COLON, LPAREN, RPAREN;
final ArgumentContext argument;
final ValueOrVariableContext valueOrVariable;
DirectiveContext(this.ARROBA, this.NAME, this.COLON, this.LPAREN, this.RPAREN,
this.argument, this.valueOrVariable) {
assert(NAME != null);
}
@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) {
out = out.expand(COLON.span).expand(valueOrVariable.span);
} 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
}
}