Compare commits
3 Commits
4a5b94a9b7
...
9379e6bb94
Author | SHA1 | Date | |
---|---|---|---|
9379e6bb94 | |||
8a30493c52 | |||
b56f08e441 |
@ -63,6 +63,10 @@ public class EventProcessor extends AbstractProcessor {
|
|||||||
else
|
else
|
||||||
pass = true;
|
pass = true;
|
||||||
|
|
||||||
|
// Warn the user about unused return values
|
||||||
|
if (useParameter && eventHandler.getReturnType().getKind() != TypeKind.VOID)
|
||||||
|
warning(eventHandler, "Unused return value");
|
||||||
|
|
||||||
// Abort checking if the handler signature is incorrect
|
// Abort checking if the handler signature is incorrect
|
||||||
if (!pass)
|
if (!pass)
|
||||||
continue;
|
continue;
|
||||||
@ -80,14 +84,20 @@ public class EventProcessor extends AbstractProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for handlers for abstract types that aren't polymorphic
|
// Detect missing or useless @Polymorphic
|
||||||
|
boolean polymorphic = eventHandler.getAnnotation(Polymorphic.class) != null;
|
||||||
Element eventElement = ((DeclaredType) eventType).asElement();
|
Element eventElement = ((DeclaredType) eventType).asElement();
|
||||||
if (eventHandler.getAnnotation(Polymorphic.class) == null
|
|
||||||
&& (eventElement.getKind() == ElementKind.INTERFACE
|
// Check for handlers for abstract types that aren't polymorphic
|
||||||
|| eventElement.getModifiers().contains(Modifier.ABSTRACT))) {
|
if (!polymorphic && (eventElement.getKind() == ElementKind.INTERFACE
|
||||||
|
|| eventElement.getModifiers().contains(Modifier.ABSTRACT)))
|
||||||
warning(eventHandler,
|
warning(eventHandler,
|
||||||
"Parameter should be instantiable or handler should use @Polymorphic");
|
"Parameter should be instantiable or handler should use @Polymorphic");
|
||||||
}
|
|
||||||
|
// Check for handlers for final types that are polymorphic
|
||||||
|
else if (polymorphic && eventElement.getModifiers().contains(Modifier.FINAL))
|
||||||
|
warning(eventHandler,
|
||||||
|
"@Polymorphic should be removed as parameter cannot be subclassed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user