diff options
Diffstat (limited to 'pygments/lexers/jvm.py')
-rw-r--r-- | pygments/lexers/jvm.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index 1009ef9f..cc390513 100644 --- a/pygments/lexers/jvm.py +++ b/pygments/lexers/jvm.py @@ -41,15 +41,17 @@ class JavaLexer(RegexLexer): (r'[^\S\n]+', Text), (r'//.*?\n', Comment.Single), (r'/\*.*?\*/', Comment.Multiline), + # keywords: go before method names to avoid lexing "throw new XYZ" + # as a method signature + (r'(assert|break|case|catch|continue|default|do|else|finally|for|' + r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b', + Keyword), # method names (r'((?:(?:[^\W\d]|\$)[\w\.\[\]\$<>]*\s+)+?)' # return arguments r'((?:[^\W\d]|\$)[\w\$]*)' # method name r'(\s*)(\()', # signature start bygroups(using(this), Name.Function, Text, Operator)), (r'@[^\W\d][\w\.]*', Name.Decorator), - (r'(assert|break|case|catch|continue|default|do|else|finally|for|' - r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b', - Keyword), (r'(abstract|const|enum|extends|final|implements|native|private|' r'protected|public|static|strictfp|super|synchronized|throws|' r'transient|volatile)\b', Keyword.Declaration), |