java.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.conf = {
  9. // the default separators except `@$`
  10. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  11. comments: {
  12. lineComment: '//',
  13. blockComment: ['/*', '*/'],
  14. },
  15. brackets: [
  16. ['{', '}'],
  17. ['[', ']'],
  18. ['(', ')'],
  19. ],
  20. autoClosingPairs: [
  21. { open: '{', close: '}' },
  22. { open: '[', close: ']' },
  23. { open: '(', close: ')' },
  24. { open: '"', close: '"' },
  25. { open: '\'', close: '\'' },
  26. ],
  27. surroundingPairs: [
  28. { open: '{', close: '}' },
  29. { open: '[', close: ']' },
  30. { open: '(', close: ')' },
  31. { open: '"', close: '"' },
  32. { open: '\'', close: '\'' },
  33. { open: '<', close: '>' },
  34. ],
  35. folding: {
  36. markers: {
  37. start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
  38. end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
  39. }
  40. }
  41. };
  42. exports.language = {
  43. defaultToken: '',
  44. tokenPostfix: '.java',
  45. keywords: [
  46. 'abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default',
  47. 'goto', 'package', 'synchronized', 'boolean', 'do', 'if', 'private',
  48. 'this', 'break', 'double', 'implements', 'protected', 'throw', 'byte',
  49. 'else', 'import', 'public', 'throws', 'case', 'enum', 'instanceof', 'return',
  50. 'transient', 'catch', 'extends', 'int', 'short', 'try', 'char', 'final',
  51. 'interface', 'static', 'void', 'class', 'finally', 'long', 'strictfp',
  52. 'volatile', 'const', 'float', 'native', 'super', 'while', 'true', 'false'
  53. ],
  54. operators: [
  55. '=', '>', '<', '!', '~', '?', ':',
  56. '==', '<=', '>=', '!=', '&&', '||', '++', '--',
  57. '+', '-', '*', '/', '&', '|', '^', '%', '<<',
  58. '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
  59. '^=', '%=', '<<=', '>>=', '>>>='
  60. ],
  61. // we include these common regular expressions
  62. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  63. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  64. digits: /\d+(_+\d+)*/,
  65. octaldigits: /[0-7]+(_+[0-7]+)*/,
  66. binarydigits: /[0-1]+(_+[0-1]+)*/,
  67. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  68. // The main tokenizer for our languages
  69. tokenizer: {
  70. root: [
  71. // identifiers and keywords
  72. [/[a-zA-Z_$][\w$]*/, {
  73. cases: {
  74. '@keywords': { token: 'keyword.$0' },
  75. '@default': 'identifier'
  76. }
  77. }],
  78. // whitespace
  79. { include: '@whitespace' },
  80. // delimiters and operators
  81. [/[{}()\[\]]/, '@brackets'],
  82. [/[<>](?!@symbols)/, '@brackets'],
  83. [/@symbols/, {
  84. cases: {
  85. '@operators': 'delimiter',
  86. '@default': ''
  87. }
  88. }],
  89. // @ annotations.
  90. [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
  91. // numbers
  92. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
  93. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
  94. [/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
  95. [/0(@octaldigits)[Ll]?/, 'number.octal'],
  96. [/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
  97. [/(@digits)[fFdD]/, 'number.float'],
  98. [/(@digits)[lL]?/, 'number'],
  99. // delimiter: after number because of .\d floats
  100. [/[;,.]/, 'delimiter'],
  101. // strings
  102. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  103. [/"/, 'string', '@string'],
  104. // characters
  105. [/'[^\\']'/, 'string'],
  106. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  107. [/'/, 'string.invalid']
  108. ],
  109. whitespace: [
  110. [/[ \t\r\n]+/, ''],
  111. [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
  112. [/\/\*/, 'comment', '@comment'],
  113. [/\/\/.*$/, 'comment'],
  114. ],
  115. comment: [
  116. [/[^\/*]+/, 'comment'],
  117. // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
  118. // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
  119. [/\*\//, 'comment', '@pop'],
  120. [/[\/*]/, 'comment']
  121. ],
  122. //Identical copy of comment above, except for the addition of .doc
  123. javadoc: [
  124. [/[^\/*]+/, 'comment.doc'],
  125. // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
  126. [/\/\*/, 'comment.doc.invalid'],
  127. [/\*\//, 'comment.doc', '@pop'],
  128. [/[\/*]/, 'comment.doc']
  129. ],
  130. string: [
  131. [/[^\\"]+/, 'string'],
  132. [/@escapes/, 'string.escape'],
  133. [/\\./, 'string.escape.invalid'],
  134. [/"/, 'string', '@pop']
  135. ],
  136. },
  137. };
  138. });