Add error message for @Listener methods.#1513
Add error message for @Listener methods.#1513stephan-gh merged 1 commit intoSpongePowered:bleedingfrom
Conversation
179a712 to
e48b63d
Compare
| msg.printMessage(Diagnostic.Kind.ERROR, "method must return void", method); | ||
| } | ||
| List<? extends VariableElement> parameters = method.getParameters(); | ||
| if (parameters.isEmpty() || isTypeSubclass(parameters.get(0), EVENT_CLASS)) { |
There was a problem hiding this comment.
This should be || !isTypeSubClass(...) because you want to show the error if the method doesn't have an Event as first parameter
| Types types = processingEnv.getTypeUtils(); | ||
|
|
||
| TypeMirror event = types.getDeclaredType(elements.getTypeElement(subclass)); | ||
| return types.isAssignable(event, typedElement.asType()); |
There was a problem hiding this comment.
The order of the arguments for isAssignable is wrong here. From the Javadocs:
returns true if and only if the first type is assignable to the second
You want to check if the parameter type extends Event which means that you need to check if the parameter is assignable to Event. Event isn't directly assignable to a subclass of it.
| @@ -1 +1,2 @@ | |||
| org.spongepowered.plugin.processor.PluginProcessor | |||
| org.spongepowered.processor.plugin.PluginProcessor | |||
There was a problem hiding this comment.
While I understand why you move it, I would prefer if it stays in its original package so we don't break older versions of SpongeGradle
There was a problem hiding this comment.
@Minecrell Moved back to the original package.
|
|
||
| return false; | ||
| } | ||
| } |
| Types types = processingEnv.getTypeUtils(); | ||
|
|
||
| TypeMirror event = types.getDeclaredType(elements.getTypeElement(subclass)); | ||
| return types.isAssignable(event, typedElement.asType()); |
e48b63d to
d20b3f3
Compare
a116968 to
203d186
Compare
b4c057a to
376c1e3
Compare
376c1e3 to
e2a1f7e
Compare
See SpongePowered/Sponge#1233 (comment).