Search in sources :

Example 11 with AutocompleteCandidate

use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.

the class AutocompleteRegistryFactory method setup.

private static void setup(AutocompleteRegistry r) {
    AutocompleteCandidate c;
    c = new AutocompleteCandidate(JavaCompletionTypes.INITIAL, "package");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "import");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "public");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "class");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "abstract");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "enum");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "final");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "interface");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "private");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "protected");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TOPLEVEL, "static");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.CLASSLEVEL, "extends");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.CLASSLEVEL, "implements");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "if");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "for");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "while");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "do");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "else");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "try");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "catch");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "switch");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "return");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "throw");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "break");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "continue");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "synchronized");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "finally");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.BLOCKLEVEL, "default");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "int");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "float");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "char");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "byte");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "void");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "boolean");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "short");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "long");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "double");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Boolean");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Byte");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Character");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Double");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Float");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Integer");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Long");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Math");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Number");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Object");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Package");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Process");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "ProcessBuilder");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Runtime");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "RuntimePermission");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "SecurityManager");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Short");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "StackTraceElement");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "StrictMath");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "String");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "StringBuffer");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "StringBuilder");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "System");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Thread");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "ThreadGroup");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Throwable");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, "Void");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "public");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "abstract");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "final");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "private");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "protected");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, "static");
    r.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NEW, "new");
    r.addCandidate(c);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 12 with AutocompleteCandidate

use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.

the class JavaNodeCompletion method completeClassFromPath.

private void completeClassFromPath(CompilationUnitContext ctx, String text) {
    text = text.substring(text.lastIndexOf(".") + 1, text.length());
    if (!text.isEmpty()) {
        AutocompleteCandidate cName = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, text);
        addQuery(cName, AutocompleteJavaResult.getStartIndex(ctx));
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 13 with AutocompleteCandidate

use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.

the class JavaNodeCompletion method exitMemberDeclaration.

@Override
public void exitMemberDeclaration(MemberDeclarationContext ctx) {
    if (ctx.getStart().getStartIndex() < cursor && ctx.getStop().getStopIndex() + 1 >= cursor) {
        String txt = ctx.getText();
        if (txt.contains(" "))
            return;
        AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.MEMBERDELC, txt);
        addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 14 with AutocompleteCandidate

use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.

the class JavaNodeCompletion method exitType.

@Override
public void exitType(TypeContext ctx) {
    if (ctx.getStart().getStartIndex() < cursor && ctx.getStop().getStopIndex() + 1 >= cursor) {
        // System.out.println("TYPE: "+ctx.getStart().getStartIndex()+" "+ctx.getStart().getStopIndex()+" "+ctx.getStart().getText());
        String txt = ctx.getText();
        if (txt.contains(" "))
            return;
        if (txt.contains(".")) {
            String[] txtv = txt.split("\\.");
            AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
            addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
        } else {
            AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.TYPE, txt);
            addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
            c = new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, txt);
            addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
        }
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 15 with AutocompleteCandidate

use of com.twosigma.beakerx.autocomplete.AutocompleteCandidate in project beakerx by twosigma.

the class JavaNodeCompletion method exitCreatedName.

@Override
public void exitCreatedName(CreatedNameContext ctx) {
    if (ctx.getStart().getStartIndex() < cursor && ctx.getStop().getStopIndex() + 1 >= cursor) {
        // System.out.println("CN: "+ctx.getStart().getStartIndex()+" "+ctx.getStart().getStopIndex()+" "+ctx.getStart().getText());
        String txt = ctx.getText();
        if (txt.contains(" "))
            return;
        if (text.charAt(cursor - 1) == '.') {
        // TODO (do I need it?)
        } else {
            if (txt.contains(".")) {
                String[] txtv = txt.split("\\.");
                AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
                addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
            } else {
                AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, txt);
                addQuery(c, AutocompleteJavaResult.getStartIndex(ctx));
            }
        }
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Aggregations

AutocompleteCandidate (com.twosigma.beakerx.autocomplete.AutocompleteCandidate)39 AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)4 ArrayList (java.util.ArrayList)4 AutocompleteRegistryFactory.createImportAutocompleteCandidate (com.twosigma.beakerx.groovy.autocomplete.AutocompleteRegistryFactory.createImportAutocompleteCandidate)3 AutocompleteRegistryFactory.createImportAutocompleteCandidate (com.twosigma.beakerx.javash.autocomplete.AutocompleteRegistryFactory.createImportAutocompleteCandidate)3 ClassOrInterfaceTypeContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.ClassOrInterfaceTypeContext)3 PrimitiveTypeContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.PrimitiveTypeContext)3 TypeContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.TypeContext)3 ParseTree (org.antlr.v4.runtime.tree.ParseTree)3 AutocompleteRegistry (com.twosigma.beakerx.autocomplete.AutocompleteRegistry)2 VariableDeclaratorContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.VariableDeclaratorContext)2 VariableDeclaratorIdContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.VariableDeclaratorIdContext)2 VariableDeclaratorsContext (com.twosigma.beakerx.javash.autocomplete.JavaParser.VariableDeclaratorsContext)2 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 Lexer (org.antlr.v4.runtime.Lexer)2 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)2 ParseTreeWalker (org.antlr.v4.runtime.tree.ParseTreeWalker)2 ClassUtils (com.twosigma.beakerx.autocomplete.ClassUtils)1 AssignmentExpressionContext (com.twosigma.beakerx.groovy.autocomplete.GroovyParser.AssignmentExpressionContext)1