use of org.checkerframework.common.basetype.BaseTypeChecker in project checker-framework by typetools.
the class GenericAnnotatedTypeFactory method getTypeFactoryOfSubchecker.
/**
* Returns the type factory used by a subchecker. Returns null if no matching subchecker was found
* or if the type factory is null. The caller must know the exact checker class to request.
*
* <p>Because the visitor path is copied, call this method each time a subfactory is needed rather
* than store the returned subfactory in a field.
*
* @param subCheckerClass the exact class of the subchecker
* @param <T> the type of {@code subCheckerClass}'s {@link AnnotatedTypeFactory}
* @return the AnnotatedTypeFactory of the subchecker or null if no subchecker exists
*/
// Intentional abuse
@SuppressWarnings("TypeParameterUnusedInFormals")
@Nullable
public <T extends GenericAnnotatedTypeFactory<?, ?, ?, ?>> T getTypeFactoryOfSubchecker(Class<? extends BaseTypeChecker> subCheckerClass) {
BaseTypeChecker subchecker = checker.getSubchecker(subCheckerClass);
if (subchecker == null) {
return null;
}
@SuppressWarnings(// This might not be safe, but the caller of the method should use the correct
"unchecked") T subFactory = (T) subchecker.getTypeFactory();
if (subFactory != null) {
subFactory.setVisitorTreePath(getVisitorTreePath());
}
return subFactory;
}
Aggregations