-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for Java 8 modifier changes #244
Conversation
@@ -82,4 +84,13 @@ public static String join(String separator, List<String> parts) { | |||
result.addAll(b); | |||
return result; | |||
} | |||
|
|||
public static boolean hasDefaultModifier(Collection<Modifier> modifiers) { |
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.
Should not be public
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.
Actually I guess doesn't matter, this class isn't public
For tests, copy a method from TypeSpecTest and modify it until it does what you need! We want to accept |
Looks like I wrote the wrong checkState, I'll add tests and attempt to fix that. |
@swankjesse Is there any preferred order for test methods, or can I insert anywhere? Also, this can't be tested without Java 8. Is there a specific way of doing that? |
@kenzierocks related tests are usually together, but the order isn't too important. Probably best to put these with the other tests that check for modifiers. |
And for the Java 8 compile restriction? |
One interesting/bad consequence of the |
Hmm... what about doing an |
Can do. |
e66fd2a
to
b0f8b35
Compare
Alright, that should be it. |
14b085d
to
83dbfc5
Compare
Okay, found a new problem. |
@kenzierocks I think you should require either |
Yes, but then it emits an |
Don't forget |
Oh, that sounds cool. I think I'll rework the implicit structure a bit to ease this in the future in case even more implicitness is added/removed. |
0a89400
to
9c463b5
Compare
I changed it so that implicit modifiers are not required, which is the most minimalist change I can think of that won't break compatibility but will allow this new rule. A side effect of this is allowing the above changes to also work. I just need to add a test that checks for |
@kenzierocks I'd like to continue requiring implicit modifiers. When Java 9 comes and interface methods can be public or private, I want the public to be in the callsite so we don't have to guess! |
Then I'll need to think of some way to allow the implicit modifiers through, or scrap the whole system and just always print modifiers explicitly. |
9c463b5
to
e408f64
Compare
Updated the |
e408f64
to
0cc0047
Compare
I'm not finding the specification for |
Modifier def = null; | ||
try { | ||
def = Modifier.valueOf("DEFAULT"); | ||
} catch (IllegalArgumentException expected) { |
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.
nit: expected –> ignored
(expected: this should happen 100% of the time. ignored: I don't care if this happens)
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.
Right.
I love how this is coming together. Thanks for your patience on my strict and pedantic reviews. I think it's worth it. |
Oh, I don't mind. The only pain I have is my formatter is off by a little bit so I'm trying not to hit format. |
5d3f7fe
to
f6ff4ab
Compare
53b24c7
to
894391a
Compare
Okay, this should be good. |
if (kind == Kind.INTERFACE) { | ||
requireExactlyOneOf(EnumSet.of(Modifier.PUBLIC, Modifier.PRIVATE), | ||
fieldSpec.modifiers); | ||
if (kind == Kind.INTERFACE) { |
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.
This if
can be removed. You already have it above.
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.
That was leftover from when the above if
had || kind == Kind.ANNOTATION
. Fixing.
894391a
to
723a03d
Compare
Fixed problem, let me know if there's anything else I need to modify. |
checkArgument(fieldSpec.modifiers.containsAll(kind.implicitFieldModifiers), | ||
"%s %s.%s requires modifiers %s", kind, name, fieldSpec.name, | ||
kind.implicitFieldModifiers); | ||
checkState(kind != Kind.ANNOTATION, "%s %s cannot have fields", kind, name); |
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 love this
This works! I'm going to merge it as-is and send my own follow-up to you where I think we can slightly shrink the code required. (Fun java tricks!) |
Add support for Java 8 modifier changes
Thanks for the fix, and for your patience! |
Adds support for most Java 8 modifier changes.