graphql.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/graphql/graphql',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. comments: {
  11. lineComment: '#'
  12. },
  13. brackets: [
  14. ['{', '}'],
  15. ['[', ']'],
  16. ['(', ')']
  17. ],
  18. autoClosingPairs: [
  19. { open: '{', close: '}' },
  20. { open: '[', close: ']' },
  21. { open: '(', close: ')' },
  22. { open: '"""', close: '"""', notIn: ['string', 'comment'] },
  23. { open: '"', close: '"', notIn: ['string', 'comment'] }
  24. ],
  25. surroundingPairs: [
  26. { open: '{', close: '}' },
  27. { open: '[', close: ']' },
  28. { open: '(', close: ')' },
  29. { open: '"""', close: '"""' },
  30. { open: '"', close: '"' }
  31. ],
  32. folding: {
  33. offSide: true
  34. }
  35. };
  36. exports.language = {
  37. // Set defaultToken to invalid to see what you do not tokenize yet
  38. defaultToken: 'invalid',
  39. tokenPostfix: '.gql',
  40. keywords: [
  41. 'null',
  42. 'true',
  43. 'false',
  44. 'query',
  45. 'mutation',
  46. 'subscription',
  47. 'extend',
  48. 'schema',
  49. 'directive',
  50. 'scalar',
  51. 'type',
  52. 'interface',
  53. 'union',
  54. 'enum',
  55. 'input',
  56. 'implements',
  57. 'fragment',
  58. 'on'
  59. ],
  60. typeKeywords: ['Int', 'Float', 'String', 'Boolean', 'ID'],
  61. directiveLocations: [
  62. 'SCHEMA',
  63. 'SCALAR',
  64. 'OBJECT',
  65. 'FIELD_DEFINITION',
  66. 'ARGUMENT_DEFINITION',
  67. 'INTERFACE',
  68. 'UNION',
  69. 'ENUM',
  70. 'ENUM_VALUE',
  71. 'INPUT_OBJECT',
  72. 'INPUT_FIELD_DEFINITION',
  73. 'QUERY',
  74. 'MUTATION',
  75. 'SUBSCRIPTION',
  76. 'FIELD',
  77. 'FRAGMENT_DEFINITION',
  78. 'FRAGMENT_SPREAD',
  79. 'INLINE_FRAGMENT',
  80. 'VARIABLE_DEFINITION'
  81. ],
  82. operators: ['=', '!', '?', ':', '&', '|'],
  83. // we include these common regular expressions
  84. symbols: /[=!?:&|]+/,
  85. // https://facebook.github.io/graphql/draft/#sec-String-Value
  86. escapes: /\\(?:["\\\/bfnrt]|u[0-9A-Fa-f]{4})/,
  87. // The main tokenizer for our languages
  88. tokenizer: {
  89. root: [
  90. // fields and argument names
  91. [
  92. /[a-z_][\w$]*/,
  93. {
  94. cases: {
  95. '@keywords': 'keyword',
  96. '@default': 'key.identifier'
  97. }
  98. }
  99. ],
  100. // identify typed input variables
  101. [
  102. /[$][\w$]*/,
  103. {
  104. cases: {
  105. '@keywords': 'keyword',
  106. '@default': 'argument.identifier'
  107. }
  108. }
  109. ],
  110. // to show class names nicely
  111. [
  112. /[A-Z][\w\$]*/,
  113. {
  114. cases: {
  115. '@typeKeywords': 'keyword',
  116. '@default': 'type.identifier'
  117. }
  118. }
  119. ],
  120. // whitespace
  121. { include: '@whitespace' },
  122. // delimiters and operators
  123. [/[{}()\[\]]/, '@brackets'],
  124. [/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
  125. // @ annotations.
  126. // As an example, we emit a debugging log message on these tokens.
  127. // Note: message are supressed during the first load -- change some lines to see them.
  128. [/@\s*[a-zA-Z_\$][\w\$]*/, { token: 'annotation', log: 'annotation token: $0' }],
  129. // numbers
  130. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  131. [/0[xX][0-9a-fA-F]+/, 'number.hex'],
  132. [/\d+/, 'number'],
  133. // delimiter: after number because of .\d floats
  134. [/[;,.]/, 'delimiter'],
  135. [/"""/, { token: 'string', next: '@mlstring', nextEmbedded: 'markdown' }],
  136. // strings
  137. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  138. [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
  139. ],
  140. mlstring: [
  141. [/[^"]+/, 'string'],
  142. ['"""', { token: 'string', next: '@pop', nextEmbedded: '@pop' }]
  143. ],
  144. string: [
  145. [/[^\\"]+/, 'string'],
  146. [/@escapes/, 'string.escape'],
  147. [/\\./, 'string.escape.invalid'],
  148. [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  149. ],
  150. whitespace: [
  151. [/[ \t\r\n]+/, ''],
  152. [/#.*$/, 'comment']
  153. ]
  154. }
  155. };
  156. });