Improve Java syntax highlighting

This commit is contained in:
Clément Fournier
2017-09-24 03:16:44 +02:00
parent f784d85b92
commit 1451ff80a2
2 changed files with 18 additions and 3 deletions

View File

@ -38,6 +38,8 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter {
private static final String BRACE_PATTERN = "[{}]"; private static final String BRACE_PATTERN = "[{}]";
private static final String BRACKET_PATTERN = "[\\[]]"; private static final String BRACKET_PATTERN = "[\\[]]";
private static final String SEMICOLON_PATTERN = ";"; private static final String SEMICOLON_PATTERN = ";";
private static final String CLASS_IDENT_PATTERN = "\\b[A-Z][\\w_$]*\\b";
private static final String NUMBER_PATTERN = "\\b\\d+[fdlFDL]*\\b";
private static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\""; private static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\"";
private static final String SINGLELINE_COMMENT_PATTERN = "//[^\n]*"; private static final String SINGLELINE_COMMENT_PATTERN = "//[^\n]*";
private static final String MULTILINE_COMMENT_PATTERN = "/\\*.*?\\*/"; private static final String MULTILINE_COMMENT_PATTERN = "/\\*.*?\\*/";
@ -48,10 +50,12 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter {
+ "|(?<MULTILINECOMMENT>" + MULTILINE_COMMENT_PATTERN + ")" + "|(?<MULTILINECOMMENT>" + MULTILINE_COMMENT_PATTERN + ")"
+ "|(?<ANNOTATION>" + ANNOTATION_PATTERN + ")" + "|(?<ANNOTATION>" + ANNOTATION_PATTERN + ")"
+ "|(?<PAREN>" + PAREN_PATTERN + ")" + "|(?<PAREN>" + PAREN_PATTERN + ")"
+ "|(?<NUMBER>" + NUMBER_PATTERN + ")"
+ "|(?<BRACE>" + BRACE_PATTERN + ")" + "|(?<BRACE>" + BRACE_PATTERN + ")"
+ "|(?<BRACKET>" + BRACKET_PATTERN + ")" + "|(?<BRACKET>" + BRACKET_PATTERN + ")"
+ "|(?<SEMICOLON>" + SEMICOLON_PATTERN + ")" + "|(?<SEMICOLON>" + SEMICOLON_PATTERN + ")"
+ "|(?<KEYWORD>" + KEYWORD_PATTERN + ")" + "|(?<KEYWORD>" + KEYWORD_PATTERN + ")"
+ "|(?<CLASSIDENT>" + CLASS_IDENT_PATTERN + ")"
+ "|(?<STRING>" + STRING_PATTERN + ")", + "|(?<STRING>" + STRING_PATTERN + ")",
Pattern.DOTALL Pattern.DOTALL
); );
@ -65,8 +69,10 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter {
map.put("KEYWORD", "keyword"); map.put("KEYWORD", "keyword");
map.put("PAREN", "paren"); map.put("PAREN", "paren");
map.put("BRACE", "brace"); map.put("BRACE", "brace");
map.put("NUMBER", "number");
map.put("BRACKET", "bracket"); map.put("BRACKET", "bracket");
map.put("SEMICOLON", "semicolon"); map.put("SEMICOLON", "semicolon");
map.put("CLASSIDENT", "class-ident");
map.put("STRING", "string"); map.put("STRING", "string");
map.put("ANNOTATION", "annotation"); map.put("ANNOTATION", "annotation");
return Collections.unmodifiableMap(map); return Collections.unmodifiableMap(map);

View File

@ -1,7 +1,7 @@
/* Theme based on Solarized Light for Eclipse, http://www.eclipsecolorthemes.org/?view=theme&id=1013 */ /* Theme based on Solarized Light for Eclipse, http://www.eclipsecolorthemes.org/?view=theme&id=1013 */
#mainCodeEditorArea { #mainCodeEditorArea {
-fx-background-color: #FDF6E3; -fx-background-color: #F5F5F5;
} }
#mainCodeEditorArea .keyword { #mainCodeEditorArea .keyword {
@ -33,8 +33,16 @@
-fx-fill: #317ECC; -fx-fill: #317ECC;
} }
#mainCodeEditorArea .number {
-fx-fill: #317ECC;
}
#mainCodeEditorArea .class-ident {
-fx-fill: #B05A65;
}
#mainCodeEditorArea .multi-line-comment { #mainCodeEditorArea .multi-line-comment {
-fx-fill: #4e6971; -fx-fill: #93A1A1;
-fx-font-style: italic; -fx-font-style: italic;
} }
@ -48,7 +56,8 @@
} }
.text { .text {
-fx-fill: #657A81; /* -fx-fill: #657A81; */
-fx-fill: #585858;
} }
.lineno { .lineno {