function getParameterType()

in client/src/components/special/cellprofiler/model/modules/parse-module-configuration.js [341:413]


function getParameterType (typeParts) {
  if (!typeParts) {
    return {type: AnalysisTypes.string};
  }
  if (typeof typeParts === 'string') {
    switch (typeParts.toLowerCase()) {
      case 'boolean':
      case 'flag':
        return {type: AnalysisTypes.boolean};
      case 'integer':
        return {type: AnalysisTypes.integer};
      case 'float':
        return {type: AnalysisTypes.float};
      case 'units':
        return {type: AnalysisTypes.units};
      case 'units2':
        return {type: AnalysisTypes.units2};
      case 'color':
        return {type: AnalysisTypes.color};
      case 'object':
        return {type: AnalysisTypes.object};
      case 'file':
        return {type: AnalysisTypes.file, isList: true};
      case 'files':
        return {type: AnalysisTypes.file, multiple: true, isList: true};
      case 'custom':
        return {type: AnalysisTypes.custom};
      case 'string':
      default:
        return {type: AnalysisTypes.string};
    }
  }
  if (
    typeof typeParts === 'object' &&
    typeParts.parts &&
    Array.isArray(typeParts.parts) &&
    typeParts.open === '['
  ) {
    const joined = splitPartsBy(typeParts.parts, ',');
    return {type: AnalysisTypes.string, isList: true, values: processArrayElements(joined)};
  }
  if (typeof typeParts === 'object' && Array.isArray(typeParts)) {
    const [mainTypePart, additionalPart] = typeParts;
    const typeDefinition = getParameterType(mainTypePart);
    if (
      additionalPart &&
      ['[', '('].includes(additionalPart.open) &&
      [
        AnalysisTypes.integer,
        AnalysisTypes.float,
        AnalysisTypes.units,
        AnalysisTypes.units2
      ].includes(typeDefinition.type)
    ) {
      const [
        startStr = '-Infinity',
        endStr = 'Infinity'
      ] = splitPartsBy(additionalPart.parts || [], ',');
      const start = Number(startStr);
      const end = Number(endStr);
      return {
        ...typeDefinition,
        isRange: additionalPart.open === '[',
        range: {
          min: Number.isNaN(start) ? -Infinity : start,
          max: Number.isNaN(end) ? Infinity : end
        }
      };
    }
    return typeDefinition;
  }
  return {type: AnalysisTypes.string};
}