Search in sources :

Example 6 with AutocompleteCandidate

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

the class GroovyNameBuilder method handlePathExpressionContext.

private void handlePathExpressionContext(AssignmentExpressionContext ctx) {
    String typpen = ctx.getChild(2).getChild(0).getText().trim();
    AutocompleteCandidate c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, ctx.getChild(0).getText());
    registry.addCandidate(c);
    if (GroovyCompletionTypes.debug)
        logger.info("define variable of type " + ctx.getChild(0).getText() + " " + typpen);
    if (classUtils.getVariableType(typpen) != null) {
        classUtils.defineVariable(ctx.getChild(0).getText(), classUtils.getVariableType(typpen));
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 7 with AutocompleteCandidate

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

the class AutocompleteRegistryFactory method setup.

public static void setup(ClassUtils cu, AutocompleteRegistry registry) {
    cu.defineClassShortName("Boolean", "java.lang.Boolean");
    cu.defineClassShortName("Byte", "java.lang.Byte");
    cu.defineClassShortName("Character", "java.lang.Character");
    cu.defineClassShortName("Double", "java.lang.Double");
    cu.defineClassShortName("Exception", "java.lang.Exception");
    cu.defineClassShortName("Float", "java.lang.Float");
    cu.defineClassShortName("Integer", "java.lang.Integer");
    cu.defineClassShortName("Long", "java.lang.Long");
    cu.defineClassShortName("Math", "java.lang.Math");
    cu.defineClassShortName("Number", "java.lang.Number");
    cu.defineClassShortName("Object", "java.lang.Object");
    cu.defineClassShortName("Package", "java.lang.Package");
    cu.defineClassShortName("Process", "java.lang.Process");
    cu.defineClassShortName("ProcessBuilder", "java.lang.ProcessBuilder");
    cu.defineClassShortName("Runtime", "java.lang.Runtime");
    cu.defineClassShortName("RuntimePermission", "java.lang.RuntimePermission");
    cu.defineClassShortName("SecurityManager", "java.lang.SecurityManager");
    cu.defineClassShortName("Short", "java.lang.Short");
    cu.defineClassShortName("StackTraceElement", "java.lang.StackTraceElement");
    cu.defineClassShortName("StrictMath", "java.lang.StrictMath");
    cu.defineClassShortName("String", "java.lang.String");
    cu.defineClassShortName("StringBuffer", "java.lang.StringBuffer");
    cu.defineClassShortName("StringBuilder", "java.lang.StringBuilder");
    cu.defineClassShortName("System", "java.lang.System");
    cu.defineClassShortName("Thread", "java.lang.Thread");
    cu.defineClassShortName("ThreadGroup", "java.lang.ThreadGroup");
    cu.defineClassShortName("Throwable", "java.lang.Throwable");
    cu.defineClassShortName("Void", "java.lang.Void");
    cu.defineClassShortName("NamespaceClient", "com.twosigma.beaker.NamespaceClient");
    AutocompleteCandidate c;
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Boolean");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Byte");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Character");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Double");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Exception");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Float");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Integer");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Long");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Number");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Object");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Package");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Process");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "ProcessBuilder");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Runtime");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "RuntimePermission");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "SecurityManager");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Short");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "StackTraceElement");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "StrictMath");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "String");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "StringBuffer");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "StringBuilder");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "System");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Thread");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "ThreadGroup");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Throwable");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "Void");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "NamespaceClient");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NAME, "beaker");
    registry.addCandidate(c);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 8 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(GroovyCompletionTypes.INITIAL, "package");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "import");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "class");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "enum");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "interface");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "def");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "assert");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "if");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "switch");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "while");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "for");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "try");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "extends");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TOPLEVEL, "implements");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.CLASSLEVEL, "extends");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.CLASSLEVEL, "implements");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "any");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "collect");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "each");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "eachWithIndex");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "every");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "create");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "findAll");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.STDFUNCS, "findIndexOf");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "int");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "float");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "char");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "byte");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "void");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "boolean");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "short");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "long");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "double");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Boolean");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Byte");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Character");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Double");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Float");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Integer");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Long");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Math");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Number");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Object");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Package");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Process");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "ProcessBuilder");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Runtime");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "RuntimePermission");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "SecurityManager");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Short");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "StackTraceElement");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "StrictMath");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "String");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "StringBuffer");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "StringBuilder");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "System");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Thread");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "ThreadGroup");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Throwable");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "Void");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.TYPE, "NamespaceClient");
    r.addCandidate(c);
    c = new AutocompleteCandidate(GroovyCompletionTypes.NEW, "new");
    r.addCandidate(c);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 9 with AutocompleteCandidate

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

the class GroovyNodeCompletion method completeClassFromPath.

private void completeClassFromPath(ClassNameExpressionContext ctx) {
    String text = ctx.getText();
    text = text.substring(text.lastIndexOf(".") + 1, text.length());
    AutocompleteCandidate cName = new AutocompleteCandidate(GroovyCompletionTypes.FQ_TYPE, text);
    addQuery(cName, AutocompleteGroovyResult.getStartIndex(ctx));
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 10 with AutocompleteCandidate

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

the class AutocompleteRegistryFactory method createRegistry.

public static AutocompleteRegistry createRegistry(ClasspathScanner cps) {
    AutocompleteRegistry registry = AutocompleteRegistryFactory.create(JavaCompletionTypes.NUM_TYPES);
    for (String pkg : cps.getPackages()) {
        String[] pkgv = pkg.split("\\.");
        AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, pkgv);
        registry.addCandidate(c);
        List<String> cls = cps.getClasses(pkg);
        if (cls != null && !cls.isEmpty()) {
            c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, pkgv);
            AutocompleteCandidate l = c;
            while (l.hasChildren()) {
                l = l.getChildrens().get(0);
            }
            for (String cl : cls) {
                l.addChildren(new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, cl));
            }
            registry.addCandidate(c);
        }
    }
    return registry;
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate) AutocompleteRegistry(com.twosigma.beakerx.autocomplete.AutocompleteRegistry)

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