Add "exclude" to Parser.next to explicitly ignore "on" when necessary
This commit is contained in:
parent
de6c9f5bef
commit
2a01c249b1
2 changed files with 11 additions and 8 deletions
|
@ -16,8 +16,9 @@ class Parser {
|
||||||
|
|
||||||
Token get current => _current;
|
Token get current => _current;
|
||||||
|
|
||||||
bool next(TokenType type) {
|
bool next(TokenType type, {Iterable<String> exclude}) {
|
||||||
if (peek()?.type == type) {
|
var tok = peek();
|
||||||
|
if (tok?.type == type && exclude?.contains(tok.span.text) != true) {
|
||||||
_current = tokens[++_index];
|
_current = tokens[++_index];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +28,6 @@ class Parser {
|
||||||
|
|
||||||
bool nextName(String name) {
|
bool nextName(String name) {
|
||||||
var tok = peek();
|
var tok = peek();
|
||||||
|
|
||||||
if (tok?.type == TokenType.NAME && tok.span.text == name) {
|
if (tok?.type == TokenType.NAME && tok.span.text == name) {
|
||||||
return next(TokenType.NAME);
|
return next(TokenType.NAME);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ class Parser {
|
||||||
FragmentSpreadContext parseFragmentSpread() {
|
FragmentSpreadContext parseFragmentSpread() {
|
||||||
if (next(TokenType.ELLIPSIS)) {
|
if (next(TokenType.ELLIPSIS)) {
|
||||||
var ELLIPSIS = current;
|
var ELLIPSIS = current;
|
||||||
if (next(TokenType.NAME)) {
|
if (next(TokenType.NAME, exclude: ['on'])) {
|
||||||
var NAME = current;
|
var NAME = current;
|
||||||
return new FragmentSpreadContext(ELLIPSIS, NAME)
|
return new FragmentSpreadContext(ELLIPSIS, NAME)
|
||||||
..directives.addAll(parseDirectives());
|
..directives.addAll(parseDirectives());
|
||||||
|
|
|
@ -73,10 +73,13 @@ class _IsSelectionSet extends Matcher {
|
||||||
bool matches(item, Map matchState) {
|
bool matches(item, Map matchState) {
|
||||||
var set =
|
var set =
|
||||||
item is SelectionSetContext ? item : parseSelectionSet(item.toString());
|
item is SelectionSetContext ? item : parseSelectionSet(item.toString());
|
||||||
print('Item: $set has ${set.selections.length} selection(s):');
|
|
||||||
for (var s in set.selections) {
|
// if (set != null) {
|
||||||
print(' * $s (${s.span.text})');
|
// print('Item: $set has ${set.selections.length} selection(s):');
|
||||||
}
|
// for (var s in set.selections) {
|
||||||
|
// print(' * $s (${s.span.text})');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (set == null) return false;
|
if (set == null) return false;
|
||||||
if (set.selections.length != selections.length) return false;
|
if (set.selections.length != selections.length) return false;
|
||||||
|
|
Loading…
Reference in a new issue