Sfoglia il codice sorgente

add tokenizer for graphql language variables

Rikki Schulte 5 anni fa
parent
commit
3655d9a96a
1 ha cambiato i file con 18 aggiunte e 4 eliminazioni
  1. 18 4
      src/graphql/graphql.ts

+ 18 - 4
src/graphql/graphql.ts

@@ -69,16 +69,30 @@ export const language = <ILanguage>{
 	// The main tokenizer for our languages
 	tokenizer: {
 		root: [
-			// identifiers and keywords
+
+			// fields and argument names
 			[
-				/[a-z_$][\w$]*/,
+				/[a-z_][\w$]*/,
 				{
 					cases: {
 						'@keywords': 'keyword',
-						'@default': 'identifier',
+						'@default': 'key.identifier',
 					},
 				},
 			],
+
+			// identify typed input variables
+			[
+				/[$][\w$]*/,
+				{
+					cases: {
+						'@keywords': 'keyword',
+						'@default': 'argument.identifier',
+					},
+				},
+			],
+
+			// to show class names nicely
 			[
 				/[A-Z][\w\$]*/,
 				{
@@ -87,7 +101,7 @@ export const language = <ILanguage>{
 						'@default': 'type.identifier',
 					},
 				},
-			], // to show class names nicely
+			],
 
 			// whitespace
 			{ include: '@whitespace' },