import { IParameterDefinition } from "../documents/parameters/IParameterDefinition" ; import { ExpressionType , toValidExpressionType } from "../documents/templates/ExpressionType" ; import { UserFunctionDefinition } from "../documents/templates/UserFunctionDefinition" ; import { UserFunctionParameterDefinition } from "../documents/templates/UserFunctionParameterDefinition" ; export function getUserFunctionUsage ( func , includeNamespaceName = true ) { const name = includeNamespaceName ? func . fullName : func . nameValue . unquotedValue ; const params = func . parameterDefinitions ; const outputType = func . output ? func . output . validOutputType : undefined ; return getFunctionUsage ( name , params , outputType ) ; } export function getFunctionUsage ( name , params , outputTypeAsString ) { let usage = `${ name }(${ params . map ( p => getFunctionParamUsage ( p . nameValue . unquotedValue , p . validType ) ) . join ( ", " ) })` ; let outputType = toValidExpressionType ( outputTypeAsString ) ; if ( outputType ) { usage += ` [${ outputType }]` ; } return usage ; } export function getFunctionParamUsage ( name , typeAsString ) { const paramType = toValidExpressionType ( typeAsString ) ; return paramType ? `${ name } [${ paramType }]` : name ; }