From 4804fe64e36d02a103a1f39d3f7fbd93c4938e5b Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 19 May 2019 13:49:37 +1000 Subject: [PATCH] Don't use a no-op suggester --- .../sk89q/worldedit/command/argument/FactoryConverter.java | 2 +- .../extension/factory/parser/DefaultBlockParser.java | 2 +- .../extension/factory/parser/DefaultItemParser.java | 2 +- .../extension/factory/parser/mask/BiomeMaskParser.java | 2 +- .../factory/parser/mask/BlockCategoryMaskParser.java | 2 +- .../extension/factory/parser/mask/BlocksMaskParser.java | 4 ++-- .../factory/parser/pattern/BlockCategoryPatternParser.java | 2 +- .../factory/parser/pattern/ClipboardPatternParser.java | 2 +- .../factory/parser/pattern/SingleBlockPatternParser.java | 4 ++-- .../sk89q/worldedit/internal/registry/AbstractFactory.java | 5 +++-- .../com/sk89q/worldedit/internal/registry/InputParser.java | 2 +- .../sk89q/worldedit/internal/registry/SimpleInputParser.java | 2 +- 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java index 826e3a1cd..d28f15ec9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java @@ -97,7 +97,7 @@ public class FactoryConverter implements ArgumentConverter { @Override public List getSuggestions(String input) { - return limitByPrefix(factoryExtractor.apply(worldEdit).getSuggestions(), input); + return factoryExtractor.apply(worldEdit).getSuggestions(input); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 5a962a9a3..a2d069bd8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -201,7 +201,7 @@ public class DefaultBlockParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { // TODO Include states return BlockType.REGISTRY.keySet().stream(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java index 52658327e..702e54458 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultItemParser.java @@ -41,7 +41,7 @@ public class DefaultItemParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return ItemType.REGISTRY.keySet().stream(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java index af887e432..d484b4ff9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java @@ -45,7 +45,7 @@ public class BiomeMaskParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return BiomeType.REGISTRY.keySet().stream().map(biomeType -> "$" + biomeType); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java index 7c20d9ee2..630386b56 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java @@ -38,7 +38,7 @@ public class BlockCategoryMaskParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java index 85c414383..df7ed3a16 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java @@ -43,8 +43,8 @@ public class BlocksMaskParser extends InputParser { } @Override - public Stream getSuggestions() { - return worldEdit.getBlockFactory().getSuggestions(); + public Stream getSuggestions(String input) { + return worldEdit.getBlockFactory().getSuggestions(input).stream(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java index 6c83b569f..f9e0f8052 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java @@ -40,7 +40,7 @@ public class BlockCategoryPatternParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java index 1f88aecbd..4029c4359 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java @@ -40,7 +40,7 @@ public class ClipboardPatternParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return Stream.of("#clipboard", "#copy"); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java index 8e2b99bae..3bd852513 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java @@ -36,8 +36,8 @@ public class SingleBlockPatternParser extends InputParser { } @Override - public Stream getSuggestions() { - return worldEdit.getBlockFactory().getSuggestions(); + public Stream getSuggestions(String input) { + return worldEdit.getBlockFactory().getSuggestions(input).stream(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java index 6fd8523c0..d4ec8bef8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.internal.registry; import static com.google.common.base.Preconditions.checkNotNull; +import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; @@ -79,8 +80,8 @@ public abstract class AbstractFactory { throw new NoMatchException("No match for '" + input + "'"); } - public Stream getSuggestions() { - return parsers.stream().flatMap(InputParser::getSuggestions); + public List getSuggestions(String input) { + return limitByPrefix(parsers.stream().flatMap(parser -> parser.getSuggestions(input)), input); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java index a5dc1e992..5862d9cf9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java @@ -48,7 +48,7 @@ public abstract class InputParser { * * @return a stream of suggestions */ - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return Stream.empty(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/SimpleInputParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/SimpleInputParser.java index 8ed5f338c..013e45958 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/SimpleInputParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/SimpleInputParser.java @@ -66,7 +66,7 @@ public abstract class SimpleInputParser extends InputParser { } @Override - public Stream getSuggestions() { + public Stream getSuggestions(String input) { return Stream.of(getPrimaryMatcher()); } }