-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add extra information when failing to parse contract #1176
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
Conversation
kdavisk6
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the idea that we track those warnings and potentially expose those to users. My comments are focused on the readability and clarifying the intention of the process.
| .forEach(processor -> processor.process(annotation, data))); | ||
| if (Arrays.stream(targetType.getAnnotations()) | ||
| .anyMatch(annotation -> classAnnotationProcessors.stream() | ||
| .anyMatch(processor -> processor.test(annotation)))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to move this test into a function so we can call like getApplicableAnnotationProcessors() to make the intention clearer and make this more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't make this happen in a meaningful way.
There are 2 loops, so can't really get a single list that I can just use w/o further filtering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not asking you to simplify the loop, just move it to a function so it is a little more readable.
| Arrays.stream(targetType.getAnnotations()) | ||
| .forEach(annotation -> classAnnotationProcessors.stream() | ||
| .filter(processor -> processor.test(annotation)) | ||
| .forEach(processor -> processor.process(annotation, data))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keying off my previous comment, the end result here is
Collection<AnnotationProcessor> applicableProcessors = this.getAnnotationProcessorsFor(targetType);
applicableProcessors.forEach(processor -> process(annotation, data));| .filter(processor -> processor.test(annotation)) | ||
| .forEach(processor -> processor.process(annotation, data)); | ||
| if (methodAnnotationProcessors.stream() | ||
| .anyMatch(processor -> processor.test(annotation))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar approach here, maybe create a function to do this test.
* Add extra information when failing to parse contract * Add warnings to other error messages * Move check if processor are valid before if block
* Add extra information when failing to parse contract * Add warnings to other error messages * Move check if processor are valid before if block
Inspired by #1173
I decided to add some extra information to contract parsing... to be attached to exceptions.
So, instead of just saying
Method has too many Body parametersgo figure what that meansI attached some extra bits:
probably needs more work =)
and introduces more mutability to
MethodMetadata=(((