Skip to content

Commit defc126

Browse files
authored
Revert "fix: Fix vscode-graphql-syntax’s grammar to support string literals on separate lines" (#3543)
* Revert "fix: Fix vscode-graphql-syntax’s grammar to support string literals o…" This reverts commit e502c41.
1 parent 04b44fa commit defc126

File tree

7 files changed

+222
-454
lines changed

7 files changed

+222
-454
lines changed

.changeset/famous-ads-jam.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"vscode-graphql-syntax": patch
3+
"vscode-graphql": patch
4+
---
5+
6+
Temporarily revert a syntax highlighting bugfix that caused more bugs

packages/vscode-graphql-syntax/grammars/graphql.js.json

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,39 @@
44
"patterns": [
55
{
66
"contentName": "meta.embedded.block.graphql",
7-
"begin": "(?<=(?:(?:Relay\\??\\.)QL|gql|graphql|graphql\\.experimental)\\s*(?:<.*>)?\\s*)\\(",
8-
"end": "\\)",
7+
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental)|(/\\* GraphQL \\*/))\\s*\\(?\\s*(`|')",
8+
"beginCaptures": {
9+
"1": {
10+
"name": "variable.other.class.js"
11+
},
12+
"2": {
13+
"name": "entity.name.function.tagged-template.js"
14+
},
15+
"3": {
16+
"name": "entity.name.function.tagged-template.js"
17+
},
18+
"4": {
19+
"name": "comment.graphql.js"
20+
},
21+
"5": {
22+
"name": "punctuation.definition.string.template.begin.js"
23+
}
24+
},
25+
"end": "(`|')",
26+
"endCaptures": {
27+
"0": {
28+
"name": "punctuation.definition.string.template.end.js"
29+
}
30+
},
931
"patterns": [
1032
{
11-
"begin": "(`|')",
12-
"end": "(`|')",
13-
"beginCaptures": {
14-
"0": {
15-
"name": "punctuation.definition.string.template.begin.js"
16-
}
17-
},
18-
"endCaptures": {
19-
"0": {
20-
"name": "punctuation.definition.string.template.end.js"
21-
}
22-
},
23-
"patterns": [
24-
{
25-
"include": "source.graphql"
26-
}
27-
]
33+
"include": "source.graphql"
2834
}
2935
]
3036
},
3137
{
3238
"contentName": "meta.embedded.block.graphql",
33-
"begin": "\\s*+(?:(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental)\\s*(?:<.*>)?\\s*)|(/\\* GraphQL \\*/))\\s*(`|')",
39+
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental))\\s*\\(?\\s*(?:<.*>)(`|')",
3440
"beginCaptures": {
3541
"1": {
3642
"name": "variable.other.class.js"
@@ -42,9 +48,6 @@
4248
"name": "entity.name.function.tagged-template.js"
4349
},
4450
"4": {
45-
"name": "comment.graphql.js"
46-
},
47-
"5": {
4851
"name": "punctuation.definition.string.template.begin.js"
4952
}
5053
},

packages/vscode-graphql-syntax/tests/__fixtures__/test-js.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,6 @@ const Component = () => {
2626
};
2727
```
2828

29-
```js
30-
const variable = 1;
31-
32-
const queryA = graphql(`
33-
query {
34-
something(arg: ${variable})
35-
}
36-
`);
37-
38-
const queryB = graphql(
39-
`
40-
query {
41-
something(arg: ${variable})
42-
}
43-
`
44-
);
45-
46-
const queryC = graphql(
47-
'query { something(arg: ${variable}) }'
48-
);
49-
```
50-
51-
```ts
52-
const variable: number = 1;
53-
54-
const queryA = graphql(`
55-
query {
56-
something(arg: ${variable})
57-
}
58-
`);
59-
60-
const queryB = graphql(
61-
`
62-
query {
63-
something(arg: ${variable})
64-
}
65-
`
66-
);
67-
68-
const queryC = graphql(
69-
'query { something(arg: ${variable}) }'
70-
);
71-
```
72-
7329
### svelte
7430

7531
```svelte

packages/vscode-graphql-syntax/tests/__fixtures__/test.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,8 @@ const graphql = graphql(`
3737
}
3838
`);
3939

40-
const graphql = graphql(
41-
`
42-
query($id: ID!) { test }
43-
`,
44-
[var1, var2]
45-
);
46-
4740
const query = /* GraphQL */ 'query { id } ';
48-
const query = graphql('query($id: ID!) { id } ');
49-
const query = graphql(
50-
'query($id: ID!) { test }'
51-
);
41+
const query = graphql('query { id } ');
5242

5343
const queryWithInlineComment = `#graphql
5444
query {
@@ -69,6 +59,7 @@ const queryWithInlineComment = `#graphql
6959
}
7060
}
7161
`;
62+
// TODO: fix this
7263
const queryWithInlineComment = `
7364
#graphql
7465
query {

packages/vscode-graphql-syntax/tests/__fixtures__/test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,9 @@ const query = graphql<SomeGeneric>`
2525
}
2626
`;
2727

28+
// TODO: Fix this
2829
const query = graphql<Generic>('query { id }');
2930

30-
const query = graphql(
31-
'query { id }'
32-
);
33-
34-
const query = graphql<Generic>(
35-
'query { id }'
36-
);
37-
38-
const query = graphql(`
39-
query { id }
40-
`);
41-
42-
const query = graphql(
43-
`
44-
query { id }
45-
`,
46-
[var1, var2]
47-
);
48-
4931
const queryWithInlineComment = `#graphql
5032
query {
5133
user(id: "5", name: boolean) {

0 commit comments

Comments
 (0)