Fixed help lookup not finding classes, issue 11867

This commit is contained in:
Paulb23 2017-11-10 23:20:04 +00:00
parent b3c08a8326
commit b835aec87b

View file

@ -2771,31 +2771,31 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
//global
for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) {
if (E->key() == p_symbol) {
Variant value = GDScriptLanguage::get_singleton()->get_global_array()[E->get()];
if (value.get_type() == Variant::OBJECT) {
Object *obj = value;
if (obj) {
if (Object::cast_to<GDNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = obj->get_class();
}
return OK;
Map<StringName, int> classes = GDScriptLanguage::get_singleton()->get_global_map();
if (classes.has(p_symbol)) {
Variant value = GDScriptLanguage::get_singleton()->get_global_array()[classes[p_symbol]];
if (value.get_type() == Variant::OBJECT) {
Object *obj = value;
if (obj) {
if (Object::cast_to<GDNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = obj->get_class();
}
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = "@Global Scope";
r_result.class_member = p_symbol;
// proxy class remove the underscore.
if (r_result.class_name.begins_with("_")) {
r_result.class_name = r_result.class_name.right(1);
}
return OK;
}
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = "@Global Scope";
r_result.class_member = p_symbol;
return OK;
}
}
}