1 | (function (Prism) {
|
2 |
|
3 | var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|null|open|opens|package|private|protected|provides|public|record|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
|
4 |
|
5 |
|
6 | var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
|
7 |
|
8 | Prism.languages.java = Prism.languages.extend('clike', {
|
9 | 'class-name': [
|
10 | className,
|
11 |
|
12 |
|
13 |
|
14 | /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
|
15 | ],
|
16 | 'keyword': keywords,
|
17 | 'function': [
|
18 | Prism.languages.clike.function,
|
19 | {
|
20 | pattern: /(\:\:)[a-z_]\w*/,
|
21 | lookbehind: true
|
22 | }
|
23 | ],
|
24 | 'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
25 | 'operator': {
|
26 | pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
27 | lookbehind: true
|
28 | }
|
29 | });
|
30 |
|
31 | Prism.languages.insertBefore('java', 'string', {
|
32 | 'triple-quoted-string': {
|
33 |
|
34 | pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
35 | greedy: true,
|
36 | alias: 'string'
|
37 | }
|
38 | });
|
39 |
|
40 | Prism.languages.insertBefore('java', 'class-name', {
|
41 | 'annotation': {
|
42 | alias: 'punctuation',
|
43 | pattern: /(^|[^.])@\w+/,
|
44 | lookbehind: true
|
45 | },
|
46 | 'namespace': {
|
47 | pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(?:\.[a-z]\w*)+/,
|
48 | lookbehind: true,
|
49 | inside: {
|
50 | 'punctuation': /\./,
|
51 | }
|
52 | },
|
53 | 'generics': {
|
54 | pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
|
55 | inside: {
|
56 | 'class-name': className,
|
57 | 'keyword': keywords,
|
58 | 'punctuation': /[<>(),.:]/,
|
59 | 'operator': /[?&|]/
|
60 | }
|
61 | }
|
62 | });
|
63 | }(Prism));
|