use of org.neo4j.shell.TabCompletion in project neo4j by neo4j.
the class AbstractAppServer method tabComplete.
@Override
public TabCompletion tabComplete(Serializable clientID, String partOfLine) throws ShellException, RemoteException {
// TODO We can't assume it's an AppShellServer, can we?
try {
AppCommandParser parser = new AppCommandParser(this, partOfLine);
App app = parser.app();
List<String> appCandidates = app.completionCandidates(partOfLine, getClientSession(clientID));
appCandidates = quote(appCandidates);
if (appCandidates.size() == 1) {
appCandidates.set(0, appCandidates.get(0) + " ");
}
int cursor = partOfLine.length() - TextUtil.lastWordOrQuoteOf(partOfLine, true).length();
return new TabCompletion(appCandidates, cursor);
} catch (Exception e) {
throw wrapException(e);
}
}
use of org.neo4j.shell.TabCompletion in project neo4j by neo4j.
the class ShellTabCompleter method complete.
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(client.getId(), buffer.trim());
cursor = completion.getCursor();
//noinspection unchecked
candidates.addAll(completion.getCandidates());
} else {
// Complete the app name
return getAppNameCompleter().complete(buffer, cursor, candidates);
}
} catch (RemoteException e) {
// TODO Throw something?
e.printStackTrace();
} catch (ShellException e) {
// TODO Throw something?
e.printStackTrace();
}
return cursor;
}
Aggregations