summaryrefslogtreecommitdiff
path: root/pygments/lexers/jvm.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-11-04 11:37:56 +0100
committerGeorg Brandl <georg@python.org>2014-11-04 11:37:56 +0100
commit9a760597282026468f768689815a09d40a1437a1 (patch)
tree6f1375b6f8604b6920f3bcc141d32303a85a5595 /pygments/lexers/jvm.py
parentb5ad3a64af4148809ac38c48d7d06834cb5ae1f7 (diff)
downloadpygments-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.py8
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),