Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script editor indicates certain classes exist that don't seem to be there #19834

Open
Piet-G opened this issue Jun 29, 2018 · 9 comments
Open

Comments

@Piet-G
Copy link
Contributor

Piet-G commented Jun 29, 2018

Godor Version 3.0.3

This happens for certain EditorPlugin classes, they do exist in C++ form in the Godot source, but when one tries to access/extend them from GDscript there's trouble.

When entering the name of the class in the script editor it turns green, this only seems to happen for valid classes, which indicates that the class is available, yet when I try to extend it I get the following message:

built-in:1 - Compile Error: Unknown class: 'CanvasItemEditorPlugin'

This happens for a bunch of EditorPlugin classes eg:

  • Path2DEditorPlugin
  • CanvasItemEditorPlugin
  • CollisionPolygon2DEditorPlugin
  • ...

The documentation of these classes when retrieved from the editor also turns up nonexistent.

@neikeq
Copy link
Contributor

neikeq commented Jun 29, 2018

This can be fixed by ignoring classes that are not "exposed" as it's done for the C# bindings.

@Piet-G
Copy link
Contributor Author

Piet-G commented Jun 29, 2018

@neikeq Is there a reason these classes aren't exposed? They seem useful.

@neikeq
Copy link
Contributor

neikeq commented Jun 29, 2018

They are not meant to be used, they are part of the editor.

@Piet-G
Copy link
Contributor Author

Piet-G commented Jun 29, 2018

@neikeq But isn't one of the main advantages/features of godot the fact that you can easily expand the features of the engine?

@akien-mga
Copy link
Member

Is this still reproducible in the current master branch?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 19, 2019

Still reproducible in 3.1 stable. Control-Clicking any of these classes opens an empty unnamed doc tab.

@mcradcliffe2490
Copy link

It's been a while is this bug still reproducible with the current version?

@KoBeWi
Copy link
Member

KoBeWi commented Mar 23, 2020

Yes, tested in 20edf69

@neikeq
Copy link
Contributor

neikeq commented Mar 23, 2020

This is probably easy to fix if any one is interested.

For the language runtime:

List<StringName> class_list;
ClassDB::get_class_list(&class_list);
for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) {
StringName n = E->get();
String s = String(n);
if (s.begins_with("_"))
n = s.substr(1, s.length());
if (globals.has(n))
continue;
Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get()));
_add_global(n, nc);
}

For auto-completion:

List<StringName> native_classes;
ClassDB::get_class_list(&native_classes);
for (List<StringName>::Element *E = native_classes.front(); E; E = E->next()) {
String class_name = E->get().operator String();
if (class_name.begins_with("_")) {
class_name = class_name.right(1);
}
if (Engine::get_singleton()->has_singleton(class_name)) {
continue;
}
ScriptCodeCompletionOption option(class_name, ScriptCodeCompletionOption::KIND_CLASS);
options.insert(option.display, option);
}

These should be changed to ignore classes that are not exposed. Something like this:

if (!ClassDB::is_class_exposed(class_name))
    continue;

@akien-mga akien-mga added this to the 4.0 milestone Apr 24, 2021
@YuriSizov YuriSizov modified the milestones: 4.0, 4.x Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants