| 1229 | } |
| 1230 | |
| 1231 | std::pair<bool, std::vector<std::string>> DebuggerPlugin::replaceKeyInString( |
| 1232 | std::string val, int randomPort, |
| 1233 | const std::unordered_map<std::string, std::string>& solvedInputs ) { |
| 1234 | auto pbm = getPluginContext()->getProjectBuildManager(); |
| 1235 | auto runConfig = pbm ? pbm->getCurrentRunConfig() : std::optional<ProjectBuildStep>{}; |
| 1236 | auto buildConfig = pbm ? pbm->getCurrentBuild() : nullptr; |
| 1237 | |
| 1238 | const auto replaceVal = [this, &runConfig, &buildConfig, &solvedInputs, |
| 1239 | randomPort]( std::string& val ) -> bool { |
| 1240 | if ( !replaceInVal( val, runConfig, buildConfig, randomPort ) ) |
| 1241 | return false; |
| 1242 | |
| 1243 | LuaPattern::Range matches[2]; |
| 1244 | if ( inputPtrn.matches( val, matches ) ) { |
| 1245 | std::string id( val.substr( matches[1].start, matches[1].end - matches[1].start ) ); |
| 1246 | auto solvedIdIt = solvedInputs.find( id ); |
| 1247 | if ( solvedIdIt != solvedInputs.end() ) |
| 1248 | String::replaceAll( val, String::format( "${input:%s}", id ), solvedIdIt->second ); |
| 1249 | } |
| 1250 | |
| 1251 | LuaPattern::Range matches2[2]; |
| 1252 | if ( commandPtrn.matches( val, matches2 ) ) { |
| 1253 | std::string id( val.substr( matches2[1].start, matches2[1].end - matches2[1].start ) ); |
| 1254 | String::toLowerInPlace( id ); |
| 1255 | auto solvedIdIt = solvedInputs.find( id ); |
| 1256 | if ( solvedIdIt != solvedInputs.end() ) |
| 1257 | val = solvedIdIt->second; |
| 1258 | } |
| 1259 | |
| 1260 | return true; |
| 1261 | }; |
| 1262 | |
| 1263 | if ( runConfig && val == KEY_ARGS ) { |
| 1264 | std::vector<std::string> argsArr; |
| 1265 | auto args = Process::parseArgs( runConfig->args ); |
| 1266 | for ( auto arg : args ) { |
| 1267 | replaceVal( arg ); |
| 1268 | argsArr.push_back( arg ); |
| 1269 | } |
| 1270 | return { true, argsArr }; |
| 1271 | } |
| 1272 | |
| 1273 | if ( !replaceVal( val ) ) |
| 1274 | return { false, {} }; |
| 1275 | |
| 1276 | return { true, { val } }; |
| 1277 | } |
| 1278 | |
| 1279 | void DebuggerPlugin::replaceKeysInJson( |
| 1280 | nlohmann::json& json, int randomPort, |
nothing calls this directly
no test coverage detected