Skip to content

Commit

Permalink
fix triple quote comment syntax (#3529)
Browse files Browse the repository at this point in the history
  • Loading branch information
acao authored Feb 4, 2024
1 parent 28a101f commit a38152e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-pots-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vscode-graphql-syntax': patch
---

fix triple double quote comment syntax by disabling inline double quote js strings for now
12 changes: 6 additions & 6 deletions packages/vscode-graphql-syntax/grammars/graphql.js.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"patterns": [
{
"contentName": "meta.embedded.block.graphql",
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental)|(/\\* GraphQL \\*/))\\s*\\(?\\s*(`|'|\")",
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental)|(/\\* GraphQL \\*/))\\s*\\(?\\s*(`|')",
"beginCaptures": {
"1": {
"name": "variable.other.class.js"
Expand All @@ -22,7 +22,7 @@
"name": "punctuation.definition.string.template.begin.js"
}
},
"end": "(`|'|\")",
"end": "(`|')",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.template.end.js"
Expand All @@ -36,7 +36,7 @@
},
{
"contentName": "meta.embedded.block.graphql",
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental))\\s*\\(?\\s*(?:<.*>)(`|'|\")",
"begin": "\\s*+(?:(?:(Relay)\\??\\.)(QL)|(gql|graphql|graphql\\.experimental))\\s*\\(?\\s*(?:<.*>)(`|')",
"beginCaptures": {
"1": {
"name": "variable.other.class.js"
Expand All @@ -51,7 +51,7 @@
"name": "punctuation.definition.string.template.begin.js"
}
},
"end": "(`|'|\")",
"end": "(`|')",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.template.end.js"
Expand All @@ -66,7 +66,7 @@
{
"name": "taggedTemplates",
"contentName": "meta.embedded.block.graphql",
"begin": "(`|'|\")(#graphql)",
"begin": "(`|')(#graphql)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.string.template.begin.js"
Expand All @@ -75,7 +75,7 @@
"name": "comment.line.graphql.js"
}
},
"end": "(`|'|\")",
"end": "(`|')",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.template.end.js"
Expand Down
2 changes: 2 additions & 0 deletions packages/vscode-graphql-syntax/tests/__fixtures__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const graphql = graphql`
`;

const graphql = graphql(`
""" this is a comment """
query {
user(id: "5", name: ${variable}) {
something
Expand Down Expand Up @@ -70,6 +71,7 @@ const queryWithInlineComment = `

const queryWithLeadingComment = /* GraphQL */ `
query {
""" this is a comment """
user(id: "5", name: boolean) {
something
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ graphql | entity.name.function.tagged-template.js
( |
\` | punctuation.definition.string.template.begin.js
| meta.embedded.block.graphql
""" | meta.embedded.block.graphql comment.line.graphql.js punctuation.whitespace.comment.leading.graphql
this is a comment | meta.embedded.block.graphql comment.line.graphql.js
""" | meta.embedded.block.graphql comment.line.graphql.js
| meta.embedded.block.graphql
query | meta.embedded.block.graphql keyword.operation.graphql
| meta.embedded.block.graphql meta.selectionset.graphql
{ | meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
Expand Down Expand Up @@ -292,6 +296,10 @@ query | meta.embedded.block.graphql keyword.ope
| meta.embedded.block.graphql meta.selectionset.graphql
{ | meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql
| meta.embedded.block.graphql meta.selectionset.graphql
""" | meta.embedded.block.graphql meta.selectionset.graphql comment.line.graphql.js punctuation.whitespace.comment.leading.graphql
this is a comment | meta.embedded.block.graphql meta.selectionset.graphql comment.line.graphql.js
""" | meta.embedded.block.graphql meta.selectionset.graphql comment.line.graphql.js
| meta.embedded.block.graphql meta.selectionset.graphql
user | meta.embedded.block.graphql meta.selectionset.graphql variable.graphql
( | meta.embedded.block.graphql meta.selectionset.graphql meta.arguments.graphql meta.brace.round.directive.graphql
id | meta.embedded.block.graphql meta.selectionset.graphql meta.arguments.graphql variable.parameter.graphql
Expand Down

0 comments on commit a38152e

Please sign in to comment.