private Completor getAppNameCompletor() throws RemoteException { if (timeWhenCached != client.timeForMostRecentConnection()) { timeWhenCached = client.timeForMostRecentConnection(); appNameCompletor = new SimpleCompletor(client.getServer().getAllAvailableCommands()); } return this.appNameCompletor; }
public int complete(String buffer, int cursor, List candidates) { if (buffer == null || buffer.length() == 0) { return cursor; } try { if (buffer.contains(" ")) { TabCompletion completion = client.getServer().tabComplete(buffer.trim(), client.session()); cursor = completion.getCursor(); candidates.addAll(completion.getCandidates()); } else { // Complete the app name return getAppNameCompletor().complete(buffer, cursor, candidates); } } catch (RemoteException e) { // TODO Throw something? e.printStackTrace(); } catch (ShellException e) { // TODO Throw something? e.printStackTrace(); } return cursor; }