Don't use a no-op suggester

This commit is contained in:
Matthew Miller 2019-05-19 13:49:37 +10:00
parent a3ffb91917
commit 4804fe64e3
12 changed files with 16 additions and 15 deletions

View File

@ -97,7 +97,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
@Override
public List<String> getSuggestions(String input) {
return limitByPrefix(factoryExtractor.apply(worldEdit).getSuggestions(), input);
return factoryExtractor.apply(worldEdit).getSuggestions(input);
}
@Override

View File

@ -201,7 +201,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
// TODO Include states
return BlockType.REGISTRY.keySet().stream();
}

View File

@ -41,7 +41,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return ItemType.REGISTRY.keySet().stream();
}

View File

@ -45,7 +45,7 @@ public class BiomeMaskParser extends InputParser<Mask> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return BiomeType.REGISTRY.keySet().stream().map(biomeType -> "$" + biomeType);
}

View File

@ -38,7 +38,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str);
}

View File

@ -43,8 +43,8 @@ public class BlocksMaskParser extends InputParser<Mask> {
}
@Override
public Stream<String> getSuggestions() {
return worldEdit.getBlockFactory().getSuggestions();
public Stream<String> getSuggestions(String input) {
return worldEdit.getBlockFactory().getSuggestions(input).stream();
}
@Override

View File

@ -40,7 +40,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return BlockCategory.REGISTRY.keySet().stream().map(str -> "##" + str);
}

View File

@ -40,7 +40,7 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return Stream.of("#clipboard", "#copy");
}

View File

@ -36,8 +36,8 @@ public class SingleBlockPatternParser extends InputParser<Pattern> {
}
@Override
public Stream<String> getSuggestions() {
return worldEdit.getBlockFactory().getSuggestions();
public Stream<String> getSuggestions(String input) {
return worldEdit.getBlockFactory().getSuggestions(input).stream();
}
@Override

View File

@ -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<E> {
throw new NoMatchException("No match for '" + input + "'");
}
public Stream<String> getSuggestions() {
return parsers.stream().flatMap(InputParser::getSuggestions);
public List<String> getSuggestions(String input) {
return limitByPrefix(parsers.stream().flatMap(parser -> parser.getSuggestions(input)), input);
}
/**

View File

@ -48,7 +48,7 @@ public abstract class InputParser<E> {
*
* @return a stream of suggestions
*/
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return Stream.empty();
}
}

View File

@ -66,7 +66,7 @@ public abstract class SimpleInputParser<E> extends InputParser<E> {
}
@Override
public Stream<String> getSuggestions() {
public Stream<String> getSuggestions(String input) {
return Stream.of(getPrimaryMatcher());
}
}