Package org.immutables.generator
Class SourceOrdering
java.lang.Object
org.immutables.generator.SourceOrdering
Utility that abstracts away hacks to retrieve elements in source order. Currently, Javac returns
elements in proper source order, but EJC returns elements in alphabetical order.
- Bug 300408 - TypeElement.getEnclosedElements does not respect source order
- JDK-6884227 : Clarify ordering requirements of javax.lang.model.TypeElement.getEnclosedElements
Based on a workaround idea provided by Christian Humer
NOTE: The Eclipse bug is fixed, and this workaround can be disabled by setting the system property
org.immutables.disableEclipseOrderingProvider=true.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceprivate static classThis inner static class will fail to load if Eclipse compliler classes will not be in classpath.private static enumprivate static interfaceprivate static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final SourceOrdering.OrderingProviderprivate static final SourceOrdering.OrderingProvider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static SourceOrdering.OrderingProviderprivate static List<ExecutableElement> disambiguateMethods(Iterable<? extends ExecutableElement> methods) static com.google.common.collect.Ordering<Element> enclosedBy(Element element) getAllAccessorsProvider(Elements elements, Types types, TypeElement originatingType) While we haveSourceOrdering, there's still a problem: We have inheritance hierarchy and we want to have all defined or inherited accessors returned as members of target type, likeElements.getAllMembers(TypeElement), but we need to have them properly and stably sorted.static com.google.common.collect.ImmutableList<Element> getEnclosedElements(Element element) (package private) static booleanisJavaLangObject(TypeElement element)
-
Field Details
-
DEFAULT_PROVIDER
-
PROVIDER
-
-
Constructor Details
-
SourceOrdering
private SourceOrdering()
-
-
Method Details
-
getEnclosedElements
-
enclosedBy
-
createProvider
-
getAllAccessorsProvider
public static SourceOrdering.AccessorProvider getAllAccessorsProvider(Elements elements, Types types, TypeElement originatingType) While we haveSourceOrdering, there's still a problem: We have inheritance hierarchy and we want to have all defined or inherited accessors returned as members of target type, likeElements.getAllMembers(TypeElement), but we need to have them properly and stably sorted. This implementation doesn't try to correctly resolve order for accessors inherited from different supertypes(interfaces), just something that stable and reasonable wrt source ordering without handling complex cases.- Parameters:
elements- the elements utilitytypes- the types utilityoriginatingType- the type to traverse- Returns:
- provider of all accessors in source order and mapping
-
disambiguateMethods
private static List<ExecutableElement> disambiguateMethods(Iterable<? extends ExecutableElement> methods) -
isJavaLangObject
-