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

make generateLogic more readable with named matches #600

Merged
merged 2 commits into from
Oct 8, 2020

Conversation

jgrgt
Copy link
Contributor

@jgrgt jgrgt commented Oct 7, 2020

I started looking at #590 and noticed one of the problems with fixing that is the use of vararg: generateLogic failed to work because it could not match that 'vararg'.

So I fixed that. Because I could not figure out the index-based regex, I moved everything to named groups first and then added the vararg. I don't like the way I had to abuse string interpolation to specify the named group referenced, but that's the best I could come up with.

Note that the vararg does not get 'expanded', so the underlying code needs to accept an Array instead of the vararg.


I confirm that I have read the Contributor Agreements v1.0, agree to be bound on them and confirm that my contribution is compliant.

@jgrgt jgrgt requested a review from robstoll as a code owner October 7, 2020 21:11
Copy link
Owner

@robstoll robstoll left a comment

Choose a reason for hiding this comment

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

@jgrgt thanks for your work but I am afraid that I don't have use for the vararg part. We never use vararg on the logic level, that's also the reason why we don't support it. Have a look at #590 the task list is only for api-fluent nothing to do in the logic level.
Anyhow.. I still think that the named groups are an improvement. Thus, can you please revert the vararg part and only keep the named groups.

@jgrgt
Copy link
Contributor Author

jgrgt commented Oct 8, 2020

@robstoll I removed the vararg parts but left the named groups.

def patterns = (6..0).collect { int amountOfParameters ->
def params = []
if (amountOfParameters > 0) {
params = (1..amountOfParameters).toList()
Copy link
Owner

@robstoll robstoll Oct 8, 2020

Choose a reason for hiding this comment

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

tiny detail (just as info) toList is not required

Suggested change
params = (1..amountOfParameters).toList()
params = (1..amountOfParameters)

@robstoll robstoll merged commit cb8f219 into robstoll:master Oct 8, 2020
@robstoll
Copy link
Owner

robstoll commented Oct 8, 2020

@jgrgt thanks for your first contribution to Atrium 🙂 👍

@robstoll robstoll changed the title Make generateLogic support varargs + avoid index-based regex make generateLogic more readable with named matches Oct 19, 2020
@robstoll robstoll added this to the 0.14.0 milestone Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants