Repository: godotengine/godot
File: modules/gdscript/gdscript_editor.cpp (C++)

Code before:
	if (!ClassDB::get_integer_constant_enum(p_class, p_enum_constant)) {
		return ScriptLanguage::LOCATION_OTHER;
	}

	int depth = 0;
	StringName class_test = p_class;
	while (class_test && !ClassDB::get_integer_constant_enum(class_test, p_enum_constant, true)) {
		class_test = ClassDB::get_parent_class(class_test);
		depth++;
	}

	return depth | ScriptLanguage::LOCATION_PARENT_MASK;
}

// END LOCATION METHODS

static String _trim_parent_class(const String &p_class, const String &p_base_class) {
	if (p_base_class.is_empty()) {
		return p_class;
	}
	Vector<String> names = p_class.split(".", false, 1);
	if (names.size() == 2) {
		String first = names[0];
		String rest = names[1];
		if (ClassDB::class_exists(p_base_class) && ClassDB::class_exists(first) && ClassDB::is_parent_class(p_base_class, first)) {
			return rest;
		}
	}
	return p_class;
}

static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg, const String &p_base_class = "") {
	String class_name = p_info.class_name;
	bool is_enum = p_info.type == Variant::INT && p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM;
	// PROPERTY_USAGE_CLASS_IS_BITFIELD: BitField[T] isn't supported (yet?), use plain int.

	if ((p_info.type == Variant::OBJECT || is_enum) && !class_name.is_empty()) {
		if (is_enum && CoreConstants::is_global_enum(p_info.class_name)) {
			return class_name;
		}
		return _trim_parent_class(class_name, p_base_class);
	} else if (p_info.type == Variant::ARRAY && p_info.hint == PROPERTY_HINT_ARRAY_TYPE && !p_info.hint_string.is_empty()) {
		return "Array[" + _trim_parent_class(p_info.hint_string, p_base_class) + "]";
	} else if (p_info.type == Variant::NIL) {
		if (p_is_arg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
			return "Variant";
		} else {
			return "void";
		}
	}


Review comment (suggestion):
```suggestion
		if (ClassDB::class_exists(p_base_class) && ClassDB::class_exists(first) && ClassDB::is_parent_class(p_base_class, first)) {
			return names[1];
```

Code after:
	if (!ClassDB::get_integer_constant_enum(p_class, p_enum_constant)) {
		return ScriptLanguage::LOCATION_OTHER;
	}

	int depth = 0;
	StringName class_test = p_class;
	while (class_test && !ClassDB::get_integer_constant_enum(class_test, p_enum_constant, true)) {
		class_test = ClassDB::get_parent_class(class_test);
		depth++;
	}

	return depth | ScriptLanguage::LOCATION_PARENT_MASK;
}

// END LOCATION METHODS

static String _trim_parent_class(const String &p_class, const String &p_base_class) {
	if (p_base_class.is_empty()) {
		return p_class;
	}
	Vector<String> names = p_class.split(".", false, 1);
	if (names.size() == 2) {
		const String &first = names[0];
		if (ClassDB::class_exists(p_base_class) && ClassDB::class_exists(first) && ClassDB::is_parent_class(p_base_class, first)) {
			const String &rest = names[1];
			return rest;
		}
	}
	return p_class;
}

static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg, const String &p_base_class = "") {
	String class_name = p_info.class_name;
	bool is_enum = p_info.type == Variant::INT && p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM;
	// PROPERTY_USAGE_CLASS_IS_BITFIELD: BitField[T] isn't supported (yet?), use plain int.

	if ((p_info.type == Variant::OBJECT || is_enum) && !class_name.is_empty()) {
		if (is_enum && CoreConstants::is_global_enum(p_info.class_name)) {
			return class_name;
		}
		return _trim_parent_class(class_name, p_base_class);
	} else if (p_info.type == Variant::ARRAY && p_info.hint == PROPERTY_HINT_ARRAY_TYPE && !p_info.hint_string.is_empty()) {
		return "Array[" + _trim_parent_class(p_info.hint_string, p_base_class) + "]";
	} else if (p_info.type == Variant::NIL) {
		if (p_is_arg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
			return "Variant";
		} else {
			return "void";
		}
	}