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

Function AddSuggestions

lib/remote/consolehandler.cpp:256–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256static void AddSuggestions(std::vector<String>& matches, const String& word, const String& pword, bool withFields, const Value& value)
257{
258 String prefix;
259
260 if (!pword.IsEmpty())
261 prefix = pword + ".";
262
263 if (value.IsObjectType<Dictionary>()) {
264 Dictionary::Ptr dict = value;
265
266 ObjectLock olock(dict);
267 for (const Dictionary::Pair& kv : dict) {
268 AddSuggestion(matches, word, prefix + kv.first);
269 }
270 }
271
272 if (value.IsObjectType<Namespace>()) {
273 Namespace::Ptr ns = value;
274
275 ObjectLock olock(ns);
276 for (const Namespace::Pair& kv : ns) {
277 AddSuggestion(matches, word, prefix + kv.first);
278 }
279 }
280
281 if (withFields) {
282 Type::Ptr type = value.GetReflectionType();
283
284 for (int i = 0; i < type->GetFieldCount(); i++) {
285 Field field = type->GetFieldInfo(i);
286
287 AddSuggestion(matches, word, prefix + field.Name);
288 }
289
290 while (type) {
291 Object::Ptr prototype = type->GetPrototype();
292 Dictionary::Ptr dict = dynamic_pointer_cast<Dictionary>(prototype);
293
294 if (dict) {
295 ObjectLock olock(dict);
296 for (const Dictionary::Pair& kv : dict) {
297 AddSuggestion(matches, word, prefix + kv.first);
298 }
299 }
300
301 type = type->GetBaseType();
302 }
303 }
304}
305
306std::vector<String> ConsoleHandler::GetAutocompletionSuggestions(const String& word, ScriptFrame& frame)
307{

Callers 1

Calls 7

AddSuggestionFunction · 0.85
IsEmptyMethod · 0.45
GetReflectionTypeMethod · 0.45
GetFieldCountMethod · 0.45
GetFieldInfoMethod · 0.45
GetPrototypeMethod · 0.45
GetBaseTypeMethod · 0.45

Tested by

no test coverage detected