(SemanticsVisitor visitor, Node[] args, FormulaSemantics semantics)
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public FormatManager<?> allowArgs(SemanticsVisitor visitor, Node[] args, |
| 69 | FormulaSemantics semantics) |
| 70 | { |
| 71 | int argCount = args.length; |
| 72 | if ((argCount < 1) || (argCount > 2)) |
| 73 | { |
| 74 | throw new SemanticsFailureException("Function " + getFunctionName() |
| 75 | + " received incorrect # of arguments, expected: 1-2 got " |
| 76 | + args.length + ' ' + Arrays.asList(args)); |
| 77 | } |
| 78 | if (!(args[0] instanceof ASTQuotString)) |
| 79 | { |
| 80 | //Error |
| 81 | throw new SemanticsFailureException( |
| 82 | "Parse Error: Invalid first argument: Must be a String"); |
| 83 | } |
| 84 | |
| 85 | //This will be a format name |
| 86 | String formatName = ((ASTQuotString) args[0]).getText(); |
| 87 | Class<? extends Loadable> cl = StringPClassUtil.getClassFor(formatName); |
| 88 | if (cl == null) |
| 89 | { |
| 90 | throw new SemanticsFailureException( |
| 91 | "Parse Error: Unable to understand Format: " + formatName); |
| 92 | } |
| 93 | LoadContext context = semantics.get(ManagerKey.CONTEXT); |
| 94 | ReferenceManufacturer<? extends Loadable> refMfg = |
| 95 | context.getReferenceContext().getManufacturer(cl); |
| 96 | if (!CDOMObject.class.isAssignableFrom(refMfg.getManagedClass())) |
| 97 | { |
| 98 | throw new SemanticsFailureException( |
| 99 | "Parse Error: Unable to use non-CDOM Format: " + formatName); |
| 100 | } |
| 101 | |
| 102 | if (argCount == 2) |
| 103 | { |
| 104 | if (!(args[1] instanceof ASTQuotString typeNode)) |
| 105 | { |
| 106 | throw new SemanticsFailureException( |
| 107 | "Parse Error: Invalid second argument: Must be a String"); |
| 108 | } |
| 109 | String viewName = typeNode.getText(); |
| 110 | try |
| 111 | { |
| 112 | View.valueOf(viewName); |
| 113 | } |
| 114 | catch (IllegalArgumentException e) |
| 115 | { |
| 116 | throw new SemanticsFailureException( |
| 117 | "Parse Error: Invalid View: " + viewName, e); |
| 118 | } |
| 119 | } |
| 120 | return context.getReferenceContext() |
| 121 | .getFormatManager("ARRAY[" + formatName + "]"); |
| 122 | } |
| 123 | |
| 124 | @Override |
nothing calls this directly
no test coverage detected