feat: math expressions in input fields#1106
feat: math expressions in input fields#1106lucasser wants to merge 2 commits intorefinedmods:developfrom
Conversation
f6b2638 to
3720b7b
Compare
73e9574 to
5d2c8d7
Compare
|
I added an ifValidOrElse method to ParsedValue to use instead of ifpresentorelse, idk if that works. Other than everything should be fixed. |
0a3390b to
15bb80f
Compare
15bb80f to
9869bac
Compare
9869bac to
844026a
Compare
844026a to
5c598ca
Compare
5c598ca to
f79e188
Compare
f79e188 to
daeee48
Compare
|
Please rebase on |
daeee48 to
626ea91
Compare
626ea91 to
6ed6e76
Compare
raoulvdberge
left a comment
There was a problem hiding this comment.
And rebase on develop please
| return Optional.ofNullable(value); | ||
| } | ||
|
|
||
| public boolean isValid() { |
There was a problem hiding this comment.
Is the only use for ParseValue to indicate out of boundness? I don't care about reporting that error back to the user, so can we remove this class please?
| * Evaluate a math expression inside a string. | ||
| */ | ||
|
|
||
| public class Evaluator { |
There was a problem hiding this comment.
MathExpressionEvaluator and then we can remove the comment on top of this class.
|
|
||
| public Evaluator(final Source source) { | ||
| if (source.content().isEmpty()) { | ||
| throw new EvaluatorException(""); |
| lexer = new Lexer(source, LexerTokenMappings.ARITHMETIC_MAPPINGS); | ||
| lexer.scan(); | ||
| } catch (LexerException e) { | ||
| throw new EvaluatorException("unrecognized character"); |
There was a problem hiding this comment.
Always pass exception context along
| throw new EvaluatorException("unrecognized character"); | |
| throw new EvaluatorException("unrecognized character", e); |
| parser = new Parser(applyUnits(lexer.getTokens()), ParserOperatorMappings.ARITHMETIC_MAPPINGS); | ||
| parser.parse(); | ||
| } catch (ParserException e) { | ||
| throw new EvaluatorException("syntax error"); |
| @FieldsAndMethodsAreNonnullByDefault | ||
| package com.refinedmods.refinedstorage.query.evaluator; | ||
|
|
||
| import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; |
There was a problem hiding this comment.
I don't think this exists in develop anymore?
| ### Added | ||
|
|
||
| - You can now configure Refined Storage to not require energy. Controllers are not necessary in this case. Creative variants of items will be hidden and items will function without energy. | ||
| - Support for entering math expressions when requesting a craft, creating a pattern, and configuring a detector. |
There was a problem hiding this comment.
| - Support for entering math expressions when requesting a craft, creating a pattern, and configuring a detector. | |
| - Support for entering math expressions when requesting autocrafting, creating a processing pattern, and configuring a detector. |
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| class EvaluatorTest { |
There was a problem hiding this comment.
Where are the tests for the units?
| return e.getMessage(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't see any exception edge cases being tested. You probably want to run mutation testing here to check what you're missing!
| public class Evaluator { | ||
| private final Source source; | ||
| private final List<Node> nodes = new ArrayList<>(); | ||
| private final Map<String, Double> unitMap = Map.of( |
Implements #199