graphql.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/graphql/graphql.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "#"
  11. },
  12. brackets: [
  13. ["{", "}"],
  14. ["[", "]"],
  15. ["(", ")"]
  16. ],
  17. autoClosingPairs: [
  18. { open: "{", close: "}" },
  19. { open: "[", close: "]" },
  20. { open: "(", close: ")" },
  21. { open: '"""', close: '"""', notIn: ["string", "comment"] },
  22. { open: '"', close: '"', notIn: ["string", "comment"] }
  23. ],
  24. surroundingPairs: [
  25. { open: "{", close: "}" },
  26. { open: "[", close: "]" },
  27. { open: "(", close: ")" },
  28. { open: '"""', close: '"""' },
  29. { open: '"', close: '"' }
  30. ],
  31. folding: {
  32. offSide: true
  33. }
  34. };
  35. var language = {
  36. defaultToken: "invalid",
  37. tokenPostfix: ".gql",
  38. keywords: [
  39. "null",
  40. "true",
  41. "false",
  42. "query",
  43. "mutation",
  44. "subscription",
  45. "extend",
  46. "schema",
  47. "directive",
  48. "scalar",
  49. "type",
  50. "interface",
  51. "union",
  52. "enum",
  53. "input",
  54. "implements",
  55. "fragment",
  56. "on"
  57. ],
  58. typeKeywords: ["Int", "Float", "String", "Boolean", "ID"],
  59. directiveLocations: [
  60. "SCHEMA",
  61. "SCALAR",
  62. "OBJECT",
  63. "FIELD_DEFINITION",
  64. "ARGUMENT_DEFINITION",
  65. "INTERFACE",
  66. "UNION",
  67. "ENUM",
  68. "ENUM_VALUE",
  69. "INPUT_OBJECT",
  70. "INPUT_FIELD_DEFINITION",
  71. "QUERY",
  72. "MUTATION",
  73. "SUBSCRIPTION",
  74. "FIELD",
  75. "FRAGMENT_DEFINITION",
  76. "FRAGMENT_SPREAD",
  77. "INLINE_FRAGMENT",
  78. "VARIABLE_DEFINITION"
  79. ],
  80. operators: ["=", "!", "?", ":", "&", "|"],
  81. symbols: /[=!?:&|]+/,
  82. escapes: /\\(?:["\\\/bfnrt]|u[0-9A-Fa-f]{4})/,
  83. tokenizer: {
  84. root: [
  85. [
  86. /[a-z_][\w$]*/,
  87. {
  88. cases: {
  89. "@keywords": "keyword",
  90. "@default": "key.identifier"
  91. }
  92. }
  93. ],
  94. [
  95. /[$][\w$]*/,
  96. {
  97. cases: {
  98. "@keywords": "keyword",
  99. "@default": "argument.identifier"
  100. }
  101. }
  102. ],
  103. [
  104. /[A-Z][\w\$]*/,
  105. {
  106. cases: {
  107. "@typeKeywords": "keyword",
  108. "@default": "type.identifier"
  109. }
  110. }
  111. ],
  112. { include: "@whitespace" },
  113. [/[{}()\[\]]/, "@brackets"],
  114. [/@symbols/, { cases: { "@operators": "operator", "@default": "" } }],
  115. [/@\s*[a-zA-Z_\$][\w\$]*/, { token: "annotation", log: "annotation token: $0" }],
  116. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  117. [/0[xX][0-9a-fA-F]+/, "number.hex"],
  118. [/\d+/, "number"],
  119. [/[;,.]/, "delimiter"],
  120. [/"""/, { token: "string", next: "@mlstring", nextEmbedded: "markdown" }],
  121. [/"([^"\\]|\\.)*$/, "string.invalid"],
  122. [/"/, { token: "string.quote", bracket: "@open", next: "@string" }]
  123. ],
  124. mlstring: [
  125. [/[^"]+/, "string"],
  126. ['"""', { token: "string", next: "@pop", nextEmbedded: "@pop" }]
  127. ],
  128. string: [
  129. [/[^\\"]+/, "string"],
  130. [/@escapes/, "string.escape"],
  131. [/\\./, "string.escape.invalid"],
  132. [/"/, { token: "string.quote", bracket: "@close", next: "@pop" }]
  133. ],
  134. whitespace: [
  135. [/[ \t\r\n]+/, ""],
  136. [/#.*$/, "comment"]
  137. ]
  138. }
  139. };
  140. export {
  141. conf,
  142. language
  143. };