void (@NotNull String line) { if (indicator != null) { indicator.checkCanceled(); } final String trimmed = line.trim(); if (trimmed.startsWith("{")) { final JsonObject controlMessage; try { controlMessage = ourGson.fromJson(trimmed, JsonObject.class); } catch (JsonSyntaxException e) { LOG.warn("Malformed control message: " + line); return; } final String msgType = controlMessage.get("type").getAsString(); if (msgType.equals("progress") && indicator != null) { final JsonElement text = controlMessage.get("text"); if (text != null) { final @NlsSafe String progressText = text.getAsString(); if (controlMessage.get("minor").getAsBoolean()) { indicator.setText2(progressText); } else { indicator.setText(progressText); } } final JsonElement fraction = controlMessage.get("fraction"); if (fraction != null) { indicator.setIndeterminate(false); indicator.setFraction(fraction.getAsDouble()); } } else if (msgType.equals("log")) { final String level = controlMessage.get("level").getAsString(); final String message = controlMessage.get("message").getAsString(); switch (level) { case "info" -> Run.LOG.info(message); case "debug" -> Run.LOG.debug(message); case "trace" -> Run.LOG.trace(message); } } else if (msgType.equals("generation_result")) { results.add(ourGson.fromJson(trimmed, GenerationResult.class)); } } } @Override public void onStderrLine(@NotNull String line) { Run.LOG.info(StringUtil.trimTrailing(line)); } }