MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Exec

Method Exec

src/main/java/fieldbox/boxes/plugins/Exec.java:23–38  ·  view source on GitHub ↗
(Box root)

Source from the content-addressed store, hash-verified

21 static public final Dict.Prop<Box.BiFunctionOfBoxAnd<String, Triple<Object, List<String>, List<Pair<Integer, String>>>>> exec = new Dict.Prop<>("exec").type().toCanon().doc("`_.exec('foo()')` executes the expression `foo()` as if you'd typed it into the text editor with `_` selected and pressed command-return. This returns a `Triple` containing the the `Object` returned, a `List<String>` of everything 'printed' by this code and the `List<Pair<Integer, String>>` of all the errors and error-line numbers if any.");
22
23 public Exec(Box root)
24 {
25 this.properties.put(exec, (box, string) -> {
26 Execution ex = RemoteEditor.getExecution(box, Execution.code);
27 Execution.ExecutionSupport support = ex.support(box, Execution.code);
28
29 List<String> out = new ArrayList<>();
30 List<Pair<Integer, String>> err = new ArrayList<>();
31 Consumer<String> success = out::add;
32 Consumer<Pair<Integer, String>> errors= err::add;
33
34 Object o = support.executeTextFragment(string, "raw", success, errors);
35
36 return new Triple<>(o, out, err);
37 });
38 }
39}

Callers

nothing calls this directly

Calls 4

getExecutionMethod · 0.95
supportMethod · 0.95
executeTextFragmentMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected