Package com.google.auto.value.processor
Class EclipseHack
java.lang.Object
com.google.auto.value.processor.EclipseHack
Hacks needed to work around various bugs and incompatibilities in Eclipse's implementation of
annotation processing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) TypeMirror
methodReturnType
(ExecutableElement method, DeclaredType in) (package private) com.google.common.collect.ImmutableMap<ExecutableElement,
TypeMirror> methodReturnTypes
(Set<ExecutableElement> methods, DeclaredType in) Returns a map containing the real return types of the given methods, knowing that they appear in the given type.private Map<Name,
ExecutableElement> Constructs a map from name to method of the no-argument methods in the given type.
-
Field Details
-
processingEnv
-
-
Constructor Details
-
EclipseHack
EclipseHack(ProcessingEnvironment processingEnv)
-
-
Method Details
-
methodReturnType
-
methodReturnTypes
com.google.common.collect.ImmutableMap<ExecutableElement,TypeMirror> methodReturnTypes(Set<ExecutableElement> methods, DeclaredType in) Returns a map containing the real return types of the given methods, knowing that they appear in the given type. This means that if the given type is sayStringIterator implements Iterator<String>
then we want thenext()
method to map to String, rather than theT
that it returns as inherited fromIterator<T>
. This method is in EclipseHack because if it weren't for this Eclipse bug it would be trivial. Unfortunately, versions of Eclipse up to at least 4.5 have a bug where theTypes.asMemberOf(javax.lang.model.type.DeclaredType, javax.lang.model.element.Element)
method throws IllegalArgumentException if given a method that is inherited from an interface. Fortunately, Eclipse's implementation ofElements.getAllMembers(javax.lang.model.element.TypeElement)
does the type substitution thatasMemberOf
would have done. But javac's implementation doesn't. So we try the way that would work if Eclipse weren't buggy, and only if we get IllegalArgumentException do we usegetAllMembers
. -
noArgMethodsIn
Constructs a map from name to method of the no-argument methods in the given type. We need this because an ExecutableElement returned byElements.getAllMembers(javax.lang.model.element.TypeElement)
will not compare equal to the original ExecutableElement ifgetAllMembers
substituted type parameters, as it does in Eclipse.
-