Skip to content

Commit 011775a

Browse files
committed
Fix for parsing a repeatable keyword as an identifier (#600)
1 parent ca67843 commit 011775a

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

gen/com/intellij/lang/jsgraphql/GraphQLParser.java

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grammars/GraphQLParser.bnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private argument_recover ::= !(')' | argument)
140140

141141
identifier ::=
142142
NAME | 'fragment' | 'query' | 'mutation' | 'subscription' | 'schema' | 'scalar' | 'type' |
143-
'interface' | 'implements' | 'enum' | 'union' | 'input' | 'extend' | 'directive' | 'on'
143+
'interface' | 'implements' | 'enum' | 'union' | 'input' | 'extend' | 'directive' | 'on' | 'repeatable'
144144
{
145145
mixin="com.intellij.lang.jsgraphql.psi.impl.GraphQLReferenceMixin"
146146
implements="com.intellij.lang.jsgraphql.psi.GraphQLReferenceElement"

src/test/com/intellij/lang/jsgraphql/parser/GraphQLParserTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public void testEmoji() {
4747
doTest(true, true);
4848
}
4949

50+
public void testKeywordsAsIdentifiers() {
51+
doTest(true, true);
52+
}
53+
5054
@Override
5155
protected String getTestDataPath() {
5256
return "test-resources/testData/graphql/parser";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type Foo {
2+
type: Boolean
3+
repeatable: Boolean
4+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
GraphQL(0,54)
2+
GraphQLObjectTypeDefinitionImpl(OBJECT_TYPE_DEFINITION)(0,54)
3+
PsiElement(type)('type')(0,4)
4+
PsiWhiteSpace(' ')(4,5)
5+
GraphQLTypeNameDefinitionImpl(TYPE_NAME_DEFINITION)(5,8)
6+
GraphQLIdentifierImpl(IDENTIFIER)(5,8)
7+
PsiElement(NAME)('Foo')(5,8)
8+
PsiWhiteSpace(' ')(8,9)
9+
GraphQLFieldsDefinitionImpl(FIELDS_DEFINITION)(9,54)
10+
PsiElement({)('{')(9,10)
11+
PsiWhiteSpace('\n ')(10,15)
12+
GraphQLFieldDefinitionImpl(FIELD_DEFINITION)(15,28)
13+
GraphQLIdentifierImpl(IDENTIFIER)(15,19)
14+
PsiElement(type)('type')(15,19)
15+
PsiElement(:)(':')(19,20)
16+
PsiWhiteSpace(' ')(20,21)
17+
GraphQLTypeNameImpl(TYPE_NAME)(21,28)
18+
GraphQLIdentifierImpl(IDENTIFIER)(21,28)
19+
PsiElement(NAME)('Boolean')(21,28)
20+
PsiWhiteSpace('\n ')(28,33)
21+
GraphQLFieldDefinitionImpl(FIELD_DEFINITION)(33,52)
22+
GraphQLIdentifierImpl(IDENTIFIER)(33,43)
23+
PsiElement(repeatable)('repeatable')(33,43)
24+
PsiElement(:)(':')(43,44)
25+
PsiWhiteSpace(' ')(44,45)
26+
GraphQLTypeNameImpl(TYPE_NAME)(45,52)
27+
GraphQLIdentifierImpl(IDENTIFIER)(45,52)
28+
PsiElement(NAME)('Boolean')(45,52)
29+
PsiWhiteSpace('\n')(52,53)
30+
PsiElement(})('}')(53,54)

0 commit comments

Comments
 (0)