Package org.crsh.cli.impl.completion

Examples of org.crsh.cli.impl.completion.CompletionMatch


  public void testComplete() {
    ClientProcessor t = new ClientProcessor(clientOIS, clientOOS, new BaseShell() {
      @Override
      public CompletionMatch complete(String prefix) {
        return new CompletionMatch(Delimiter.DOUBLE_QUOTE, Completion.create(prefix, "ix", true));
      }
    });
    t.start();

    //
    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);
    CompletionMatch completion = server.complete("pref");
    assertEquals(Delimiter.DOUBLE_QUOTE, completion.getDelimiter());
    Completion value = completion.getValue();
    assertEquals("pref", value.getPrefix());
    assertEquals(1, value.getSize());
    assertEquals(Collections.singleton("ix"), value.getValues());
    assertEquals(Boolean.TRUE, value.get("ix"));
View Full Code Here


          String prompt = shell.getPrompt();
          out.writeObject(new ServerMessage.Prompt(prompt));
          out.flush();
        } else if (msg instanceof ClientMessage.GetCompletion) {
          String prefix = ((ClientMessage.GetCompletion)msg).prefix;
          CompletionMatch completion = shell.complete(prefix);
          out.writeObject(new ServerMessage.Completion(completion));
          out.flush();
        } else if (msg instanceof ClientMessage.SetSize) {
          ClientMessage.SetSize setSize = (ClientMessage.SetSize)msg;
          width = setSize.width;
View Full Code Here

  /**
   * Returns an empty unmodifiable map.
   */
  public CompletionMatch complete(String prefix) {
    return new CompletionMatch(Delimiter.EMPTY, Completion.create());
  }
View Full Code Here

    try {
      return matcher.match(completer, line);
    }
    catch (CompletionException e) {
      // command.log.log(Level.SEVERE, "Error during completion of line " + line, e);
      return new CompletionMatch(Delimiter.EMPTY, Completion.create());
    }
  }
View Full Code Here

      matcher.match("n b");
      fail();
    }
    catch (CompletionException ignore) {
    }
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("ilto", true)), matcher.match(some, "n b"));
  }
View Full Code Here

    //
    CommandDescriptor<Instance<A>> desc = CommandFactory.DEFAULT.create(A.class);
    CompletionMatcher<Instance<A>> matcher = desc.completer();

    //
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("foo", true)), matcher.match("m "));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("oo", true)), matcher.match("m f"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("o", true)), matcher.match("m fo"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create()), matcher.match("m a "));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("f")), matcher.match("m a f"));
  }
View Full Code Here

    //
    CommandDescriptor<Instance<A>> desc = CommandFactory.DEFAULT.create(A.class);
    CompletionMatcher<Instance<A>> matcher = desc.completer();

    //
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("foo", true)), matcher.match(""));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("oo", true)), matcher.match("f"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("o", true)), matcher.match("fo"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create()), matcher.match("a "));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("f")), matcher.match("a f"));
  }
View Full Code Here

    //
    CommandDescriptor<Instance<A>> desc = CommandFactory.DEFAULT.create(A.class);
    CompletionMatcher<Instance<A>> matcher = desc.completer();

    //
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("foo", true)), matcher.match("foo "));
    assertEquals(new CompletionMatch(Delimiter.DOUBLE_QUOTE, Completion.create("foo", true)), matcher.match("foo \""));
  }
View Full Code Here

    //
    CommandDescriptor<Instance<A>> desc = CommandFactory.DEFAULT.create(A.class);
    CompletionMatcher<Instance<A>> matcher = desc.completer();

    //
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("foo", true)), matcher.match("m "));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("oo", true)), matcher.match("m f"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("o", true)), matcher.match("m fo"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("foo", true)), matcher.match("m a "));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("oo", true)), matcher.match("m a f"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("o", true)), matcher.match("m a fo"));
  }
View Full Code Here

    //
    CommandDescriptor<Instance<A>> desc = CommandFactory.DEFAULT.create(A.class);
    CompletionMatcher<Instance<A>> matcher = desc.completer();

    //
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("-", "a", true)), matcher.match("-"));
    assertEquals(new CompletionMatch(Delimiter.EMPTY, Completion.create("", true)), matcher.match("-a"));

    CompletionMatch a = new CompletionMatch(Delimiter.EMPTY, Completion.builder("--").add("add", true).add("addition", true).build());
    CompletionMatch b = new CompletionMatch(Delimiter.EMPTY, Completion.builder("--ad").add("d", true).add("dition", true).build());
    CompletionMatch c = new CompletionMatch(Delimiter.EMPTY, Completion.create("--addi", "tion", true));

    //
    assertEquals(a, matcher.match("--"));
    assertEquals(b, matcher.match("--ad"));
    assertEquals(c, matcher.match("--addi"));
View Full Code Here

TOP

Related Classes of org.crsh.cli.impl.completion.CompletionMatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.