@Test public void testUpdateSuggestions() { AutocompleteSuggestion autocompleteSuggestion = new AutocompleteSuggestion("text", SuggestionType.UNKNOWN, true, "desc", 42, 3, "hint"); assertThat( updateSuggestions(ImmutableList.of(autocompleteSuggestion), false, NODE_NAME, 0), equalTo( ImmutableSet.of( new ParboiledAutoCompleteSuggestion("text", "hint", 0, NODE_NAME, "desc")))); }
@VisibleForTesting @Nonnull static Set<ParboiledAutoCompleteSuggestion> updateSuggestions( List<AutocompleteSuggestion> suggestions, boolean escape, Anchor.Type anchorType, int startIndex) { return suggestions.stream() .map( s -> new ParboiledAutoCompleteSuggestion( escape || (isEscapableNameAnchor(anchorType) && nameNeedsEscaping(s.getText())) ? ESCAPE_CHAR + s.getText() + ESCAPE_CHAR : s.getText(), Optional.ofNullable(s.getHint()).orElseGet(anchorType::getHint), startIndex, anchorType, Optional.ofNullable(s.getDescription()).orElse(null))) .collect(ImmutableSet.toImmutableSet()); }
ParboiledAutoComplete { @VisibleForTesting @Nonnull static Set<ParboiledAutoCompleteSuggestion> updateSuggestions( List<AutocompleteSuggestion> suggestions, boolean escape, Anchor.Type anchorType, int startIndex) { return suggestions.stream() .map( s -> new ParboiledAutoCompleteSuggestion( escape || (isEscapableNameAnchor(anchorType) && nameNeedsEscaping(s.getText())) ? ESCAPE_CHAR + s.getText() + ESCAPE_CHAR : s.getText(), Optional.ofNullable(s.getHint()).orElseGet(anchorType::getHint), startIndex, anchorType, Optional.ofNullable(s.getDescription()).orElse(null))) .collect(ImmutableSet.toImmutableSet()); } }
ParboiledAutoComplete { @VisibleForTesting @Nonnull static Set<ParboiledAutoCompleteSuggestion> updateSuggestions( List<AutocompleteSuggestion> suggestions, boolean escape, Anchor.Type anchorType, int startIndex) { return suggestions.stream() .map( s -> new ParboiledAutoCompleteSuggestion( escape || (isEscapableNameAnchor(anchorType) && nameNeedsEscaping(s.getText())) ? ESCAPE_CHAR + s.getText() + ESCAPE_CHAR : s.getText(), Optional.ofNullable(s.getHint()).orElseGet(anchorType::getHint), startIndex, anchorType, Optional.ofNullable(s.getDescription()).orElse(null))) .collect(ImmutableSet.toImmutableSet()); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); }
ParboiledAutoComplete { @VisibleForTesting @Nonnull static Set<ParboiledAutoCompleteSuggestion> updateSuggestions( List<AutocompleteSuggestion> suggestions, boolean escape, Anchor.Type anchorType, int startIndex) { return suggestions.stream() .map( s -> new ParboiledAutoCompleteSuggestion( escape || (isEscapableNameAnchor(anchorType) && nameNeedsEscaping(s.getText())) ? ESCAPE_CHAR + s.getText() + ESCAPE_CHAR : s.getText(), Optional.ofNullable(s.getHint()).orElseGet(anchorType::getHint), startIndex, anchorType, Optional.ofNullable(s.getDescription()).orElse(null))) .collect(ImmutableSet.toImmutableSet()); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static List<AutocompleteSuggestion> autoComplete(
      Grammar grammar,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); }
ParboiledAutoComplete { @VisibleForTesting @Nonnull static Set<ParboiledAutoCompleteSuggestion> updateSuggestions( List<AutocompleteSuggestion> suggestions, boolean escape, Anchor.Type anchorType, int startIndex) { return suggestions.stream() .map( s -> new ParboiledAutoCompleteSuggestion( escape || (isEscapableNameAnchor(anchorType) && nameNeedsEscaping(s.getText())) ? ESCAPE_CHAR + s.getText() + ESCAPE_CHAR : s.getText(), Optional.ofNullable(s.getHint()).orElseGet(anchorType::getHint), startIndex, anchorType, Optional.ofNullable(s.getDescription()).orElse(null))) .collect(ImmutableSet.toImmutableSet()); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static List<AutocompleteSuggestion> autoComplete(
      Grammar grammar,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);  }