MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GetAutocompletionSuggestions

Method GetAutocompletionSuggestions

lib/remote/consolehandler.cpp:306–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306std::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}

Callers

nothing calls this directly

Calls 6

AddSuggestionFunction · 0.85
AddSuggestionsFunction · 0.85
RFindMethod · 0.80
SubStrMethod · 0.80
EvaluateMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected