From a562c96fa3953d0301ad7b610028fa6c4a779bf6 Mon Sep 17 00:00:00 2001 From: Gasser-Aly <105317851+Gasser-Aly@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:11:29 -0500 Subject: [PATCH] fix: block strings syntax highlighting in cm6-graphql (#3505) * fix: block strings syntax highlighting in cm6-graphql * make Description tagged as string --- .changeset/new-tools-unite.md | 5 ++++ packages/cm6-graphql/__tests__/cases.txt | 32 ++++++++++++++++++++++++ packages/cm6-graphql/src/language.ts | 1 + packages/cm6-graphql/src/syntax.grammar | 5 +++- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .changeset/new-tools-unite.md diff --git a/.changeset/new-tools-unite.md b/.changeset/new-tools-unite.md new file mode 100644 index 00000000000..d9140ff2a5b --- /dev/null +++ b/.changeset/new-tools-unite.md @@ -0,0 +1,5 @@ +--- +'cm6-graphql': patch +--- + +fix: block strings syntax highlighting diff --git a/packages/cm6-graphql/__tests__/cases.txt b/packages/cm6-graphql/__tests__/cases.txt index c6a8db77228..241700a124d 100644 --- a/packages/cm6-graphql/__tests__/cases.txt +++ b/packages/cm6-graphql/__tests__/cases.txt @@ -113,3 +113,35 @@ Document( Document( OperationDefinition(SelectionSet("{",Selection(Field(FieldName)),Selection(Field(FieldName,SelectionSet("{",Selection(Field(FieldName)),"}"))),"}")) ) + + + +# Test case for blockStringCharacter in a Description + +""" +This is a block string description +with multiple lines. +It can contain any character except for \""". +""" +type Example { + id: ID +} + +==> + +Document( + TypeSystemDefinition( + TypeDefinition( + ObjectTypeDefinition( + Description(StringValue), + TypeKeyword(type), + Name, + FieldsDefinition( + "{", + FieldDefinition(Name, NamedType(Name)), + "}" + ) + ) + ) + ) +) diff --git a/packages/cm6-graphql/src/language.ts b/packages/cm6-graphql/src/language.ts index 5a38e994d3b..cbec9695f7a 100644 --- a/packages/cm6-graphql/src/language.ts +++ b/packages/cm6-graphql/src/language.ts @@ -20,6 +20,7 @@ export const graphqlLanguage = LRLanguage.define({ styleTags({ Variable: t.variableName, BooleanValue: t.bool, + Description: t.string, StringValue: t.string, Comment: t.lineComment, IntValue: t.integer, diff --git a/packages/cm6-graphql/src/syntax.grammar b/packages/cm6-graphql/src/syntax.grammar index 355ef280dd3..71c1c0838aa 100644 --- a/packages/cm6-graphql/src/syntax.grammar +++ b/packages/cm6-graphql/src/syntax.grammar @@ -393,7 +393,10 @@ Name { name } // https://spec.graphql.org/October2021/#BlockStringCharacter blockStringCharacter { '\\"""' | - '"' '"'? !["] + '"' '"'? !["] | + stringCharacter | + '\n' | + '\r\n' } // https://spec.graphql.org/October2021/#EscapedUnicode