Search in sources :

Example 21 with AutocompleteCandidate

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

the class AutocompleteRegistryFactory method addDefaultImports.

public static void addDefaultImports(ClassUtils cu, AutocompleteRegistry registry, List<String> imports, ClasspathScanner cps) {
    for (String imp : imports) {
        // this imports using '*'
        if (imp.endsWith(".*")) {
            String st = imp.substring(0, imp.length() - 2);
            String[] txtv = st.split("\\.");
            AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
            registry.addCandidate(c);
            List<String> cls = cps.getClasses(st);
            if (cls != null) {
                c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
                AutocompleteCandidate l = c.findLeaf();
                for (String s : cls) {
                    l.addChildren(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
                    registry.addCandidate(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
                    cu.defineClassShortName(s, st + "." + s);
                }
                registry.addCandidate(c);
            }
        } else {
            String[] txtv = imp.split("\\.");
            AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv, txtv.length - 1);
            registry.addCandidate(c);
            c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
            registry.addCandidate(c);
            c = new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, txtv[txtv.length - 1]);
            registry.addCandidate(c);
            cu.defineClassShortName(txtv[txtv.length - 1], imp);
        }
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 22 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("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");
    AutocompleteCandidate c;
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Boolean");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Byte");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Character");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Double");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Exception");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Float");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Integer");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Long");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Number");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Object");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Package");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Process");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "ProcessBuilder");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Runtime");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "RuntimePermission");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "SecurityManager");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Short");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "StackTraceElement");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "StrictMath");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "String");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "StringBuffer");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "StringBuilder");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "System");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Thread");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "ThreadGroup");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Throwable");
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.NAME, "Void");
    registry.addCandidate(c);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 23 with AutocompleteCandidate

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

the class AutocompleteRegistryFactory method createImportAutocompleteCandidate.

public static void createImportAutocompleteCandidate(ClassUtils cu, AutocompleteRegistry registry, String imp) {
    String[] txtv = imp.split("\\.");
    AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv, txtv.length - 1);
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
    registry.addCandidate(c);
    c = new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, txtv[txtv.length - 1]);
    registry.addCandidate(c);
    cu.defineClassShortName(txtv[txtv.length - 1], imp);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate)

Example 24 with AutocompleteCandidate

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

the class JavaImportDeclarationCompletion method importPackageNameAfterDot.

private void importPackageNameAfterDot(ImportDeclarationContext ctx) {
    String st = ctx.getText();
    st = removeImportWord(st);
    String[] txtv = (st + "X").split("\\.");
    txtv[txtv.length - 1] = EMPTY_NODE;
    AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
    addQuery(c, AutocompleteJavaResult.getStartIndex(ctx) + 1);
    c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
    addQuery(c, AutocompleteJavaResult.getStartIndex(ctx) + 1);
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate) AutocompleteRegistryFactory.createImportAutocompleteCandidate(com.twosigma.beakerx.javash.autocomplete.AutocompleteRegistryFactory.createImportAutocompleteCandidate)

Example 25 with AutocompleteCandidate

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

the class JavaImportDeclarationCompletion method importWithWildcard.

private void importWithWildcard(String st) {
    String[] txtv = st.split("\\.");
    AutocompleteCandidate c = new AutocompleteCandidate(JavaCompletionTypes.PACKAGE_NAME, txtv);
    registry.addCandidate(c);
    st = st.substring(0, st.length() - 2);
    List<String> cls = cps.getClasses(st);
    if (cls != null) {
        c = new AutocompleteCandidate(JavaCompletionTypes.FQ_TYPE, txtv);
        AutocompleteCandidate l = c.findLeaf();
        for (String s : cls) {
            l.addChildren(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
            registry.addCandidate(new AutocompleteCandidate(JavaCompletionTypes.CUSTOM_TYPE, s));
            classUtils.defineClassShortName(s, st + "." + s);
        }
        registry.addCandidate(c);
    }
}
Also used : AutocompleteCandidate(com.twosigma.beakerx.autocomplete.AutocompleteCandidate) AutocompleteRegistryFactory.createImportAutocompleteCandidate(com.twosigma.beakerx.javash.autocomplete.AutocompleteRegistryFactory.createImportAutocompleteCandidate)

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