| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,14 +363,14 @@ | |||
| 363 | 363 | <directory>src/main/resources</directory> | |
| 364 | 364 | <filtering>false</filtering> | |
| 365 | 365 | <excludes> | |
| 366 | - <exclude>/jcpversion.props</exclude> | ||
| 366 | + <exclude>/jcpversion.properties</exclude> | ||
| 367 | 367 | </excludes> | |
| 368 | 368 | </resource> | |
| 369 | 369 | <resource> | |
| 370 | 370 | <directory>src/main/resources</directory> | |
| 371 | 371 | <filtering>true</filtering> | |
| 372 | 372 | <includes> | |
| 373 | - <include>**/jcpversion.props</include> | ||
| 373 | + <include>**/jcpversion.properties</include> | ||
| 374 | 374 | </includes> | |
| 375 | 375 | </resource> | |
| 376 | 376 | </resources> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | package com.igormaznitsa.jcp; | |
| 23 | 23 | ||
| 24 | 24 | import static com.igormaznitsa.jcp.context.JCPSpecialVariableProcessor.getReference; | |
| 25 | + import static java.util.Objects.requireNonNull; | ||
| 25 | 26 | import static java.util.stream.Collectors.toList; | |
| 26 | 27 | ||
| 27 | 28 | import com.igormaznitsa.jcp.cmdline.CommandLineHandler; | |
@@ -35,7 +36,6 @@ | |||
| 35 | 36 | import java.util.ArrayList; | |
| 36 | 37 | import java.util.List; | |
| 37 | 38 | import java.util.Locale; | |
| 38 | - import java.util.Objects; | ||
| 39 | 39 | import java.util.Properties; | |
| 40 | 40 | ||
| 41 | 41 | public final class InfoHelper { | |
@@ -48,13 +48,13 @@ public final class InfoHelper { | |||
| 48 | 48 | public static final int YEAR; | |
| 49 | 49 | ||
| 50 | 50 | static { | |
| 51 | - final String path = "/jcpversion.props"; | ||
| 51 | + final String path = "/jcpversion.properties"; | ||
| 52 | 52 | try (final InputStream stream = InfoHelper.class.getResourceAsStream(path)) { | |
| 53 | 53 | final Properties props = new Properties(); | |
| 54 | 54 | props.load(stream); | |
| 55 | - VERSION = Objects.requireNonNull(props.getProperty("version")); | ||
| 56 | - URL = Objects.requireNonNull(props.getProperty("url")); | ||
| 57 | - YEAR = Integer.parseInt(Objects.requireNonNull(props.getProperty("year")).trim()); | ||
| 55 | + VERSION = requireNonNull(props.getProperty("version")); | ||
| 56 | + URL = requireNonNull(props.getProperty("url")); | ||
| 57 | + YEAR = Integer.parseInt(requireNonNull(props.getProperty("year")).trim()); | ||
| 58 | 58 | } catch (IOException ex) { | |
| 59 | 59 | throw new IllegalStateException("Can't read resource: " + path, ex); | |
| 60 | 60 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | 22 | package com.igormaznitsa.jcp.expression; | |
| 23 | 23 | ||
| 24 | - import com.igormaznitsa.jcp.context.PreprocessingState; | ||
| 25 | 24 | import com.igormaznitsa.jcp.context.PreprocessorContext; | |
| 26 | 25 | import com.igormaznitsa.jcp.exceptions.FilePositionInfo; | |
| 27 | 26 | import com.igormaznitsa.jcp.exceptions.PreprocessorException; | |
@@ -51,21 +50,12 @@ public class Expression { | |||
| 51 | 50 | */ | |
| 52 | 51 | private static final Class<?>[] OPERATOR_SIGNATURE_2 = new Class<?>[] {Value.class, Value.class}; | |
| 53 | 52 | ||
| 54 | - /** | ||
| 55 | - * The variable contains the preprocessor context for the expression, it can be null | ||
| 56 | - */ | ||
| 57 | - private final PreprocessorContext context; | ||
| 58 | - | ||
| 59 | 53 | /** | |
| 60 | 54 | * The variable contains the expression tree | |
| 61 | 55 | */ | |
| 62 | 56 | private final ExpressionTree expressionTree; | |
| 63 | 57 | ||
| 64 | - private Expression(final PreprocessorContext context, final ExpressionTree tree) { | ||
| 65 | - if (tree == null) { | ||
| 66 | - throw context.makeException("[Expression]The expression tree is null", null); | ||
| 67 | - } | ||
| 68 | - this.context = context; | ||
| 58 | + private Expression(final ExpressionTree tree) { | ||
| 69 | 59 | this.expressionTree = tree; | |
| 70 | 60 | } | |
| 71 | 61 | ||
@@ -97,13 +87,13 @@ public static Value evalExpression(final String expression, final PreprocessorCo | |||
| 97 | 87 | */ | |
| 98 | 88 | ||
| 99 | 89 | public static Value evalTree(final ExpressionTree tree, final PreprocessorContext context) { | |
| 100 | - final Expression exp = new Expression(context, tree); | ||
| 101 | - return exp.eval(context.getPreprocessingState()); | ||
| 90 | + final Expression exp = new Expression(tree); | ||
| 91 | + return exp.eval(context); | ||
| 102 | 92 | } | |
| 103 | 93 | ||
| 104 | 94 | ||
| 105 | 95 | private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionElement, | |
| 106 | - final PreprocessingState state) { | ||
| 96 | + final PreprocessorContext context) { | ||
| 107 | 97 | final AbstractFunction function = (AbstractFunction) functionElement.getItem(); | |
| 108 | 98 | ||
| 109 | 99 | final int arity = function.getArity(); | |
@@ -114,8 +104,8 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 114 | 104 | final FilePositionInfo[] stack; | |
| 115 | 105 | final String sources; | |
| 116 | 106 | ||
| 117 | - stack = state.makeIncludeStack(); | ||
| 118 | - sources = state.getLastReadString(); | ||
| 107 | + stack = context.getPreprocessingState().makeIncludeStack(); | ||
| 108 | + sources = context.getPreprocessingState().getLastReadString(); | ||
| 119 | 109 | ||
| 120 | 110 | final StringBuilder signature = new StringBuilder(AbstractFunction.EXECUTION_PREFIX); | |
| 121 | 111 | ||
@@ -125,14 +115,14 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 125 | 115 | ||
| 126 | 116 | for (int i = 0; i < arity; i++) { | |
| 127 | 117 | final ExpressionTreeElement item = | |
| 128 | - calculateTreeElement(functionElement.getChildForIndex(i), state); | ||
| 118 | + this.calculateTreeElement(functionElement.getChildForIndex(i), context); | ||
| 129 | 119 | ||
| 130 | 120 | final ExpressionItem itemValue = item.getItem(); | |
| 131 | 121 | ||
| 132 | 122 | if (itemValue instanceof Value) { | |
| 133 | 123 | arguments[i] = (Value) itemValue; | |
| 134 | 124 | } else { | |
| 135 | - throw this.context.makeException( | ||
| 125 | + throw context.makeException( | ||
| 136 | 126 | "[Expression]Wrong argument type detected for the '" + function.getName() + | |
| 137 | 127 | "' function", null); | |
| 138 | 128 | } | |
@@ -162,7 +152,7 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 162 | 152 | } | |
| 163 | 153 | ||
| 164 | 154 | if (allowed == null) { | |
| 165 | - throw this.context.makeException( | ||
| 155 | + throw context.makeException( | ||
| 166 | 156 | "[Expression]Unsupported argument detected for '" + function.getName() + '\'', null); | |
| 167 | 157 | } | |
| 168 | 158 | ||
@@ -171,7 +161,7 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 171 | 161 | try { | |
| 172 | 162 | return new ExpressionTreeElement(userFunction.execute(context, arguments), stack, sources); | |
| 173 | 163 | } catch (Exception unexpected) { | |
| 174 | - throw this.context | ||
| 164 | + throw context | ||
| 175 | 165 | .makeException("[Expression]Unexpected exception during a user function processing", | |
| 176 | 166 | unexpected); | |
| 177 | 167 | } | |
@@ -186,21 +176,21 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 186 | 176 | final Value result = (Value) method.invoke(function, callArgs); | |
| 187 | 177 | ||
| 188 | 178 | if (!result.getType().isCompatible(function.getResultType())) { | |
| 189 | - throw this.context.makeException("[Expression]Unsupported function result detected [" + | ||
| 179 | + throw context.makeException("[Expression]Unsupported function result detected [" + | ||
| 190 | 180 | result.getType().getSignature() + ']', null); | |
| 191 | 181 | } | |
| 192 | 182 | ||
| 193 | 183 | return new ExpressionTreeElement(result, stack, sources); | |
| 194 | 184 | } catch (NoSuchMethodException unexpected) { | |
| 195 | - throw this.context.makeException( | ||
| 185 | + throw context.makeException( | ||
| 196 | 186 | "[Expression]Can't find a function method to process data [" + signature + | |
| 197 | 187 | ']', unexpected); | |
| 198 | 188 | } catch (Exception unexpected) { | |
| 199 | 189 | final Throwable cause = unexpected.getCause(); | |
| 200 | 190 | if (cause instanceof PreprocessorException) { | |
| 201 | 191 | throw (PreprocessorException) cause; | |
| 202 | 192 | } | |
| 203 | - throw this.context.makeException( | ||
| 193 | + throw context.makeException( | ||
| 204 | 194 | "[Expression]Can't execute a function method to process data [" + | |
| 205 | 195 | function.getClass().getName() + '.' + signature + ']', unexpected); | |
| 206 | 196 | } | |
@@ -209,7 +199,7 @@ private ExpressionTreeElement evalFunction(final ExpressionTreeElement functionE | |||
| 209 | 199 | ||
| 210 | 200 | ||
| 211 | 201 | private ExpressionTreeElement evalOperator(final ExpressionTreeElement operatorElement, | |
| 212 | - final PreprocessingState state) { | ||
| 202 | + final PreprocessorContext context) { | ||
| 213 | 203 | final AbstractOperator operator = (AbstractOperator) operatorElement.getItem(); | |
| 214 | 204 | ||
| 215 | 205 | final int arity = operator.getArity(); | |
@@ -224,25 +214,25 @@ private ExpressionTreeElement evalOperator(final ExpressionTreeElement operatorE | |||
| 224 | 214 | final FilePositionInfo[] stack; | |
| 225 | 215 | final String sources; | |
| 226 | 216 | ||
| 227 | - stack = state.makeIncludeStack(); | ||
| 228 | - sources = state.getLastReadString(); | ||
| 217 | + stack = context.getPreprocessingState().makeIncludeStack(); | ||
| 218 | + sources = context.getPreprocessingState().getLastReadString(); | ||
| 229 | 219 | ||
| 230 | 220 | for (int i = 0; i < arity; i++) { | |
| 231 | 221 | final ExpressionTreeElement arg = operatorElement.getChildForIndex(i); | |
| 232 | 222 | if (arg == ExpressionTreeElement.EMPTY_SLOT) { | |
| 233 | - throw this.context.makeException( | ||
| 223 | + throw context.makeException( | ||
| 234 | 224 | "[Expression]There is not needed argument for the operator [" + operator.getKeyword() + | |
| 235 | 225 | ']', null); | |
| 236 | 226 | } | |
| 237 | 227 | ||
| 238 | - final ExpressionTreeElement currentElement = calculateTreeElement(arg, state); | ||
| 228 | + final ExpressionTreeElement currentElement = calculateTreeElement(arg, context); | ||
| 239 | 229 | ||
| 240 | 230 | final ExpressionItem item = currentElement.getItem(); | |
| 241 | 231 | ||
| 242 | 232 | if (item instanceof Value) { | |
| 243 | 233 | arguments[i] = (Value) item; | |
| 244 | 234 | } else { | |
| 245 | - throw this.context.makeException( | ||
| 235 | + throw context.makeException( | ||
| 246 | 236 | "[Expression]Non-value detected for the '" + operator.getKeyword() + "' operator", | |
| 247 | 237 | null); | |
| 248 | 238 | } | |
@@ -284,7 +274,7 @@ private ExpressionTreeElement evalOperator(final ExpressionTreeElement operatorE | |||
| 284 | 274 | } | |
| 285 | 275 | ||
| 286 | 276 | if (executeMethod == null) { | |
| 287 | - throw this.context.makeException( | ||
| 277 | + throw context.makeException( | ||
| 288 | 278 | "[Expression]Unsupported arguments detected for operator '" + operator.getKeyword() + | |
| 289 | 279 | "' " + Arrays.toString(arguments), null); | |
| 290 | 280 | } | |
@@ -302,15 +292,15 @@ private ExpressionTreeElement evalOperator(final ExpressionTreeElement operatorE | |||
| 302 | 292 | throw new RuntimeException( | |
| 303 | 293 | "Invocation exception during '" + operator.getKeyword() + "' processing", thr); | |
| 304 | 294 | } catch (Exception unexpected) { | |
| 305 | - throw this.context | ||
| 295 | + throw context | ||
| 306 | 296 | .makeException("[Exception]Exception during '" + operator.getKeyword() + "' processing", | |
| 307 | 297 | unexpected); | |
| 308 | 298 | } | |
| 309 | 299 | } | |
| 310 | 300 | ||
| 311 | 301 | ||
| 312 | 302 | private ExpressionTreeElement calculateTreeElement(final ExpressionTreeElement element, | |
| 313 | - final PreprocessingState state) { | ||
| 303 | + final PreprocessorContext context) { | ||
| 314 | 304 | ExpressionTreeElement treeElement = element; | |
| 315 | 305 | ||
| 316 | 306 | switch (element.getItem().getExpressionItemType()) { | |
@@ -326,38 +316,39 @@ private ExpressionTreeElement calculateTreeElement(final ExpressionTreeElement e | |||
| 326 | 316 | throw new RuntimeException("Unknown variable [" + name + ']'); | |
| 327 | 317 | } else { | |
| 328 | 318 | treeElement = | |
| 329 | - new ExpressionTreeElement(value, state.makeIncludeStack(), state.getLastReadString()); | ||
| 319 | + new ExpressionTreeElement(value, context.getPreprocessingState().makeIncludeStack(), | ||
| 320 | + context.getPreprocessingState().getLastReadString()); | ||
| 330 | 321 | } | |
| 331 | 322 | } | |
| 332 | 323 | break; | |
| 333 | 324 | case OPERATOR: { | |
| 334 | - treeElement = evalOperator(element, state); | ||
| 325 | + treeElement = this.evalOperator(element, context); | ||
| 335 | 326 | } | |
| 336 | 327 | break; | |
| 337 | 328 | case FUNCTION: { | |
| 338 | - treeElement = evalFunction(element, state); | ||
| 329 | + treeElement = evalFunction(element, context); | ||
| 339 | 330 | } | |
| 340 | 331 | break; | |
| 341 | 332 | } | |
| 342 | 333 | return treeElement; | |
| 343 | 334 | } | |
| 344 | 335 | ||
| 345 | 336 | ||
| 346 | - private Value eval(final PreprocessingState state) { | ||
| 337 | + private Value eval(final PreprocessorContext context) { | ||
| 347 | 338 | if (expressionTree.isEmpty()) { | |
| 348 | - throw this.context.makeException("[Expression]The expression is empty", null); | ||
| 339 | + throw context.makeException("[Expression]The expression is empty", null); | ||
| 349 | 340 | } | |
| 350 | - final ExpressionTreeElement result = calculateTreeElement(expressionTree.getRoot(), state); | ||
| 341 | + final ExpressionTreeElement result = calculateTreeElement(expressionTree.getRoot(), context); | ||
| 351 | 342 | final ExpressionItem resultItem = result.getItem(); | |
| 352 | 343 | ||
| 353 | 344 | if (resultItem == null) { | |
| 354 | - throw this.context.makeException("[Expression]Expression doesn't have result", null); | ||
| 345 | + throw context.makeException("[Expression]Expression doesn't have result", null); | ||
| 355 | 346 | } | |
| 356 | 347 | ||
| 357 | 348 | if (resultItem instanceof Value) { | |
| 358 | 349 | return (Value) resultItem; | |
| 359 | 350 | } else { | |
| 360 | - throw this.context | ||
| 351 | + throw context | ||
| 361 | 352 | .makeException("[Expression]The expression returns non-value result [" + resultItem + ']', | |
| 362 | 353 | null); | |
| 363 | 354 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,10 +164,11 @@ | |||
| 164 | 164 | <plugin> | |
| 165 | 165 | <groupId>org.codehaus.mojo</groupId> | |
| 166 | 166 | <artifactId>build-helper-maven-plugin</artifactId> | |
| 167 | - <version>3.0.0</version> | ||
| 167 | + <version>3.4.0</version> | ||
| 168 | 168 | </plugin> | |
| 169 | 169 | </plugins> | |
| 170 | 170 | </pluginManagement> | |
| 171 | + | ||
| 171 | 172 | <plugins> | |
| 172 | 173 | <plugin> | |
| 173 | 174 | <groupId>org.codehaus.mojo</groupId> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments