#305 Adjust behavior of label handling; cleanup

- Fix bugs in behavior (wrong labels being shown for help)
- Change order of labels and arguments in FoundCommandResult constructors
- Move FoundResultStatus enum to its own class
- Create test class for HelpProvider
This commit is contained in:
ljacqu
2015-12-18 22:19:26 +01:00
parent d871939793
commit 01a294a334
9 changed files with 231 additions and 51 deletions
@@ -1,5 +1,6 @@
package fr.xephi.authme.command.help;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import fr.xephi.authme.command.CommandArgumentDescription;
@@ -216,11 +217,12 @@ public final class HelpProvider {
return (flag & options) != 0;
}
private static List<String> filterCorrectLabels(CommandDescription command, List<String> labels) {
@VisibleForTesting
protected static List<String> filterCorrectLabels(CommandDescription command, List<String> labels) {
List<CommandDescription> commands = new ArrayList<>(command.getParentCount() + 1);
CommandDescription currentCommand = command;
while (currentCommand != null) {
commands.add(command);
commands.add(currentCommand);
currentCommand = currentCommand.getParent();
}
commands = Lists.reverse(commands);