Tabnine Logo
Suggestion.expand
Code IndexAdd Tabnine to your IDE (free)

How to use
expand
method
in
com.mojang.brigadier.suggestion.Suggestion

Best Java code snippets using com.mojang.brigadier.suggestion.Suggestion.expand (Showing top 6 results out of 315)

origin: Mojang/brigadier

  public static Suggestions create(final String command, final Collection<Suggestion> suggestions) {
    if (suggestions.isEmpty()) {
      return EMPTY;
    }
    int start = Integer.MAX_VALUE;
    int end = Integer.MIN_VALUE;
    for (final Suggestion suggestion : suggestions) {
      start = Math.min(suggestion.getRange().getStart(), start);
      end = Math.max(suggestion.getRange().getEnd(), end);
    }
    final StringRange range = new StringRange(start, end);
    final Set<Suggestion> texts = new HashSet<>();
    for (final Suggestion suggestion : suggestions) {
      texts.add(suggestion.expand(command, range));
    }
    final List<Suggestion> sorted = new ArrayList<>(texts);
    sorted.sort((a, b) -> a.compareToIgnoreCase(b));
    return new Suggestions(range, sorted);
  }
}
origin: Mojang/brigadier

@Test
public void expand_unchanged() {
  final Suggestion suggestion = new Suggestion(StringRange.at(1), "oo");
  assertThat(suggestion.expand("f", StringRange.at(1)), equalTo(suggestion));
}
origin: Mojang/brigadier

@Test
public void expand_right() {
  final Suggestion suggestion = new Suggestion(StringRange.at(0), "minecraft:");
  assertThat(suggestion.expand("fish", StringRange.between(0, 4)), equalTo(new Suggestion(StringRange.between(0, 4), "minecraft:fish")));
}
origin: Mojang/brigadier

@Test
public void expand_left() {
  final Suggestion suggestion = new Suggestion(StringRange.at(1), "oo");
  assertThat(suggestion.expand("f", StringRange.between(0, 1)), equalTo(new Suggestion(StringRange.between(0, 1), "foo")));
}
origin: Mojang/brigadier

@Test
public void expand_both() {
  final Suggestion suggestion = new Suggestion(StringRange.at(11), "minecraft:");
  assertThat(suggestion.expand("give Steve fish_block", StringRange.between(5, 21)), equalTo(new Suggestion(StringRange.between(5, 21), "Steve minecraft:fish_block")));
}
origin: Mojang/brigadier

  @Test
  public void expand_replacement() {
    final Suggestion suggestion = new Suggestion(StringRange.between(6, 11), "strangers");
    assertThat(suggestion.expand("Hello world!", StringRange.between(0, 12)), equalTo(new Suggestion(StringRange.between(0, 12), "Hello strangers!")));
  }
}
com.mojang.brigadier.suggestionSuggestionexpand

Popular methods of Suggestion

  • <init>
  • getText
  • apply
  • compareTo
  • compareToIgnoreCase
  • equals
  • getRange
  • getTooltip
  • hashCode

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • ImageIO (javax.imageio)
  • JList (javax.swing)
  • JPanel (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now