@Test public void testFindPrecedingInputMissingAnchor() { _thrown.expect(IllegalArgumentException.class); ParboiledAutoComplete.findPrecedingInput( new PotentialMatch( new PathElement(Type.INTERFACE_NAME, null, 0, 0), "", ImmutableList.of()), "@specifier(g1,", NODE_AND_INTERFACE, NODE_AND_INTERFACE_TAIL); }
@VisibleForTesting static Optional<String> findPrecedingInput( PotentialMatch pm, String query, Anchor.Type headAnchorType, Anchor.Type tailAnchorType) { int anchorIndex = pm.getPath().indexOf(pm.getAnchor()); checkArgument(anchorIndex != -1, "Anchor is not present in the path."); Optional<PathElement> nodeStartElement = findFirstMatchingPathElement(pm, anchorIndex, headAnchorType); if (!nodeStartElement.isPresent()) { return Optional.empty(); } Optional<PathElement> nodeEndElement = findFirstMatchingPathElement(pm, anchorIndex, tailAnchorType); checkArgument( nodeEndElement.isPresent(), "Tail anchor type '%s' not found for input '%s'", tailAnchorType, query); return Optional.of( query.substring( nodeStartElement.get().getStartIndex(), nodeEndElement.get().getStartIndex())); }
ParboiledAutoComplete { @VisibleForTesting static Optional<String> findPrecedingInput( PotentialMatch pm, String query, Anchor.Type headAnchorType, Anchor.Type tailAnchorType) { int anchorIndex = pm.getPath().indexOf(pm.getAnchor()); checkArgument(anchorIndex != -1, "Anchor is not present in the path."); Optional<PathElement> nodeStartElement = findFirstMatchingPathElement(pm, anchorIndex, headAnchorType); if (!nodeStartElement.isPresent()) { return Optional.empty(); } Optional<PathElement> nodeEndElement = findFirstMatchingPathElement(pm, anchorIndex, tailAnchorType); checkArgument( nodeEndElement.isPresent(), "Tail anchor type '%s' not found for input '%s'", tailAnchorType, query); return Optional.of( query.substring( nodeStartElement.get().getStartIndex(), nodeEndElement.get().getStartIndex())); } }
ParboiledAutoComplete { @VisibleForTesting static Optional<String> findPrecedingInput( PotentialMatch pm, String query, Anchor.Type headAnchorType, Anchor.Type tailAnchorType) { int anchorIndex = pm.getPath().indexOf(pm.getAnchor()); checkArgument(anchorIndex != -1, "Anchor is not present in the path."); Optional<PathElement> nodeStartElement = findFirstMatchingPathElement(pm, anchorIndex, headAnchorType); if (!nodeStartElement.isPresent()) { return Optional.empty(); } Optional<PathElement> nodeEndElement = findFirstMatchingPathElement(pm, anchorIndex, tailAnchorType); checkArgument( nodeEndElement.isPresent(), "Tail anchor type '%s' not found for input '%s'", tailAnchorType, query); return Optional.of( query.substring( nodeStartElement.get().getStartIndex(), nodeEndElement.get().getStartIndex())); } 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 static Optional<String> findPrecedingInput( PotentialMatch pm, String query, Anchor.Type headAnchorType, Anchor.Type tailAnchorType) { int anchorIndex = pm.getPath().indexOf(pm.getAnchor()); checkArgument(anchorIndex != -1, "Anchor is not present in the path."); Optional<PathElement> nodeStartElement = findFirstMatchingPathElement(pm, anchorIndex, headAnchorType); if (!nodeStartElement.isPresent()) { return Optional.empty(); } Optional<PathElement> nodeEndElement = findFirstMatchingPathElement(pm, anchorIndex, tailAnchorType); checkArgument( nodeEndElement.isPresent(), "Tail anchor type '%s' not found for input '%s'", tailAnchorType, query); return Optional.of( query.substring( nodeStartElement.get().getStartIndex(), nodeEndElement.get().getStartIndex())); } 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 static Optional<String> findPrecedingInput( PotentialMatch pm, String query, Anchor.Type headAnchorType, Anchor.Type tailAnchorType) { int anchorIndex = pm.getPath().indexOf(pm.getAnchor()); checkArgument(anchorIndex != -1, "Anchor is not present in the path."); Optional<PathElement> nodeStartElement = findFirstMatchingPathElement(pm, anchorIndex, headAnchorType); if (!nodeStartElement.isPresent()) { return Optional.empty(); } Optional<PathElement> nodeEndElement = findFirstMatchingPathElement(pm, anchorIndex, tailAnchorType); checkArgument( nodeEndElement.isPresent(), "Tail anchor type '%s' not found for input '%s'", tailAnchorType, query); return Optional.of( query.substring( nodeStartElement.get().getStartIndex(), nodeEndElement.get().getStartIndex())); } 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);  }