diff options
author | Georg Brandl <georg@python.org> | 2014-11-04 11:37:56 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-11-04 11:37:56 +0100 |
commit | 9a760597282026468f768689815a09d40a1437a1 (patch) | |
tree | 6f1375b6f8604b6920f3bcc141d32303a85a5595 /pygments/lexers/jvm.py | |
parent | b5ad3a64af4148809ac38c48d7d06834cb5ae1f7 (diff) | |
download | pygments-9a760597282026468f768689815a09d40a1437a1.tar.gz |
Closes #1051: fix misrecognition of throw and return statements as method
signatures in the Java lexer.
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), |