Skip to content

Commit 4a98dde

Browse files
committed
Require that classes starting with "Editor" be marked internal
1 parent 8d9a1ee commit 4a98dde

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

godot-macros/src/class/derive_godot_class.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,15 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
537537
if let Some(span) = parser.handle_alone_with_span("internal")? {
538538
require_api_version!("4.2", span, "#[class(internal)]")?;
539539
is_internal = true;
540+
} else {
541+
// Godot has an edge case where classes starting with "Editor" are implicitly hidden:
542+
// https://github.com/godotengine/godot/blob/ca452113d430cb96de409a297ff5b52389f1c9d9/editor/gui/create_dialog.cpp#L171-L173
543+
if class.name.to_string().starts_with("Editor") {
544+
return bail!(
545+
class.name.span(),
546+
"Classes starting with `Editor` are implicitly hidden by Godot; use #[class(internal)] to make this explicit",
547+
);
548+
}
540549
}
541550

542551
// Deprecated #[class(hidden)]

godot-macros/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ use crate::util::{bail, ident, KvParser};
452452
///
453453
/// ## Class hiding
454454
///
455-
/// If you want to register a class with Godot, but not have it show up in the editor then you can use `#[class(internal)]`.
455+
/// If you want to register a class with Godot, but not display in the editor (e.g. when creating a new node), you can use `#[class(internal)]`.
456+
///
457+
/// Classes starting with "Editor" are auto-hidden by Godot. They *must* be marked as internal in godot-rust.
456458
///
457459
/// ```
458460
/// # use godot::prelude::*;
@@ -540,7 +542,8 @@ use crate::util::{bail, ident, KvParser};
540542
alias = "var",
541543
alias = "export",
542544
alias = "tool",
543-
alias = "rename"
545+
alias = "rename",
546+
alias = "internal"
544547
)]
545548
#[proc_macro_derive(
546549
GodotClass,

0 commit comments

Comments
 (0)