Search in sources :

Example 1 with REPLContext

use of dyvilx.tools.repl.context.REPLContext in project Dyvil by Dyvil.

the class CompleteCommand method printREPLMembers.

private void printREPLMembers(DyvilREPL repl, String start) {
    final REPLContext replContext = repl.getContext();
    final Set<IField> variables = new TreeSet<>(MemberSorter.MEMBER_COMPARATOR);
    final Set<IMethod> methods = new TreeSet<>(MemberSorter.METHOD_COMPARATOR);
    for (IField variable : replContext.getFields().values()) {
        checkMember(variables, variable, start);
    }
    for (IMethod method : replContext.getMethods()) {
        checkMember(methods, method, start);
    }
    final PrintStream output = repl.getOutput();
    boolean hasOutput = false;
    if (!variables.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.variables"));
        printMembers(output, variables, null);
    }
    if (!methods.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.methods"));
        printMethods(output, methods, null);
    }
    if (!hasOutput) {
        output.println(I18n.get("command.complete.none"));
    }
}
Also used : PrintStream(java.io.PrintStream) TreeSet(dyvil.collection.mutable.TreeSet) REPLContext(dyvilx.tools.repl.context.REPLContext) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IField(dyvilx.tools.compiler.ast.field.IField)

Aggregations

TreeSet (dyvil.collection.mutable.TreeSet)1 IField (dyvilx.tools.compiler.ast.field.IField)1 IMethod (dyvilx.tools.compiler.ast.method.IMethod)1 REPLContext (dyvilx.tools.repl.context.REPLContext)1 PrintStream (java.io.PrintStream)1