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

Method requestCommands

src/main/java/fielded/Commands.java:112–150  ·  view source on GitHub ↗
(Optional<Box> box, String property, String text, Consumer<String> ret, int line, int ch)

Source from the content-addressed store, hash-verified

110 public RemoteEditor.ExtendedCommand callTable_alternative = null;
111
112 public void requestCommands(Optional<Box> box, String property, String text, Consumer<String> ret, int line, int ch) {
113
114 // now we need to ask everybody if they have any commands to offer based on the above.
115
116 //todo: handle no box case
117 List<Triple<String, String, Runnable>> commands = getCommandsAndDocs(box.get());
118
119 CompletionStats.stats.autosuggestCommands(commands);
120
121 Log.log("remote.trace", () -> " commands are :" + commands);
122
123 JSONStringer stringer = new JSONStringer();
124 stringer.array();
125 callTable.clear();
126 callTableName.clear();
127
128 for (Triple<String, String, Runnable> r : commands) {
129 String u = UUID.randomUUID()
130 .toString();
131 callTable.put(u, r.third);
132 callTableName.put(u, r.first);
133 stringer.object();
134 stringer.key("name")
135 .value(r.first);
136 stringer.key("info")
137 .value(format(r.second));
138 stringer.key("call")
139 .value(u);
140 stringer.endObject();
141 }
142
143
144 Log.log("remote.trace", () -> " call table looks like :" + callTable);
145
146 stringer.endArray();
147
148 ret.accept(stringer.toString());
149
150 }
151
152 static public void exportAsCommand(Box inside, Runnable r, String name, String doc) {
153 inside.properties.getOrConstruct(command)

Callers 3

RemoteEditorMethod · 0.80
inject2Method · 0.80
joinCommandsMethod · 0.80

Calls 10

getCommandsAndDocsMethod · 0.95
logMethod · 0.95
autosuggestCommandsMethod · 0.80
getMethod · 0.65
acceptMethod · 0.65
clearMethod · 0.45
toStringMethod · 0.45
putMethod · 0.45
keyMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected