[PlutoCommandParser] Code cleanup

This commit is contained in:
493msi 2020-09-21 00:05:43 +02:00
parent c3bd358bed
commit aa70f1bbe2
3 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,7 @@ can now only be modified only through public setters
* `[PlutoCore]` Refactored `InputBus` and added several convenience methods * `[PlutoCore]` Refactored `InputBus` and added several convenience methods
* `[PlutoCore]` Refactored input callbacks * `[PlutoCore]` Refactored input callbacks
* `[PlutoStatic]` Slight cleanup in the `Display` and `DisplayBuilder` classes * `[PlutoStatic]` Slight cleanup in the `Display` and `DisplayBuilder` classes
* `[PlutoCommandParser]` Code cleanup
## 20.2.0.0-alpha.1 ## 20.2.0.0-alpha.1
* `[PlutoLib#cz.tefek.pluto.io.logger]` Refactored the Logger subsystem * `[PlutoLib#cz.tefek.pluto.io.logger]` Refactored the Logger subsystem

View File

@ -4,7 +4,7 @@ import cz.tefek.pluto.command.CommandBase;
public class CommandContextBuilder public class CommandContextBuilder
{ {
private CommandContext ctx; private final CommandContext ctx;
public CommandContextBuilder() public CommandContextBuilder()
{ {

View File

@ -14,7 +14,7 @@ import cz.tefek.pluto.command.registry.CommandRegistry;
public class CommandParser public class CommandParser
{ {
private String text; private final String text;
private Set<OfInt> prefixes; private Set<OfInt> prefixes;
private EnumParserState state; private EnumParserState state;
@ -196,7 +196,11 @@ public class CommandParser
this.state = EnumParserState.READING_PREFIX; this.state = EnumParserState.READING_PREFIX;
} }
this.text.codePoints().takeWhile(this::readCodepoint); var cps = this.text.codePoints();
for (var cpIt = cps.iterator(); cpIt.hasNext(); )
if (!this.readCodepoint(cpIt.next()))
break;
// Update the state for EOF // Update the state for EOF
switch (this.state) switch (this.state)