Skip to content

Commit 17e5911

Browse files
Pop type state when encountering punctuation for graphql (#1210)
Previously, something like `query \{ a, b \}` would have a resolve as a NameClass. We need to pop out of the type state when we encounter that { I added that simple example in graphql.actual locally for finding the bug, but reverted as it is covered by other cases (`otherField`, etc) Although just { would cover the actual issue, I thought it'd be best to be more open-ended, which handles all punctuation that might reasonably follow a type reference. fixes #1084
1 parent 893841b commit 17e5911

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lexers/embedded/graphql.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
</rule>
7777
</state>
7878
<state name="type">
79+
<rule pattern="[\{\}\(\)\[\]]">
80+
<token type="Punctuation"/>
81+
<pop depth="1"/>
82+
</rule>
7983
<rule pattern="[^\W\d]\w*">
8084
<token type="NameClass"/>
8185
<pop depth="1"/>

lexers/testdata/graphql.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{"type":"TextWhitespace","value":" "},
2828
{"type":"Punctuation","value":"{"},
2929
{"type":"TextWhitespace","value":"\n "},
30-
{"type":"NameClass","value":"name"},
30+
{"type":"NameProperty","value":"name"},
3131
{"type":"TextWhitespace","value":"\n "},
3232
{"type":"NameProperty","value":"friends"},
3333
{"type":"TextWhitespace","value":" "},
@@ -41,7 +41,7 @@
4141
{"type":"TextWhitespace","value":" "},
4242
{"type":"Punctuation","value":"{"},
4343
{"type":"TextWhitespace","value":"\n "},
44-
{"type":"NameClass","value":"name"},
44+
{"type":"NameProperty","value":"name"},
4545
{"type":"TextWhitespace","value":"\n "},
4646
{"type":"KeywordDeclaration","value":"..."},
4747
{"type":"NameProperty","value":"frag"},
@@ -110,7 +110,7 @@
110110
{"type":"LiteralString","value":"\"Use `newField`.\""},
111111
{"type":"Punctuation","value":")"},
112112
{"type":"TextWhitespace","value":"\n\n "},
113-
{"type":"NameClass","value":"otherField"},
113+
{"type":"NameProperty","value":"otherField"},
114114
{"type":"Punctuation","value":"("},
115115
{"type":"TextWhitespace","value":"\n "},
116116
{"type":"LiteralString","value":"\"Description for argument\""},

0 commit comments

Comments
 (0)