Search in sources :

Example 1 with TabCompletion

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);
    }
}
Also used : App(org.neo4j.shell.App) TabCompletion(org.neo4j.shell.TabCompletion) AppCommandParser(org.neo4j.shell.AppCommandParser) RemoteException(java.rmi.RemoteException) ShellException(org.neo4j.shell.ShellException)

Example 2 with TabCompletion

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;
}
Also used : TabCompletion(org.neo4j.shell.TabCompletion) RemoteException(java.rmi.RemoteException) ShellException(org.neo4j.shell.ShellException)

Aggregations

RemoteException (java.rmi.RemoteException)2 ShellException (org.neo4j.shell.ShellException)2 TabCompletion (org.neo4j.shell.TabCompletion)2 App (org.neo4j.shell.App)1 AppCommandParser (org.neo4j.shell.AppCommandParser)1