* @brief Dispatches a dry-run call to the matching scripting endpoint and attaches references. */
| 1189 | * @brief Dispatches a dry-run call to the matching scripting endpoint and attaches references. |
| 1190 | */ |
| 1191 | static QJsonObject executeScriptDryRun(const QJsonObject& args) |
| 1192 | { |
| 1193 | const auto kind = args.value(QStringLiteral("kind")).toString(); |
| 1194 | const auto code = args.value(QStringLiteral("code")).toString(); |
| 1195 | const int language = |
| 1196 | args.contains(QStringLiteral("language")) ? args.value(QStringLiteral("language")).toInt() : 1; |
| 1197 | |
| 1198 | QJsonObject dryArgs; |
| 1199 | if (!code.isEmpty()) |
| 1200 | dryArgs[QStringLiteral("code")] = code; |
| 1201 | |
| 1202 | const QString command = dryRunCommandForKind(kind, args, dryArgs, language); |
| 1203 | if (command.isEmpty()) { |
| 1204 | QJsonObject out; |
| 1205 | out[QStringLiteral("ok")] = false; |
| 1206 | out[QStringLiteral("error")] = QStringLiteral("unknown_script_kind"); |
| 1207 | return out; |
| 1208 | } |
| 1209 | |
| 1210 | auto reply = runCommand(command, dryArgs); |
| 1211 | reply[QStringLiteral("command")] = command; |
| 1212 | reply[QStringLiteral("arguments")] = dryArgs; |
| 1213 | const auto docsKind = scriptingDocKindForScriptKind(kind, language); |
| 1214 | if (!docsKind.isEmpty()) |
| 1215 | reply[QStringLiteral("reference")] = |
| 1216 | QStringLiteral("meta.fetchScriptingDocs{kind:'%1'}").arg(docsKind); |
| 1217 | |
| 1218 | return attachRepairHint(reply, command); |
| 1219 | } |
| 1220 | |
| 1221 | /** |
| 1222 | * @brief Toggles the target dataset to virtual when the apply request asks for it. |
no test coverage detected