| 304 | } |
| 305 | |
| 306 | std::vector<String> ConsoleHandler::GetAutocompletionSuggestions(const String& word, ScriptFrame& frame) |
| 307 | { |
| 308 | std::vector<String> matches; |
| 309 | |
| 310 | for (const String& keyword : ConfigWriter::GetKeywords()) { |
| 311 | AddSuggestion(matches, word, keyword); |
| 312 | } |
| 313 | |
| 314 | { |
| 315 | ObjectLock olock(frame.Locals); |
| 316 | for (const Dictionary::Pair& kv : frame.Locals) { |
| 317 | AddSuggestion(matches, word, kv.first); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | { |
| 322 | ObjectLock olock(ScriptGlobal::GetGlobals()); |
| 323 | for (const Namespace::Pair& kv : ScriptGlobal::GetGlobals()) { |
| 324 | AddSuggestion(matches, word, kv.first); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | Namespace::Ptr systemNS = ScriptGlobal::Get("System"); |
| 329 | |
| 330 | AddSuggestions(matches, word, "", false, systemNS); |
| 331 | AddSuggestions(matches, word, "", true, systemNS->Get("Configuration")); |
| 332 | AddSuggestions(matches, word, "", false, ScriptGlobal::Get("Types")); |
| 333 | AddSuggestions(matches, word, "", false, ScriptGlobal::Get("Icinga")); |
| 334 | |
| 335 | String::SizeType cperiod = word.RFind("."); |
| 336 | |
| 337 | if (cperiod != String::NPos) { |
| 338 | String pword = word.SubStr(0, cperiod); |
| 339 | |
| 340 | Value value; |
| 341 | |
| 342 | try { |
| 343 | std::unique_ptr<Expression> expr = ConfigCompiler::CompileText("temp", pword); |
| 344 | |
| 345 | if (expr) |
| 346 | value = expr->Evaluate(frame); |
| 347 | |
| 348 | AddSuggestions(matches, word, pword, true, value); |
| 349 | } catch (...) { /* Ignore the exception */ } |
| 350 | } |
| 351 | |
| 352 | return matches; |
| 353 | } |
nothing calls this directly
no test coverage detected