Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groovy lexer: detect quoted function names #1765

merged 3 commits into from May 2, 2021

groovy lexer: detect quoted function names #1765

merged 3 commits into from May 2, 2021


Copy link

@alisonatwork alisonatwork commented Apr 5, 2021

Should fix #1753. I don't have a VM with Python set up in a way where I can easily test this, so I am depending on the tests in CI.

In Groovy it is valid to have a function name which is a quoted string. Single quote ('), double quote (") and the triple-single/triple-double formats are all allowed, but I suspect most people only use standard single or double. In most syntax highlighters the quoted function name is displayed as if it were a string (e.g., which perhaps we could also do by switching the priority to parse strings before function declarations. But since we already detect a function name here, I just try to expand the pattern a little bit to match the quoted string as a function name too.

While we are here, also fix a bug where sometimes keywords would be interpreted as function names (already fixed in Java lexer).

@@ -88,7 +88,7 @@
' ' Text
'String' Name
' ' Text
'getWorldString' Name.Function
'getWorldString' Name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be detected as Name.Function and not Name, but I think this is not a big problem considering it's much more annoying for keywords or exceptions to be detected as functions (see test.groovy.output fixes, below).

@Anteru Anteru self-assigned this Apr 10, 2021
@Anteru Anteru added this to the 2.9 milestone May 2, 2021
@Anteru Anteru merged commit 3752e98 into pygments:master May 2, 2021
Copy link

Anteru commented May 2, 2021

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Groovy lexer doesn't handle quoted function names
2 participants