use of org.immutables.generator.TypeHierarchyCollector in project immutables by immutables.
the class TypeIntrospectionBase method collectTypeHierarchy.
protected TypeHierarchyCollector collectTypeHierarchy(TypeMirror typeMirror) {
TypeHierarchyCollector collector = new TypeHierarchyCollector();
collector.collectFrom(typeMirror);
return collector;
}
use of org.immutables.generator.TypeHierarchyCollector in project immutables by immutables.
the class TypeIntrospectionBase method introspectTypeMirror.
protected void introspectTypeMirror(TypeMirror typeMirror) {
TypeHierarchyCollector collector = collectTypeHierarchy(typeMirror);
this.extendedClassesNames = collector.extendedClassNames();
this.implementedInterfacesNames = collector.implementedInterfaceNames();
this.unresolvedYetArguments = collector.unresolvedYetArguments();
}
use of org.immutables.generator.TypeHierarchyCollector in project immutables by immutables.
the class ValueAttribute method introspectType.
@Override
protected void introspectType() {
TypeMirror typeMirror = returnType;
// Special case for primitive Optional, may become a pattern for specialized types
if (typeKind.isOptionalSpecializedJdk()) {
typeParameters = ImmutableList.of(optionalSpecializedType());
// no delegation to introspect further
return;
}
if (isContainerType()) {
if (typeMirror.getKind() == TypeKind.DECLARED || typeMirror.getKind() == TypeKind.ERROR) {
DeclaredType declaredType = (DeclaredType) typeMirror;
List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
if (!typeArguments.isEmpty()) {
final TypeMirror typeArgument = typeArguments.get(0);
if (isSetType() && protoclass().environment().hasOrdinalModule()) {
this.generateOrdinalValueSet = new TypeIntrospectionBase() {
@Override
protected TypeMirror internalTypeMirror() {
return typeArgument;
}
@Override
protected TypeHierarchyCollector collectTypeHierarchy(TypeMirror typeMirror) {
TypeHierarchyCollector collector = containingType.createTypeHierarchyCollector(reporter, element);
collector.collectFrom(typeMirror);
return collector;
}
}.isOrdinalValue();
}
if (isMapType()) {
TypeMirror typeSecondArgument = typeArguments.get(1);
if (typeSecondArgument.getKind() == TypeKind.DECLARED) {
TypeElement typeElement = (TypeElement) ((DeclaredType) typeSecondArgument).asElement();
this.containedSecondaryTypeElement = typeElement;
}
}
typeMirror = typeArgument;
}
}
} else if (isArrayType()) {
arrayComponent = ((ArrayType) typeMirror).getComponentType();
typeMirror = arrayComponent;
}
if (typeMirror.getKind() == TypeKind.DECLARED) {
TypeElement typeElement = (TypeElement) ((DeclaredType) typeMirror).asElement();
this.containedTypeElement = typeElement;
}
introspectTypeMirror(typeMirror);
introspectSupertypes();
}
use of org.immutables.generator.TypeHierarchyCollector in project immutables by immutables.
the class Metaservices method useIntrospectedInterfacesForServices.
private Set<String> useIntrospectedInterfacesForServices(TypeElement typeElement) {
TypeHierarchyCollector typeHierarchyCollector = new TypeHierarchyCollector();
typeHierarchyCollector.collectFrom(typeElement.asType());
return typeHierarchyCollector.implementedInterfaceNames();
}
Aggregations