in src/powerquery-parser/language/type/typeUtils/categorize.ts [179:275]
function addToCategory(category: TCategory, type: Type.TPowerQueryType): TCategory {
// We can't group cases which call `addToCategoryForPrimitive` as they each have a different generic type.
switch (type.kind) {
case Type.TypeKind.Action:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Any: {
assertIsCategoryForType<Type.TAny, AnyCategory>(category, type);
return addTypeIfUniqueAny(category, type);
}
case Type.TypeKind.AnyNonNull:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Binary:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Date:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.DateTime:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.DateTimeZone:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Duration:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Function: {
assertIsCategoryForType<Type.TFunction, FunctionCategory>(category, type);
return addToCategoryForFunction(category, type);
}
case Type.TypeKind.List: {
assertIsCategoryForType<Type.TList, ListCategory>(category, type);
return addToCategoryForList(category, type);
}
case Type.TypeKind.Logical: {
assertIsCategoryForType<Type.TLogical, LogicalCategory>(category, type);
return addToCategoryForLogical(category, type);
}
case Type.TypeKind.None:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.NotApplicable:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Null:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Number: {
assertIsCategoryForType<Type.TNumber, NumberCategory>(category, type);
return addToCategoryForNumber(category, type);
}
case Type.TypeKind.Record: {
assertIsCategoryForType<Type.TRecord, RecordCategory>(category, type);
return addToCategoryForRecord(category, type);
}
case Type.TypeKind.Table: {
assertIsCategoryForType<Type.TTable, TableCategory>(category, type);
return addToCategoryForTable(category, type);
}
case Type.TypeKind.Text: {
assertIsCategoryForType<Type.TText, TextCategory>(category, type);
return addToCategoryForText(category, type);
}
case Type.TypeKind.Time:
return addToCategoryForPrimitive(category, type);
case Type.TypeKind.Type: {
assertIsCategoryForType<Type.TType, TypeCategory>(category, type);
return addTypeIfUniqueType(category, type);
}
case Type.TypeKind.Unknown:
return addToCategoryForPrimitive(category, type);
default:
throw Assert.isNever(type);
}
}