From 1451ff80a22363eab628f9b34237b646d9ee2869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sun, 24 Sep 2017 03:16:44 +0200 Subject: [PATCH] Improve Java syntax highlighting --- .../syntaxhighlighting/JavaSyntaxHighlighter.java | 6 ++++++ .../util/codearea/syntaxhighlighting/java.css | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/JavaSyntaxHighlighter.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/JavaSyntaxHighlighter.java index 06ecf1b6ed..9c291dc65f 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/JavaSyntaxHighlighter.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/JavaSyntaxHighlighter.java @@ -38,6 +38,8 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter { private static final String BRACE_PATTERN = "[{}]"; private static final String BRACKET_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 SINGLELINE_COMMENT_PATTERN = "//[^\n]*"; private static final String MULTILINE_COMMENT_PATTERN = "/\\*.*?\\*/"; @@ -48,10 +50,12 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter { + "|(?" + MULTILINE_COMMENT_PATTERN + ")" + "|(?" + ANNOTATION_PATTERN + ")" + "|(?" + PAREN_PATTERN + ")" + + "|(?" + NUMBER_PATTERN + ")" + "|(?" + BRACE_PATTERN + ")" + "|(?" + BRACKET_PATTERN + ")" + "|(?" + SEMICOLON_PATTERN + ")" + "|(?" + KEYWORD_PATTERN + ")" + + "|(?" + CLASS_IDENT_PATTERN + ")" + "|(?" + STRING_PATTERN + ")", Pattern.DOTALL ); @@ -65,8 +69,10 @@ public class JavaSyntaxHighlighter extends SyntaxHighlighter { map.put("KEYWORD", "keyword"); map.put("PAREN", "paren"); map.put("BRACE", "brace"); + map.put("NUMBER", "number"); map.put("BRACKET", "bracket"); map.put("SEMICOLON", "semicolon"); + map.put("CLASSIDENT", "class-ident"); map.put("STRING", "string"); map.put("ANNOTATION", "annotation"); return Collections.unmodifiableMap(map); diff --git a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/java.css b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/java.css index e3ebab9455..c569e0189e 100644 --- a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/java.css +++ b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/util/codearea/syntaxhighlighting/java.css @@ -1,7 +1,7 @@ /* Theme based on Solarized Light for Eclipse, http://www.eclipsecolorthemes.org/?view=theme&id=1013 */ #mainCodeEditorArea { - -fx-background-color: #FDF6E3; + -fx-background-color: #F5F5F5; } #mainCodeEditorArea .keyword { @@ -33,8 +33,16 @@ -fx-fill: #317ECC; } +#mainCodeEditorArea .number { + -fx-fill: #317ECC; +} + +#mainCodeEditorArea .class-ident { + -fx-fill: #B05A65; +} + #mainCodeEditorArea .multi-line-comment { - -fx-fill: #4e6971; + -fx-fill: #93A1A1; -fx-font-style: italic; } @@ -48,7 +56,8 @@ } .text { - -fx-fill: #657A81; + /* -fx-fill: #657A81; */ + -fx-fill: #585858; } .lineno {