Search in sources :

Example 1 with VarSnippet

use of jdk.jshell.VarSnippet in project jdk9-jigsaw by AdoptOpenJDK.

the class ShellService method eval.

public synchronized void eval(String command) {
    List<SnippetEvent> events = shell.eval(command);
    for (SnippetEvent event : events) {
        if (event.snippet() instanceof VarSnippet) {
            String type = ((VarSnippet) event.snippet()).typeName();
            String name = ((VarSnippet) event.snippet()).name();
            String value = event.value();
            VarData varData = new VarData(type, name, value);
            eventBus.publish(Topics.VAR_CREATED_TOPIC, varData);
            variables.add(varData);
        }
    }
}
Also used : VarSnippet(jdk.jshell.VarSnippet) SnippetEvent(jdk.jshell.SnippetEvent) VarData(com.guigarage.shell.event.VarData)

Example 2 with VarSnippet

use of jdk.jshell.VarSnippet in project jdk9-jigsaw by AdoptOpenJDK.

the class JShellSample5 method print.

public static void print(List<SnippetEvent> events) {
    for (SnippetEvent event : events) {
        if (event.snippet() instanceof VarSnippet) {
            String name = ((VarSnippet) event.snippet()).name();
            String id = ((VarSnippet) event.snippet()).id();
            System.out.println("Variable " + name + " defined with ID " + id);
        }
    }
}
Also used : VarSnippet(jdk.jshell.VarSnippet) SnippetEvent(jdk.jshell.SnippetEvent)

Aggregations

SnippetEvent (jdk.jshell.SnippetEvent)2 VarSnippet (jdk.jshell.VarSnippet)2 VarData (com.guigarage.shell.event.VarData)1