(funcDecl: FunctionDecl)
| 414 | * Returns an empty array if no such attribute is found or if the attribute value cannot be determined. |
| 415 | */ |
| 416 | export function getFunctionExpressionContext(funcDecl: FunctionDecl) { |
| 417 | const funcAllowedContext: ExpressionContext[] = []; |
| 418 | const funcAttr = funcDecl.attributes.find((attr) => attr.decl.$refText === '@@@expressionContext'); |
| 419 | if (funcAttr) { |
| 420 | const contextArg = funcAttr.args[0]?.value; |
| 421 | if (isArrayExpr(contextArg)) { |
| 422 | contextArg.items.forEach((item) => { |
| 423 | if (isEnumFieldReference(item)) { |
| 424 | funcAllowedContext.push(item.target.$refText as ExpressionContext); |
| 425 | } |
| 426 | }); |
| 427 | } |
| 428 | } |
| 429 | return funcAllowedContext; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Gets the data field referenced by the given expression, if any. Returns `undefined` if the expression is not a reference to a data field. |
no test coverage detected