1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:08:11 +00:00

LibCore+LibGUI: Make ObjectClassRegistration::construct() nullable

This lays the groundwork for allowing the registration of abstract
core objects, which will be needed for improved GML autocomplete.
This commit is contained in:
thislooksfun 2021-10-25 20:19:28 -05:00 committed by Andreas Kling
parent 0e537e2e1f
commit c3b0b9057e
3 changed files with 14 additions and 12 deletions

View file

@ -145,10 +145,11 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
}
auto registration = Core::ObjectClassRegistration::find(class_names.last());
if (registration && registration->is_derived_from(widget_class)) {
auto instance = registration->construct();
for (auto& it : instance->properties()) {
if (it.key.starts_with(identifier_string))
identifier_entries.empend(it.key, identifier_string.length());
if (auto instance = registration->construct()) {
for (auto& it : instance->properties()) {
if (it.key.starts_with(identifier_string))
identifier_entries.empend(it.key, identifier_string.length());
}
}
}
if (can_have_declared_layout(class_names.last()) && "layout"sv.starts_with(identifier_string))
@ -169,10 +170,11 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
if (!class_names.is_empty()) {
auto registration = Core::ObjectClassRegistration::find(class_names.last());
if (registration && registration->is_derived_from(widget_class)) {
auto instance = registration->construct();
for (auto& it : instance->properties()) {
if (!it.value->is_readonly())
identifier_entries.empend(it.key, 0u);
if (auto instance = registration->construct()) {
for (auto& it : instance->properties()) {
if (!it.value->is_readonly())
identifier_entries.empend(it.key, 0u);
}
}
}
}