import * as t from '@babel/types' ; import type { Metadata } from '../../../../types' ; import { createResultPair } from '../../common' ; import type { TraverseHandlers } from '../types' ; import { getFunctionArgs } from './function-args' ; import { evaluateIdentifier } from './identifier' ; export const resolveExpressionInMember = ( expression , meta , expressionName , memberExpression , traversers ) : ReturnType < typeof createResultPair > => { let result = createResultPair ( expression , meta ) ; if ( t . isIdentifier ( expression ) ) { result = evaluateIdentifier ( expression , meta ) ; } else if ( t . isFunction ( expression ) ) { const callExpression = t . callExpression ( expression , getFunctionArgs ( expressionName , memberExpression ) ) ; result = traversers . callExpression ( callExpression , meta ) ; } else if ( t . isCallExpression ( expression ) ) { result = traversers . callExpression ( expression , meta ) ; } else if ( t . isMemberExpression ( expression ) ) { result = traversers . memberExpression ( expression , meta ) ; } if ( result . value !== expression ) { return resolveExpressionInMember ( result . value , result . meta , expressionName , memberExpression , traversers ) ; } return result ; } ;