use of org.immutables.generator.SourceOrdering.AccessorProvider in project immutables by immutables.
the class Accessors method collectAccessors.
private void collectAccessors(TypeElement type, Map<String, Accessor> accesors) {
List<? extends Element> allMembers = elements.getAllMembers(type);
for (VariableElement field : ElementFilter.fieldsIn(allMembers)) {
if (isAccessible(field)) {
Accessor accessor = new Accessor(field);
accesors.put(accessor.name, accessor);
}
}
// toString, hashCode from Object
for (ExecutableElement method : ElementFilter.methodsIn(allMembers)) {
TypeElement definingType = (TypeElement) method.getEnclosingElement();
if (definingType.getQualifiedName().contentEquals(Object.class.getCanonicalName()) || isSimpleAccessor(method) && isAccessible(method)) {
Accessor accessor = new Accessor(method);
accesors.put(accessor.name, accessor);
}
}
// For other accessors we use shared utility
AccessorProvider provider = SourceOrdering.getAllAccessorsProvider(elements, types, type);
for (ExecutableElement method : provider.get()) {
// this should be already checked, but we check for completeness
if (isSimpleAccessor(method) && isAccessible(method)) {
Accessor accessor = new Accessor(method);
accesors.put(accessor.name, accessor);
}
}
}
use of org.immutables.generator.SourceOrdering.AccessorProvider in project immutables by immutables.
the class AccessorAttributesCollector method collectGeneratedCandidateMethods.
private void collectGeneratedCandidateMethods(TypeElement type) {
TypeElement originalType = CachingElements.getDelegate(type);
List<? extends Element> accessorsInSourceOrder;
if (originalType.getKind() == ElementKind.ANNOTATION_TYPE) {
accessorsInSourceOrder = SourceOrdering.getEnclosedElements(originalType);
} else {
AccessorProvider provider = SourceOrdering.getAllAccessorsProvider(processing.getElementUtils(), processing.getTypeUtils(), originalType);
accessorsInSourceOrder = provider.get();
accessorMapping = provider.accessorMapping();
}
for (ExecutableElement element : ElementFilter.methodsIn(accessorsInSourceOrder)) {
if (isElegibleAccessorMethod(element)) {
processGenerationCandidateMethod(element, originalType);
}
}
// inform use during checking for warnings.
for (Element element : processing.getElementUtils().getAllMembers(originalType)) {
if (element.getKind() == ElementKind.METHOD) {
switch(element.getSimpleName().toString()) {
case HASH_CODE_METHOD:
case TO_STRING_METHOD:
case EQUALS_METHOD:
processUtilityCandidateMethod((ExecutableElement) element, originalType);
break;
default:
}
}
}
}
Aggregations