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

Support pattern operator for groovy #4847

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Conversation

jevanlingen
Copy link
Contributor

What's changed?

The pattern operator ~ is parsed correctly.

What's your motivation?

Support the operator to support Gradle files better. For example the Spring Boot project uses it: click.

Any additional context

I took a shortcut to parse the operator as part of a string, that's exactly the same route as how we parse Regexes:

// both are typed as strings
def PATTERN = ~/foo/ // should actually be of type `Pattern`
def REGEX = /\d+/ // should actually be a MethodInvocation of `Pattern.matches(regex, string)`

This works, because our groovy parser does not do type checks (like we do for Java). If we ever want to support this, we have to change the groovy parser as well.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@jevanlingen jevanlingen added enhancement New feature or request parser-groovy labels Jan 6, 2025
@jevanlingen jevanlingen self-assigned this Jan 6, 2025
@jevanlingen jevanlingen mentioned this pull request Jan 6, 2025
3 tasks
@jevanlingen jevanlingen merged commit c455436 into main Jan 6, 2025
2 checks passed
@jevanlingen jevanlingen deleted the groovy-pattern-operator branch January 6, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser-groovy
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants