java.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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/java/java',["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. // the default separators except `@$`
  11. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  12. comments: {
  13. lineComment: '//',
  14. blockComment: ['/*', '*/']
  15. },
  16. brackets: [
  17. ['{', '}'],
  18. ['[', ']'],
  19. ['(', ')']
  20. ],
  21. autoClosingPairs: [
  22. { open: '{', close: '}' },
  23. { open: '[', close: ']' },
  24. { open: '(', close: ')' },
  25. { open: '"', close: '"' },
  26. { open: "'", close: "'" }
  27. ],
  28. surroundingPairs: [
  29. { open: '{', close: '}' },
  30. { open: '[', close: ']' },
  31. { open: '(', close: ')' },
  32. { open: '"', close: '"' },
  33. { open: "'", close: "'" },
  34. { open: '<', close: '>' }
  35. ],
  36. folding: {
  37. markers: {
  38. start: new RegExp('^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'),
  39. end: new RegExp('^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))')
  40. }
  41. }
  42. };
  43. exports.language = {
  44. defaultToken: '',
  45. tokenPostfix: '.java',
  46. keywords: [
  47. 'abstract',
  48. 'continue',
  49. 'for',
  50. 'new',
  51. 'switch',
  52. 'assert',
  53. 'default',
  54. 'goto',
  55. 'package',
  56. 'synchronized',
  57. 'boolean',
  58. 'do',
  59. 'if',
  60. 'private',
  61. 'this',
  62. 'break',
  63. 'double',
  64. 'implements',
  65. 'protected',
  66. 'throw',
  67. 'byte',
  68. 'else',
  69. 'import',
  70. 'public',
  71. 'throws',
  72. 'case',
  73. 'enum',
  74. 'instanceof',
  75. 'return',
  76. 'transient',
  77. 'catch',
  78. 'extends',
  79. 'int',
  80. 'short',
  81. 'try',
  82. 'char',
  83. 'final',
  84. 'interface',
  85. 'static',
  86. 'void',
  87. 'class',
  88. 'finally',
  89. 'long',
  90. 'strictfp',
  91. 'volatile',
  92. 'const',
  93. 'float',
  94. 'native',
  95. 'super',
  96. 'while',
  97. 'true',
  98. 'false'
  99. ],
  100. operators: [
  101. '=',
  102. '>',
  103. '<',
  104. '!',
  105. '~',
  106. '?',
  107. ':',
  108. '==',
  109. '<=',
  110. '>=',
  111. '!=',
  112. '&&',
  113. '||',
  114. '++',
  115. '--',
  116. '+',
  117. '-',
  118. '*',
  119. '/',
  120. '&',
  121. '|',
  122. '^',
  123. '%',
  124. '<<',
  125. '>>',
  126. '>>>',
  127. '+=',
  128. '-=',
  129. '*=',
  130. '/=',
  131. '&=',
  132. '|=',
  133. '^=',
  134. '%=',
  135. '<<=',
  136. '>>=',
  137. '>>>='
  138. ],
  139. // we include these common regular expressions
  140. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  141. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  142. digits: /\d+(_+\d+)*/,
  143. octaldigits: /[0-7]+(_+[0-7]+)*/,
  144. binarydigits: /[0-1]+(_+[0-1]+)*/,
  145. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  146. // The main tokenizer for our languages
  147. tokenizer: {
  148. root: [
  149. // identifiers and keywords
  150. [
  151. /[a-zA-Z_$][\w$]*/,
  152. {
  153. cases: {
  154. '@keywords': { token: 'keyword.$0' },
  155. '@default': 'identifier'
  156. }
  157. }
  158. ],
  159. // whitespace
  160. { include: '@whitespace' },
  161. // delimiters and operators
  162. [/[{}()\[\]]/, '@brackets'],
  163. [/[<>](?!@symbols)/, '@brackets'],
  164. [
  165. /@symbols/,
  166. {
  167. cases: {
  168. '@operators': 'delimiter',
  169. '@default': ''
  170. }
  171. }
  172. ],
  173. // @ annotations.
  174. [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
  175. // numbers
  176. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
  177. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
  178. [/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
  179. [/0(@octaldigits)[Ll]?/, 'number.octal'],
  180. [/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
  181. [/(@digits)[fFdD]/, 'number.float'],
  182. [/(@digits)[lL]?/, 'number'],
  183. // delimiter: after number because of .\d floats
  184. [/[;,.]/, 'delimiter'],
  185. // strings
  186. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  187. [/"/, 'string', '@string'],
  188. // characters
  189. [/'[^\\']'/, 'string'],
  190. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  191. [/'/, 'string.invalid']
  192. ],
  193. whitespace: [
  194. [/[ \t\r\n]+/, ''],
  195. [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
  196. [/\/\*/, 'comment', '@comment'],
  197. [/\/\/.*$/, 'comment']
  198. ],
  199. comment: [
  200. [/[^\/*]+/, 'comment'],
  201. // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
  202. // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
  203. [/\*\//, 'comment', '@pop'],
  204. [/[\/*]/, 'comment']
  205. ],
  206. //Identical copy of comment above, except for the addition of .doc
  207. javadoc: [
  208. [/[^\/*]+/, 'comment.doc'],
  209. // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
  210. [/\/\*/, 'comment.doc.invalid'],
  211. [/\*\//, 'comment.doc', '@pop'],
  212. [/[\/*]/, 'comment.doc']
  213. ],
  214. string: [
  215. [/[^\\"]+/, 'string'],
  216. [/@escapes/, 'string.escape'],
  217. [/\\./, 'string.escape.invalid'],
  218. [/"/, 'string', '@pop']
  219. ]
  220. }
  221. };
  222. });