Skip to content

Commit

Permalink
Better hide internal properties from users
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizov committed Jan 26, 2024
1 parent 17e7f85 commit 40d607b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
10 changes: 9 additions & 1 deletion editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2862,9 +2862,17 @@ void EditorHelpTooltip::parse_tooltip(const String &p_text) {
const String &property_name = slices[2];
const String &property_args = slices[3];

String formatted_text;

// Exclude internal properties, they are not documented.
if (type == "internal_property") {
formatted_text = "[i]" + TTR("This property can only be set in the Inspector.") + "[/i]";
set_text(formatted_text);
return;
}

String title;
String description;
String formatted_text;

if (type == "class") {
title = class_name;
Expand Down
6 changes: 5 additions & 1 deletion editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3329,7 +3329,11 @@ void EditorInspector::update_tree() {
if (use_doc_hints) {
// `|` separator used in `EditorHelpTooltip` for formatting.
if (theme_item_name.is_empty()) {
ep->set_tooltip_text("property|" + classname + "|" + property_prefix + p.name + "|");
if (p.usage & PROPERTY_USAGE_INTERNAL) {
ep->set_tooltip_text("internal_property|" + classname + "|" + property_prefix + p.name + "|");
} else {
ep->set_tooltip_text("property|" + classname + "|" + property_prefix + p.name + "|");
}
} else {
ep->set_tooltip_text("theme_item|" + classname + "|" + theme_item_name + "|");
}
Expand Down
12 changes: 9 additions & 3 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
List<PropertyInfo> members;
scr->get_script_property_list(&members);
for (const PropertyInfo &E : members) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP)) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_INTERNAL)) {
continue;
}
if (E.name.contains("/")) {
Expand Down Expand Up @@ -1210,7 +1210,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
List<PropertyInfo> pinfo;
ClassDB::get_property_list(type, &pinfo);
for (const PropertyInfo &E : pinfo) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP)) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_INTERNAL)) {
continue;
}
if (E.name.contains("/")) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
}

for (const PropertyInfo &E : members) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP)) {
if (E.usage & (PROPERTY_USAGE_CATEGORY | PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_INTERNAL)) {
continue;
}
if (!String(E.name).contains("/")) {
Expand Down Expand Up @@ -3514,6 +3514,12 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}

if (ClassDB::has_property(class_name, p_symbol, true)) {
PropertyInfo prop_info;
ClassDB::get_property_info(class_name, p_symbol, &prop_info, true);
if (prop_info.usage & PROPERTY_USAGE_INTERNAL) {
return ERR_CANT_RESOLVE;
}

r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY;
r_result.class_name = base_type.native_type;
r_result.class_member = p_symbol;
Expand Down

0 comments on commit 40d607b

Please sign in to comment.