|
@@ -44,6 +44,7 @@
|
|
|
#include "core/core_constants.h"
|
|
|
#include "core/io/file_access.h"
|
|
|
#include "core/math/expression.h"
|
|
|
+#include "core/variant/container_type_validate.h"
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
#include "core/config/project_settings.h"
|
|
@@ -2099,13 +2100,22 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- {
|
|
|
- bool valid;
|
|
|
- Variant value = base.value.get(index.value, &valid);
|
|
|
- if (valid) {
|
|
|
- r_type = _type_from_variant(value, p_context);
|
|
|
- found = true;
|
|
|
- break;
|
|
|
+ if (base.type.is_constant && index.type.is_constant) {
|
|
|
+ if (base.value.get_type() == Variant::DICTIONARY) {
|
|
|
+ Dictionary base_dict = base.value.operator Dictionary();
|
|
|
+ if (base_dict.get_key_validator().test_validate(index.value) && base_dict.has(index.value)) {
|
|
|
+ r_type = _type_from_variant(base_dict[index.value], p_context);
|
|
|
+ found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bool valid;
|
|
|
+ Variant value = base.value.get(index.value, &valid);
|
|
|
+ if (valid) {
|
|
|
+ r_type = _type_from_variant(value, p_context);
|
|
|
+ found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|