Parses the 3 arguments plus associations that are part of a token doing a modification. @param context The LoadContext for processing @param value The instructions of the modification @param scope The scope in which the modification should be analyzed @param tokenNa
(LoadContext context, String value, PCGenScope scope, FormulaManager formulaManager, String tokenName, int argsConsumed)
| 92 | * if the parsing failed. The message contains information about the error |
| 93 | */ |
| 94 | public static VarModifier<?> parseModifyInfo(LoadContext context, |
| 95 | String value, PCGenScope scope, FormulaManager formulaManager, |
| 96 | String tokenName, int argsConsumed) throws ModifyException |
| 97 | { |
| 98 | /* |
| 99 | * TODO CODE-3299 Need to check the object type of the VarHolder to make sure it |
| 100 | * is legal. Note it's a proxy, so a @ReadOnly method needs to be used to support |
| 101 | * the analysis. |
| 102 | */ |
| 103 | ParsingSeparator sep = new ParsingSeparator(value, '|'); |
| 104 | sep.addGroupingPair('[', ']'); |
| 105 | sep.addGroupingPair('(', ')'); |
| 106 | |
| 107 | if (!sep.hasNext()) |
| 108 | { |
| 109 | throw new ModifyException(tokenName + " may not be empty"); |
| 110 | } |
| 111 | |
| 112 | String varName = sep.next(); |
| 113 | if (!context.getVariableContext().isLegalVariableID(scope, varName)) |
| 114 | { |
| 115 | throw new ModifyException(tokenName + " found invalid var name: " + varName |
| 116 | + "(scope: " + scope.getName() + ")"); |
| 117 | } |
| 118 | if (!sep.hasNext()) |
| 119 | { |
| 120 | throw new ModifyException( |
| 121 | tokenName + " needed argument #" + (argsConsumed + 2) + ": " + value); |
| 122 | } |
| 123 | String modIdentification = sep.next(); |
| 124 | if (!sep.hasNext()) |
| 125 | { |
| 126 | throw new ModifyException( |
| 127 | tokenName + " needed argument # " + (argsConsumed + 3) + ": " + value); |
| 128 | } |
| 129 | String modInstructions = sep.next(); |
| 130 | FormulaModifier<?> modifier; |
| 131 | try |
| 132 | { |
| 133 | FormatManager<?> format = context.getVariableContext().getVariableFormat(scope, varName); |
| 134 | modifier = |
| 135 | context.getVariableContext().getModifier(modIdentification, |
| 136 | modInstructions, formulaManager, scope, format); |
| 137 | } |
| 138 | catch (IllegalArgumentException e) |
| 139 | { |
| 140 | throw new ModifyException( |
| 141 | tokenName + " Modifier " + modIdentification + " had value " |
| 142 | + modInstructions + " but it was not valid: " + e.getMessage(), e); |
| 143 | } |
| 144 | |
| 145 | Set<Object> associationsVisited = Collections.newSetFromMap(new CaseInsensitiveMap<>()); |
| 146 | while (sep.hasNext()) |
| 147 | { |
| 148 | String assoc = sep.next(); |
| 149 | int equalLoc = assoc.indexOf('='); |
| 150 | if (equalLoc == -1) |
| 151 | { |
no test coverage detected