Skip to content

Commit 342a003

Browse files
Java: Added support for constants (#3507)
1 parent 05ee042 commit 342a003

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

components/prism-java.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
'operator': {
5656
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
5757
lookbehind: true
58-
}
58+
},
59+
'constant': /\b[A-Z][A-Z_\d]+\b/
5960
});
6061

6162
Prism.languages.insertBefore('java', 'string', {

components/prism-java.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-scala.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ Prism.languages.insertBefore('scala', 'triple-quoted-string', {
4747

4848
delete Prism.languages.scala['class-name'];
4949
delete Prism.languages.scala['function'];
50+
delete Prism.languages.scala['constant'];

components/prism-scala.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/java/annotation_feature.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
["punctuation", "("],
1717
"value",
1818
["operator", "="],
19-
"SOURCE",
19+
["constant", "SOURCE"],
2020
["punctuation", ")"],
2121

2222
["annotation", "@Target"],
2323
["punctuation", "("],
2424
"value",
2525
["operator", "="],
2626
["punctuation", "{"],
27-
"PACKAGE",
27+
["constant", "PACKAGE"],
2828
["punctuation", ","],
29-
"TYPE",
29+
["constant", "TYPE"],
3030
["punctuation", "}"],
3131
["punctuation", ")"]
3232
]
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
public class Test {
2+
private static final String AAAA = "aaaaaa";
3+
4+
private String str = "1";
5+
6+
public static void main(String[] args) {
7+
str += AAAA + "AAAA";
8+
}
9+
}
10+
11+
----------------------------------------------------
12+
13+
[
14+
["keyword", "public"],
15+
["keyword", "class"],
16+
["class-name", ["Test"]],
17+
["punctuation", "{"],
18+
19+
["keyword", "private"],
20+
["keyword", "static"],
21+
["keyword", "final"],
22+
["class-name", ["String"]],
23+
["constant", "AAAA"],
24+
["operator", "="],
25+
["string", "\"aaaaaa\""],
26+
["punctuation", ";"],
27+
28+
["keyword", "private"],
29+
["class-name", ["String"]],
30+
" str ",
31+
["operator", "="],
32+
["string", "\"1\""],
33+
["punctuation", ";"],
34+
35+
["keyword", "public"],
36+
["keyword", "static"],
37+
["keyword", "void"],
38+
["function", "main"],
39+
["punctuation", "("],
40+
["class-name", ["String"]],
41+
["punctuation", "["],
42+
["punctuation", "]"],
43+
" args",
44+
["punctuation", ")"],
45+
["punctuation", "{"],
46+
47+
"\r\n str ",
48+
["operator", "+="],
49+
["constant", "AAAA"],
50+
["operator", "+"],
51+
["string", "\"AAAA\""],
52+
["punctuation", ";"],
53+
54+
["punctuation", "}"],
55+
56+
["punctuation", "}"]
57+
]
58+
59+
----------------------------------------------------
60+
61+
Checks for all constants.

0 commit comments

Comments
 (0)