Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to getSuggestions the CommandArgs parameter #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sat Jun 20 16:01:15 PDT 2015
#Fri Jul 03 06:22:44 EEST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Body get(CommandArgs arguments, List<? extends Annotation> modifiers) thr
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return ImmutableList.copyOf(universe.getPrefixedWith(prefix).keySet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public User get(CommandArgs arguments, List<? extends Annotation> modifiers) thr
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return ImmutableList.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public User get(CommandArgs arguments, List<? extends Annotation> modifiers) thr
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return ImmutableList.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public T get(CommandArgs arguments, List<? extends Annotation> modifiers) {
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public interface Provider<T> {
* <p>If no suggestions could be enumerated, an empty list should
* be returned.</p>
*
* @param arguments The arguments
* @param modifiers The modifiers on the parameter
* @param prefix What the user has typed so far (may be an empty string)
* @return A list of suggestions
*/
List<String> getSuggestions(String prefix);
List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix);

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Boolean get(CommandArgs arguments, List<? extends Annotation> modifiers)
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CommandArgs get(CommandArgs arguments, List<? extends Annotation> modifie
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return ImmutableList.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public T get(CommandArgs arguments, List<? extends Annotation> modifiers) throws
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
List<String> suggestions = Lists.newArrayList();
String test = simplify(prefix);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package com.sk89q.intake.parametric.provider;

import com.sk89q.intake.argument.ArgumentParseException;
import com.sk89q.intake.argument.CommandArgs;
import com.sk89q.intake.parametric.Provider;
import com.sk89q.intake.parametric.annotation.Range;

Expand All @@ -36,7 +37,7 @@ public boolean isProvided() {
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String get(CommandArgs arguments, List<? extends Annotation> modifiers) t
}

@Override
public List<String> getSuggestions(String prefix) {
public List<String> getSuggestions(CommandArgs arguments, List<? extends Annotation> modifiers, String prefix) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public void testGetMissing() throws Exception {

@Test
public void testGetSuggestions() throws Exception {
assertThat(provider.getSuggestions(""), containsInAnyOrder("small", "medium", "large", "very_large"));
assertThat(provider.getSuggestions("s"), containsInAnyOrder("small"));
assertThat(provider.getSuggestions("la"), containsInAnyOrder("large"));
assertThat(provider.getSuggestions("very"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions("verylarg"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions("very_"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions("tiny"), Matchers.<String>empty());
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), ""), containsInAnyOrder("small", "medium", "large", "very_large"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "s"), containsInAnyOrder("small"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "la"), containsInAnyOrder("large"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "very"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "verylarg"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "very_"), containsInAnyOrder("very_large"));
assertThat(provider.getSuggestions(Arguments.of(), ImmutableList.<Annotation>of(), "tiny"), Matchers.<String>empty());
}

enum Size {
Expand Down