| 254 | } |
| 255 | |
| 256 | static 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 | |
| 306 | std::vector<String> ConsoleHandler::GetAutocompletionSuggestions(const String& word, ScriptFrame& frame) |
| 307 | { |
no test coverage detected