Skip to content

Commit

Permalink
Special annotation handling for Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
wcekan committed Mar 14, 2021
1 parent 211294b commit 739803f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.yahoo.elide.core.exceptions.DuplicateMappingException;
import com.yahoo.elide.core.lifecycle.LifeCycleHook;
import com.yahoo.elide.core.type.AccessibleObject;
import com.yahoo.elide.core.type.ClassType;
import com.yahoo.elide.core.type.Field;
import com.yahoo.elide.core.type.Member;
import com.yahoo.elide.core.type.Method;
Expand Down Expand Up @@ -270,6 +271,18 @@ private void bindEntityFields(Type<?> cls, String type,
Collection<AccessibleObject> fieldOrMethodList,
Set<Class<? extends Annotation>> hiddenAnnotations) {
for (AccessibleObject fieldOrMethod : fieldOrMethodList) {
// Special handling for Eclipse. Load missing annotations by reloading method
if (fieldOrMethod.getAnnotations().length == 0 && fieldOrMethod instanceof Method) {
Method m = (Method) fieldOrMethod;
try {
fieldOrMethod = cls.getMethod(m.getName(),
Arrays.stream(m.getParameterTypes())
.map(ClassType::new)
.toArray(Type[]::new));
} catch (NoSuchMethodException | SecurityException e) {
// Not expected, leave alone
}
}
bindTriggerIfPresent(fieldOrMethod);

if (fieldOrMethod.isAnnotationPresent(Id.class)) {
Expand Down

0 comments on commit 739803f

Please sign in to comment.